Tag Info

Hot answers tagged

18

I know this has been answered already on this site, but I cannot seem to find it. Map and Apply do subtly different things. For example, Map[f, {a,b,c}] (* {f[a], f[b], f[c]} *) If you have a list that is more deeply nested, without using the third argument which is for level specification, you get Map[f, {{a,b}, {c}}] (* {f[{a,b}], f[{c}]} *) or, if ...


18

One way would be to redirect all messages issued by ToExpression to a string-stream. Here is an example of that approach, with minimal error-checking: Needs["Developer`"] interpret[str_String] := Module[{s = StreamToString[], r, m} , Block[{$Messages = {s}}, r = ToExpression[str, InputForm, HoldComplete]] ; m = StringFromStream[s] ; Close[s] ; ...


6

This is pitched at the "how to understand" level, not the "how is it implemented" level. I've basically presented how I think of these things, without really caring about how Mathematica carries them out. The object h[2][x] is just another expression-with-head. The head is h[2], which just happens to have a more complicated form than is perhaps usual. In ...


5

In 10.2 there is WolframLanguageData. As a sample, to get a list (sorted by common-ness) of symbols which do not begin with $, are not *Box or *Data functions, are not solely options to other functions, and having got rid of some of the display-only things like AngleBracket: dat = WolframLanguageData[ All, {"CanonicalName", "Frequencies", ...


5

To summarize the comments into an answer: The second element is a list of lists because there may be several different tags sown. For example, Reap[Sow[1, x]; Sow[2, y]; result] (* {result, {{1}, {2}}} *) Another example by belisarius, Reap[Sow[1, {x, y}]; Sow[2, y]; Sow[3, x], _, tag] (* {3, {tag[x, {1, 3}], tag[y, {1, 2}]}} *) See also this ...


5

Simon's code CreateDialog[ {(a = RandomInteger[BernoulliDistribution[0.1], {200, 200}]; Dynamic[ Image[a = 1 - Unitize[(# - 3) (# - 12) (# - 13)] &@ ListConvolve[{{1, 1, 1}, {1, 10, 1}, {1, 1, 1}}, a, {2, 2}, 0]]]), DefaultButton[]}, Modal -> True]


4

There was a wrong bracket in F. Also do not use { as a normal bracket, and second you wrote Exp{[ which has to be either {Exp[ or (Exp[ . F[k1_, k2_, λ1_, λ2_, δ_, w1_, w2_] := (1 - Exp[-(w1/λ1)^k1]) (1 - Exp[-(w2/λ2)^k2]) (Exp[(1 - (1 - Exp[-(w1/λ1)^k1]))^(-δ) + (1 + (1 - Exp[-(w2/λ2)^k2]))^-δ]^(1/-δ))


4

I'd allow myself some guesswork here, that you're going after alternatives as a form of excercise in Mathematica programming. However, you've clearly stated, that the list is list={a, b, c, d, e, f, g, h, i, j, k, l} and the expected output is c + e + g Note, that in the question you've linked, ReplaceList and FoldList are utilized to generate lists of ...


1

No spacebar ... CreateDialog[ {a = Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]; Dynamic[ First@{Graphics[a = Rotate[a, 2 Pi/100], PlotRange -> {{-2, 2}, {-1, 3}}], Pause[1/100];}], DefaultButton[]}, Modal -> True]


1

To use Put or PutAppend with a filename saved in a string in terminal, one can use it in input form rather then >> or >>>, that is: filename="newfile.txt" Put[expression,filename] or PutAppend[expression,filename] I found the answer in http://stackoverflow.com/questions/8853676 by Brett Champion. While this solves my problem, I would ...



Only top voted, non community-wiki answers of a minimum length are eligible