Jump to content

Old lady swallowed a fly: Difference between revisions

adding lambdatalk
m (→‎{{header|C++}}: REASON removed)
(adding lambdatalk)
Line 1,765:
sing()
}</lang>
 
=={{header|Lambdatalk}}==
<lang scheme>
{def A {A.new fly spider bird cat dog goat cow horse}}
-> A
 
{def H
{H.new
fly I don't know why she swallowed that fly{br}Perhaps she'll die |
spider That wiggled and jiggled and tickled inside her |
bird How absurd, to swallow a bird |
cat Imagine that. She swallowed a cat |
dog What a hog to swallow a dog |
goat She just opened her throat and swallowed that goat |
cow I don't know how she swallowed that cow |
horse She's dead of course
}}
-> H
 
{def oldlady {lambda {:w} There was an old lady who swallowed a :w}}
-> oldlady
 
{def swallow {lambda {:a :b} She swallowed the :a to catch the :b}}
-> swallow
 
Writing
 
{hr}{oldlady {A.get 0 {A}}}
{H.get {A.get 0 {A}} {H}}
 
{S.map {lambda {:i}
{hr}{oldlady {A.get :i {A}}}
{br}{H.get {A.get :i {A}} {H}}
{S.map {lambda {:j} {br}* {swallow {A.get :j {A}}
{A.get {- :j 1} {A}}}}
{S.serie :i 1 -1}}
{br}{H.get {A.get 0 {A}} {H}} }
{S.serie 1 6}}
 
{hr}{oldlady {A.get 7 {A}}}
{H.get {A.get 7 {A}} {H}}
 
displays:
 
There was an old lady who swallowed a fly
I don't know why she swallowed that fly
Perhaps she'll die
 
There was an old lady who swallowed a spider
That wiggled and jiggled and tickled inside her
* She swallowed the spider to catch the fly
I don't know why she swallowed that fly
Perhaps she'll die
 
There was an old lady who swallowed a bird
How absurd, to swallow a bird
* She swallowed the bird to catch the spider
* She swallowed the spider to catch the fly
I don't know why she swallowed that fly
Perhaps she'll die
 
...
 
There was an old lady who swallowed a cow
I don't know how she swallowed that cow
* She swallowed the cow to catch the goat
* She swallowed the goat to catch the dog
* She swallowed the dog to catch the cat
* She swallowed the cat to catch the bird
* She swallowed the bird to catch the spider
* She swallowed the spider to catch the fly
I don't know why she swallowed that fly
Perhaps she'll die
 
There was an old lady who swallowed a horse
She's dead of course
</lang>
 
=={{header|Liberty BASIC}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.