fork download
  1. \ counted strings: compile, skip over.
  2. : s, ( au-) dup c, here swap dup allot move ;
  3. : s+ ( a-a) count + ;
  4.  
  5. \ at each (v)erse addr: tag c, beast s, aside s, len c,
  6. : v: ( u-) here >r c, parse-name s, 0 parse s, here r> - c, ;
  7. : v+ ( v-v) 1+ s+ s+ 1+ ;
  8. : v- ( v-v) 1- dup c@ - ;
  9. : always? ( v-vf) dup c@ 1 and ;
  10. : end? ( v-vf) dup c@ 2 and ;
  11. : beast ( v-v) dup 1+ count type ;
  12. : aside ( v-v) dup 1+ s+ count type ;
  13.  
  14. Create fly
  15. 3 v: fly I don't know why she swallowed a fly, %Perhaps she'll die.
  16. 1 v: spider It wiggled and jiggled and tickled inside her.
  17. 0 v: bird How absurd, to swallow a bird.
  18. 0 v: cat Imagine that! She swallowed a cat!
  19. 0 v: dog What a hog to swallow a dog.
  20. 0 v: goat She just opened her throat and swallowed that goat.
  21. 0 v: cow I don't know how she swallowed that cow.
  22. 2 v: horse.. She's dead, of course.
  23. 10 fly v+ 21 - c! \ Replace the % with a newline.
  24.  
  25. : twaolwsa ." There was an old lady who swallowed a " ;
  26. : sst ." She swallowed the " ;
  27. : tct ." to catch the " ;
  28. : dot '.' emit ;
  29.  
  30. : ?aside ( v-v) always? if cr aside then ;
  31. : reason- ( v-v) cr sst beast tct v- beast dot ?aside ;
  32. : reasons ( v-v) dup begin reason- end? until drop ;
  33. : lyric ( v-v) cr cr twaolwsa beast dot cr aside ;
  34. : verses+ ( v-v) begin lyric reasons v+ end? until ;
  35. : song ( -) fly lyric v+ verses+ lyric drop ;
  36. song
  37.  
Success #stdin #stdout #stderr 0.01s 5320KB
stdin
Standard input is empty
stdout

There was an old lady who swallowed a fly.
I don't know why she swallowed a fly, 
Perhaps she'll die.

There was an old lady who swallowed a spider.
It wiggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed a 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.
It wiggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed a fly, 
Perhaps she'll die.

There was an old lady who swallowed a cat.
Imagine that! She swallowed a cat!
She swallowed the cat to catch the bird.
She swallowed the bird to catch the spider.
It wiggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed a fly, 
Perhaps she'll die.

There was an old lady who swallowed a dog.
What a hog to swallow a 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.
It wiggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed a fly, 
Perhaps she'll die.

There was an old lady who swallowed a goat.
She just opened her throat and swallowed that 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.
It wiggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed a 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.
It wiggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly.
I don't know why she swallowed a fly, 
Perhaps she'll die.

There was an old lady who swallowed a horse...
She's dead, of course.
stderr
redefined S, with s,  redefined s+