0
|
6893 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
GROUPS:

# Questions about the code signs in Mathematica: @, #, / ?

Posted 10 years ago
 checkIfOn := (Select[# < 0.1 & /@       scaledTrajectory[[iterator ;; iterator +2]], # &] // Length) == 0I am very confused by this code, what does "# < 0.1 & /@" mean, here the scaledTrajectory[] just means a table of numbers. I could find "#" meaning, but just cann't figure this code's meaning out. I would appreciate it very much if anyone could help.
3 Replies
Sort By:
Posted 10 years ago
 This is perhaps more easily seen as:checkIfOn := (Select[Function[{x}, x < 0.1] /@ scaledTrajectory[[iterator ;; iterator +2]], Function[{x}, x]] // Length) == 0That is, "select, from the True or False outputs we get on testing whether each of these three scaledTrajectories is less than 0.1, those which are identically the symbol True; find the length of what we just output; see whether it's equal to 0".It is much more neatly phrased as:MemberQ[scaledTrajectory[[iterator ;; iterator + 2]], _?(# < 0.1 &)]
Posted 10 years ago
 Many of these cryptic characters are in the documentation. The descriptions can help, or at least give suggestions for what to look under.  In:= ? /@                                                                            Map[f, expr] or f/@expr applies f to each element on the first level in expr.       Map[f, expr, levelspec] applies f to parts of expr specified by levelspec.   In:= ? #                                                                             # represents the first argument supplied to a pure function.      #n represents the n'th  argument. In:= ? &                                                                            Function[body] or body &       is a pure function. The formal parameters are # (or #1), #2, etc.       Function[ x, body] is a pure function with a single formal parameter x.      Function[{x1 , x2 , }, body] is a pure function with a list of formal parameters.
Posted 10 years ago
 An expression containing # (and perhaps a few other special characters) and ending with an &is a shorthand notation for definining a function without giving it a name. This tutorial might helpyou begin to get an idea how this works, but it sometimes takes some study and practice to beable to understand this notation when you see it used.http://reference.wolfram.com/mathematica/tutorial/PureFunctions.html