Skip to main content
Fix formatting
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45

In fact by doing tests for this explanation I found a short way to use a growing glob that properly handles the first empty entry. Run as perl -ap kleene0.pl <<< "a b" (so add 2 bytes for -ap` (so add 2 bytes for -ap)

In fact by doing tests for this explanation I found a short way to use a growing glob that properly handles the first empty entry. Run as perl -ap kleene0.pl <<< "a b" (so add 2 bytes for -ap`)

In fact by doing tests for this explanation I found a short way to use a growing glob that properly handles the first empty entry. Run as perl -ap kleene0.pl <<< "a b" (so add 2 bytes for -ap)

Also mention that all these programs will run out of memory
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45

All I still need to do is prime the loop with an empty string. That is done by effectively doing using$#a = 0 (, in numeric context becomes 0) which causes the first and only element of @a to become undef which will behave like "" when I use it

All these solutions will keep more and more of the output in memory and that will cause the program to fail after some time. You can also use perl globs for lazy generation by using them in scalar context, but that makes the programs longer....

All I still need to do is prime the loop with an empty string. That is done by effectively doing $#a = 0 (, in numeric context becomes 0) which causes the first and only element of @a to become undef which will behave like "" when I use it

All I still need to do is prime the loop with an empty string. That is done using$#a = 0 (, in numeric context becomes 0) which causes the first and only element of @a to become undef which will behave like "" when I use it

All these solutions will keep more and more of the output in memory and that will cause the program to fail after some time. You can also use perl globs for lazy generation by using them in scalar context, but that makes the programs longer....

Minor textual fixes
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45

Perl, 39 3737 35 bytes

Explanation:

Explanation:

Improvement

kleenekleene0.pl (this version is 33+2 bytes):

Perl, 39 37 35 bytes

Explanation:

kleene.pl (this version is 33+2 bytes):

Perl, 39 37 35 bytes

Explanation:

Improvement

kleene0.pl (this version is 33+2 bytes):

Gain 2 bytes
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45
Loading
Add explanation, fix byte counts which were too high
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45
Loading
Oops, mis-count. The $#a trick in fact gained 2 bytes, not just 1
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45
Loading
Properly count the penalty for having to split the input string
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45
Loading
Unexpectedly shave of 1 byte
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45
Loading
Fix formatting
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45
Loading
Source Link
Ton Hospel
  • 15k
  • 1
  • 23
  • 45
Loading