worked example: bottles-of-beer

    description:
        sing the bottles of beer song

    code:
        n-1 |*> #=> arithmetic(|_self>, |->, |1>)

        bottles |0> => |no more bottles>
        bottles |1> => |1 bottle>
        bottles |*> #=> |_self> __ |bottles>

        first-line |*> #=> to-upper[1] bottles |_self> __ |of beer on the wall,> __ bottles |_self> __ |of beer.>

        second-line |*> #=> |Take one down and pass it around,> __ bottles n-1 |_self> __ |of beer on the wall.>
        second-line |0> #=> |Go to the store and buy some more,> __ bottles max |bottles> __ |of beer on the wall.>

        row |*> #=> first-line |_self> . second-line |_self> . |>

        max |bottles> => |10>
        sing |*> #=> smerge["
"] row sp2seq reverse range(|0>, max |bottles>)

        -- alternate version:
        -- NB: tidy is purposely not defined, so 'sdrop tidy seq' returns |> for all sequences seq
        sing2 |*> #=> sdrop tidy print row sp2seq reverse range(|0>, max |bottles>)

    examples:
        max |bottles> => |4>
        sing
            |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, 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, 4 bottles of beer on the wall.
            >

    source code:
        load bottles-of-beer.sw
    
    see also:
    

Home