|| @iamidly
-- a blog about sham, unix and software design. also i rant.

repeat

repeat is a loop construct in sham. it breaks on break and skips to the end of a grouping with continue.
a repeat group without a break will not terminate.

#!/usr/bin/env sham
aseq 1..5 | repeat { read idx || break
                     echo index is now $idx
                   }
@iamidly> sham /tmp/EXAMPLE_CODE_0_
index is now #a
index is now 1
index is now 2
index is now 3
index is now 4
index is now 5
#!/usr/bin/env sham
aseq 1..5 | repeat { read idx
                     echo index is now $idx
                     break
                   }
@iamidly> sham /tmp/EXAMPLE_CODE_1_
index is now #a
#!/usr/bin/env sham
aseq 1..5 | repeat { read idx || break
                     echo index is now $idx
                     continue
                   }
@iamidly> sham /tmp/EXAMPLE_CODE_2_
index is now #a
index is now 1
index is now 2
index is now 3
index is now 4
index is now 5
|| come join me at #sham on irc.snoonet.net
</post>