You could use agenda:
replfb=: ":`('Fizz'&[)`('Buzz'&[)`('FizzBuzz'&[) @. ([: #. 0 = 5 3 | ])
replfb&>:>i.100
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
...
On 3/6/07, Roger Hui <[EMAIL PROTECTED]> wrote:
Well:
FB =: (": [^:([EMAIL PROTECTED]@]) Fizz,Buzz)"0
FB1 =: (": (] , [EMAIL PROTECTED] }. [) Fizz,Buzz)"0
(FB -: FB1) >: i.100
1
# ;: 5!:5 <'FB'
19
# ;: 5!:5 <'FB1'
17
I could also move the "0 from the definition
to the expression FB"0 >:i.100 . That'd get
rid of the overall parens.
----- Original Message -----
From: Raul Miller <[EMAIL PROTECTED]>
Date: Tuesday, March 6, 2007 2:54 pm
Subject: Re: [Jprogramming] FizzBuzz
> On 3/6/07, Roger Hui <[EMAIL PROTECTED]> wrote:
> > Fizz=: 'Fizz' #~ 0 = 3&|
> > Buzz=: 'Buzz' #~ 0 = 5&|
> > FB =: (": [^:(0&[EMAIL PROTECTED]@]) Fizz,Buzz)"0
> > FB >: i.100
>
> That's shorter than what I was going to do.
>
> That said, FB could be
>
> FB=: (": [^:([EMAIL PROTECTED]) Fizz,Buzz)"0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm