I got this:
fb =: (verb : '((15 3 5|y)i.0){''fizzbuzz'';''fizz'';''buzz'';y')"0
Although it resorts to explicit definition (so what?) it does use 15 instead
of 3 "and" 5, which I haven't seen so far.
------------------------------------------------------------------------
|\/| Randy A MacDonald | APL: If you can say it, it's done.. (ram)
|/\| [EMAIL PROTECTED] |
|\ | | The only real problem with APL is that
BSc(Math) UNBF'83 | it is "still ahead of its time."
Sapere Aude | - Morten Kromberg
Natural Born APL'er | Demo website: http://156.34.84.219/
-----------------------------------------------------(INTP)----{ gnat }-
----- Original Message -----
From: "June Kim" <[EMAIL PROTECTED]>
To: "Programming forum" <[email protected]>
Sent: Tuesday, March 06, 2007 4:33 PM
Subject: [Jprogramming] FizzBuzz
> FizzBuzz is a very simple toy problem for screening programming
> applicants at interviews.
>
> The problem is:
>
> Write a program that prints the numbers from 1 to 100. But for
> multiples of three print "Fizz" instead of the number and for the
> multiples of five print "Buzz". For numbers which are multiples of
> both three and five print "FizzBuzz".
>
> see some solutions in various languages at:
> *
http://mult.ifario.us/articles/2007/01/25/laziness-and-fizzbuzz-in-haskell
> *
http://tickletux.wordpress.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/
> * http://programming.reddit.com/info/10d7w/comments
> * http://www.ittutor.net/forums/index.php?showtopic=31262
> * http://tkyte.blogspot.com/2007/02/what-is-your-fizzbuzz-factor.html
>
> How short and simple solution in J can you write for this problem?
>
>
> Following are my trials:
>
> f=:0=3&|
> b=:0=5&|
> pr=:[: ; (('';'fizz') {~ f) , ('';'buzz') {~ b
> fb=:":[EMAIL PROTECTED](f+.b)"0
>
> s=:(('';'fizz') {~ f ) , each ('';'buzz') {~ b
> ll=:,:~ s&>
> fb2=:[: ":&> (a: = [EMAIL PROTECTED])[EMAIL PROTECTED]@:(<"0)
>
> assert (fb -: fb2) >:i.100
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm