real language

## Language J

```See http://www.cs.trinity.edu/About/The_Courses/cs2322/

Date: Thu, 8 Mar 2001 09:23:02 -0500
From: Roger Hui
To: APL Mailing List , J Forum , TimTroyR@ionet.net
Subject: Jforum: Re: New Scientist Puzzle and Oddball Languages

NB. a solution in J (http://www.jsoftware.com) to the 99 Bottles of Beer problem.

bob =: ": , ' bottle'"_ , (1: = ]) }. 's of beer'"_
bobw=: bob , ' on the wall'"_
beer=: bobw , ', '"_ , bob , '; take one down and pass it around, '"_ , bobw@<:

NB. For example:

beer"0 >:i.-5
5 bottles of beer on the wall, 5 bottles of beer; take one down and pass it around, 4 bottles of
beer on the wall
4 bottles of beer on the wall, 4 bottles of beer; take one down and pass it around, 3 bottles of
beer on the wall
3 bottles of beer on the wall, 3 bottles of beer; take one down and pass it around, 2 bottles of
beer on the wall
2 bottles of beer on the wall, 2 bottles of beer; take one down and pass it around, 1 bottle of beer
on the wall
1 bottle of beer on the wall, 1 bottle of beer; take one down and pass it around, 0 bottles of beer
on the wall```

## Alternative Versions

Raul Miller said on 10/02/05 07:05:41

NB. a slightly more concise of Hui's implementation

bob =: ": , ' bottles of beer'"_ -. 1&= # 's'"_
bobw=: bob , ' on the wall'"_
beer=: bobw , ', '"_ , bob , '; take one down and pass it around, '"_ , bobw@<:

beer"0 (- i.) 99

Raul Miller said on 10/02/05 07:25:26

A slightly quirkier implementation:

c=: "_
n=: 'No more'c`":@.*@(100&|)
bob=: n, ' bottles of beer'c -. 1&= # 's'c
L1=: bob, ' on the wall'c
L2=: bob, '!'c
L3=: 2&<. { ([;._2 noun define)c
Go to the store and buy some more
if one of those bottles should happen to fall
Take one down, pass it around
)
L4=: L1@<:, '!'c
lyrics=: (L1, L2, L3,: L4)"0 i.-100

Here's how the last four verses appear with this version.

_4 {. lyrics

3 bottles of beer on the wall
3 bottles of beer!
Take one down, pass it around
2 bottles of beer on the wall!

2 bottles of beer on the wall
2 bottles of beer!
Take one down, pass it around
1 bottle of beer on the wall!

1 bottle of beer on the wall
1 bottle of beer!
if one of those bottles should happen to fall
No more bottles of beer on the wall!

No more bottles of beer on the wall
No more bottles of beer!
Go to the store and buy some more
99 bottles of beer on the wall!

Futureboy said on 04/12/07 14:15:05

This doesn't appear to produce the canonical form of the song, e.g. "no more bottles of beer".

PoodleNoodle said on 12/19/08 17:54:52

@Futureboy: Oh noes!
It seems to integrate the 10 green bottles song into it, I prefer it, as a small twist and a bit of a surprise from the same old script.

Johanna22OBRIEN said on 08/07/10 01:34:59

Make your own life time easier take the <a href="http://bestfinance-blog.com/topics/credit-loans">credit loans</a> and all you require.

Konsolen said on 09/02/10 05:11:46

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.