Here I send four aeguments into f
f=. 3 : 0
('a b c d')=.y
smoutput a
smoutput b
smoutput c
smoutput d
''
)
f 'adds';4;'skhfdgkjf';2 3$5 234534 534 52 35465
adds
4
skhfdgkjf
5 234534 534
52 35465 5
2011/10/29 Andrew Pennebaker <[email protected]>
> Apologies for crossposting, I'm registering for the programming forum right
> now.
>
> Okay, the left argument is assigned to x, the right argument is assigned to
> y.
>
> What about functions with arity greater than 2?
>
> Lightbulb: Does J limit arity to 0, 1, or 2?
>
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us
>
> On Fri, Oct 28, 2011 at 9:37 PM, Ric Sherlock <[email protected]> wrote:
>
> > Explicit definitions like fizzy require you to refer to the arguments
> > explicitly. The right argument is assigned to "y" locally within the
> > verb (right argument is assigned to "x")
> >
> > fizzy =: 3 : 0
> > if. div35 y do.
> > 'FizzBuzz'
> > elseif. div3 y do.
> > 'Fizz'
> > elseif. div5 y do.
> > 'Buzz'
> > elseif. 1 do.
> > > 'd' (8!:0) y
> > end.
> > )
> >
> > On Sat, Oct 29, 2011 at 2:15 PM, Andrew Pennebaker
> > <[email protected]> wrote:
> > > To get a feel for J, I'm implementing FizzBuzz, but I keep getting a
> > control
> > > error.
> > >
> > > #!/usr/bin/env jconsole
> > >
> > > div3 =: 0 = 3 & |
> > >
> > > div5 =: 0 = 5 & |
> > >
> > > div35 =: div3 *. div5
> > >
> > > fizzy =: 3 : 0
> > > if. div35 & do.
> > > 'FizzBuzz'
> > > elseif. div3 & do.
> > > 'Fizz'
> > > elseif. div5 & do.
> > > 'Buzz'
> > > elseif. 1 do.
> > > > 'd' (8!:0) &
> > > end.
> > > )
> > >
> > > fizzy 1
> > >
> > > exit ''
> > >
> > > Cheers,
> > >
> > > Andrew Pennebaker
> > > www.yellosoft.us
> > >
> > > On Fri, Oct 28, 2011 at 8:39 PM, Tom Arneson <[email protected]>
> wrote:
> > >
> > >> Try
> > >>
> > >> mod3=: 3&|
> > >>
> > >>
> > >> -----Original Message-----
> > >> From: [email protected] [mailto:[email protected]]
> On
> > >> Behalf Of Andrew Pennebaker
> > >> Sent: Friday, October 28, 2011 12:54
> > >> 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
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Björn Helgason, Verkfræðingur
Fornustekkum II
781 Hornafirði,
t-póst: [email protected]
gsm: +3546985532
twitter: @flugfiskur
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=) ♖♘♗♕♔♙
`. )----' (")_(") ☃☠
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm