On Thu, Oct 20, 2011 at 12:52 PM, David Vaughan <[email protected]> wrote: > Thanks. > > How does the $: verb work? I don't really get it from the dictionary page. > For example how does it work in: > > sqrt=: DP&$: : (4 : 0) " 0 > assert. 0<:y > %/ <.@%: (2 x: (2*x) round y)*10x^2*x+0>.>.10^.y > )
http://www.jsoftware.com/help/dictionary/d212.htm says: $: denotes the longest verb that contains it. In this case, the definition of sqrt is the longest verb that contains it. So, it's almost equivalent to DP&sqrt -- the difference being that it's anonymous and not tied to the name. So you could define: SQRT=: sqrt f. sqrt=: [: and monadic SQRT would continue to work. > I can see that it makes x =. DP, but I don't know why. My best guess is that > $: literally means 'sqrt' and so it is equivalent to DP&sqrt y Just about... > Then again the extra colon after DP&$: is not clear to me either. That extra colon is http://www.jsoftware.com/help/dictionary/d310v.htm The verb on the left is the definition used for the monad case where the verb on the right (which must always be enclosed in parenthesis unless it's only one word) is the definition used for the dyad case. Finally, since "0 on that line is not in parenthesis, it applies to both the monad and dyad cases. FYI, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
