Linked Questions

4 votes
1 answer
250 views

Association of pure functions [duplicate]

I've encountered confusing behavior of Association when I try to use it for storing pure functions. For example: as = <|"1" -> # + 1 &|> ...
iav's user avatar
  • 2,016
76 votes
3 answers
6k views

when is f@g not the same as f[g]?

I have always thought that f@g will give the same result as f[g] in all cases, and it is just a matter of style which one to use ...
Nasser's user avatar
  • 145k
30 votes
3 answers
1k views

Parentheses in pure functions: # & vs. ( # &)

I've been using Mathematica for years, and over time I have developed the habit of using: Select[data, (# == 1 &)] instead of ...
Eric Brown's user avatar
  • 4,426
37 votes
3 answers
3k views

How to Combine Pattern Constraints and Default Values for Function Arguments?

EDIT: As several respondents have noted in the answers and comments below, the original example had a default value that would never be used because of the way patterns and default values are ...
StackExchanger's user avatar
24 votes
3 answers
1k views

How can I get the unchanged Box form of an arbitrary expression?

One may observe that MakeBoxes does not give the actual Box form of various expressions: MakeBoxes[{1*^4, 000123, a*b c}] <...
Mr.Wizard's user avatar
  • 272k
15 votes
2 answers
606 views

Infix form of PutAppend ( >>> ) does not work with variable

I'm new to Mathematica, so I suspect this question involves either a misunderstanding involving variables or the usage of >>>. On a webMathematica page (...
Daniel's user avatar
  • 825
18 votes
1 answer
1k views

Is there a guideline about when to end expressions with semicolons?

Whether for nested Ifs or within scoping constructs like Module and Block, I never know ...
Andrew Cheong's user avatar
9 votes
3 answers
202 views

Metaquestion: how to find out why (e.g.) MatchQ[42, _?Function[x, True]] is False?

Suppose you run into a bewildering Mathematica result (which happens to me several times per Mathematica session, even after a 20-year acquaintance), such as, for example: ...
kjo's user avatar
  • 11.7k
17 votes
3 answers
580 views

What is the real default CellEvaluationFunction?

The default CellEvaluationFunction is Identity but one can quickly see that this is handled specially as an equivalent function, ...
Mr.Wizard's user avatar
  • 272k
3 votes
4 answers
1k views

Extracting RHS from Rule

In an example from another question, the rhs of a list of rules can be simply extracted: ...
ebergerson's user avatar
1 vote
2 answers
205 views

Confused about scoping, not sure what to ask

I'm grading for a class using Mathematica right now, and one of the students ran into a weird issue. When he ran code like this: ...
eipxen's user avatar
  • 13
5 votes
2 answers
275 views

Associativity of `/@` [duplicate]

Why are the following not equivalent: Map[Line, Map[(Print[#]; #) &, {{{2, 1}, {1, 1}}, {{-2, 1}, {3, 1}}}]] which produces ...
d125q's user avatar
  • 437
2 votes
2 answers
350 views

FullForm applied to functions

I would have expected FullForm[Cases[{a^2, a^3}, a_^1]] to produce Cases[List[Power[a, 2], Power[a ,3]], Pattern[a, Blank[]]]...
bbgodfrey's user avatar
  • 61.6k
0 votes
1 answer
769 views

how to work with list as function parameter

I want to output an arrow based on input from user and I tried writing this small function to achieve this: ...
Pankaj Sejwal's user avatar
4 votes
1 answer
532 views

How to see abstract syntax tree of Wolfram Language expression

I mean, suppose I have this expression: 2 + 2 I want to get something like this: Plus[2, 2] as an output. I've tried FullForm, but this just evaluates 2+2 and returns 4. Is this even possible?
Ezo's user avatar
  • 43

15 30 50 per page