Skip to main content
deleted 3 characters in body
Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141

Zsh + coreutils, 406 308 375 bytes

g()ls -t<>"She$d the $1 to catch the $2,"
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!

Tricks:

  • the g function creates the line as a file and then ls lists the files in the current directory in order of creation (-t), to avoid having to repeat the previous lines every time.
    • I used <> (which creates the file before the command is executed) instead of >...; because using multiple commands in a function requires {} around them
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form setting b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)

Zsh + coreutils, 406 308 375 bytes

g()ls -t<>"She$d the $1 to catch the $2,"
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!

Tricks:

  • the g function creates the line as a file and then ls lists the files in the current directory in order of creation (-t), to avoid having to repeat the previous lines every time.
    • I used <> (which creates the file before the command is executed) instead of >...; using multiple commands in a function requires {} around them
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form setting b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)

Zsh + coreutils, 406 375 bytes

g()ls -t<>"She$d the $1 to catch the $2,"
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!

Tricks:

  • the g function creates the line as a file and then ls lists the files in the current directory in order of creation (-t), to avoid having to repeat the previous lines every time.
    • I used <> (which creates the file before the command is executed) instead of >...; because using multiple commands in a function requires {} around them
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form setting b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)
-13
Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141

Zsh + coreutils, 406 308 382375 bytes

g(){echols She$d-t<>"She$d the $1 to catch the $2,>>o;tac o}"
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!Try it online!

Tricks:

  • the g function appends (>>)creates the line to theas a file o and then prints ols lists the files in reverse linethe current directory in order of creation (tac-t), to avoid having to repeat the previous lines every time.
    • I used <> (which creates the file before the command is executed) instead of >...; using multiple commands in a function requires {} around them
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form setting b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)

Zsh + coreutils, 406 382 bytes

g(){echo She$d the $1 to catch the $2,>>o;tac o}
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!

Tricks:

  • the g function appends (>>) the line to the file o and then prints o in reverse line order (tac), to avoid having to repeat the previous lines every time
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form setting b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)

Zsh + coreutils, 406 308 375 bytes

g()ls -t<>"She$d the $1 to catch the $2,"
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!

Tricks:

  • the g function creates the line as a file and then ls lists the files in the current directory in order of creation (-t), to avoid having to repeat the previous lines every time.
    • I used <> (which creates the file before the command is executed) instead of >...; using multiple commands in a function requires {} around them
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form setting b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)
added 23 characters in body
Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141

Zsh + coreutils, 406 382 bytes

g(){echo She$d the $1 to catch the $2,>>o;tac o}
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!

Tricks:

  • the g function appends (>>) the line to the file o and then prints o in reverse line order (tac), to avoid having to repeat doing itthe previous lines every time
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form assigningsetting b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)

Zsh + coreutils, 406 382 bytes

g(){echo She$d the $1 to catch the $2,>>o;tac o}
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!

Tricks:

  • the g function appends the line to the file o and then prints o in reverse line order, to avoid having to repeat doing it every time
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form assigning b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)

Zsh + coreutils, 406 382 bytes

g(){echo She$d the $1 to catch the $2,>>o;tac o}
set bird spider \ swallow iggled\ 
<<Z
${b=There was an old lady who${d=$3ed} a }fly.${5=
I don't know why she$d that fly,
Perhaps she'll die.

$b}$2,
That wr$4and $4and j$4inside her.
`g $2 fly`$5$1,
How absurd${6= to$3 a }$1.
`g $@`$5cat,
Imagine that$6cat.
`g cat $1`$5dog,
What a hog$6dog.
`g dog cat`$5horse,
She died of course.

Try it online!

Tricks:

  • the g function appends (>>) the line to the file o and then prints o in reverse line order (tac), to avoid having to repeat the previous lines every time
  • set bird ... assigns the words to $1, $2, etc.
  • \ swallow includes a space at the start of without needing to use quotes
  • <<Z starts a heredoc which is effectively a long interpolated string
  • ${b=There...} is a shorthand form setting b to that string and substituting its value in
  • Indexed variables like $1, $2, etc. can be substituted without a space afterwards (rather than being interpreted as a variable called 5dog, for example), so we prefer them as it allows us to include the space inside the assignment to avoid repeating it
  • g $@: since we set $1 and $2 to bird and spider respectively, we can pass all the numbered variables to g in one go with $@ instead of g $1 $2 (it ignores the extra ones, $3 etc.)
-26 and add explanation of some tricks
Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141
Loading
Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141
Loading