Thanks Björn, Roger, and Lettow.

The docs imply that J and its predecessor APL use prefix/right-to-left
syntax. So I expected all J code to have the form:

operator operands

And therefore defining functions to be similar to stack languages, but in
reverse order.

myfunc =: operator constant_operands &

Or like Haskell function composition, because a fully right-to-left order of
operations makes composition intuitive.

myfunc =: operator constant_operands

I wish J didn't use infix operators as they create confusion in a
predominately prefix language.

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Fri, Oct 28, 2011 at 2:04 PM, Lettow, Kenneth <[email protected]>wrote:

> You should post this in jprogramming.
>
> In any case, it looks like you just juxtaposed a few characters.
>
>  mod3=: 3&|
>   mod3 i.10
> 0 1 2 0 1 2 0 1 2 0
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Andrew Pennebaker
> Sent: Friday, October 28, 2011 1:54 PM
> To: J
> Subject: [Jbeta] syntax for functions and modulo
>
> I'm trying to make a function mod3 that returns the input modulo three,
> but
> my syntax is wrong. I don't see why the syntax would be any different
> from
> the double example in the docs.
>
> $ jconsole
>   double =: * & 2
>   double 1
> 2
>   double 2
> 4
>   double 3
> 6
>   mod3 =: 3 | &
> |syntax error
> |   mod3=:    3|&
>
>
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to