[Jprogramming] FizzBuzz

June Kim juneaftn at gmail.com
Wed Mar 7 11:48:51 HKT 2007


2007/3/7, Sherlock, Ric <R.G.Sherlock at massey.ac.nz>:
> Hmmm...
> I tried opening a new J session & copying your code in & running it line
> by line with the following output:
>
>   f=: 0=3&|
>   b=: 0=5&|
>   pr=: [: ; (('';'fizz') {~ f) , ('';'buzz') {~ b fb=:":`pr at .(f+.b)"0

It's two lines erroneously concatenated into one.

Try splitting it into two:

pr=:[: ; (('';'fizz') {~ f) , ('';'buzz') {~ b

fb=:":`pr at .(f+.b)"0

> |domain error: f
> |   pr=:[:;    (('';'fizz'){~f),('';'buzz'){~b fb=:":`pr at .(f+.b)"0
>
> I'm not sure what I'm doing wrong??
>
>
> t in my solution can of course be simplified from
> t=: (>./"1 f,.(2*b),.(3*f*.b))
> to
> t=: >./ 1 2 3 * f,b,:f*.b
> (I always tend to think in columns which is not as concise as rows in J)
>
>
>
> > -----Original Message-----
> > From: programming-bounces at jsoftware.com
> > [mailto:programming-bounces at jsoftware.com] On Behalf Of June Kim
>
> > > I tried to run yours to see if the output was OK but got a domain
> > > error when I ran pr=:...
> >
> > I don't have any error. Try it again in a clean session. (for
> > instance, do clear 'base' first)
> >
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>


More information about the Programming mailing list