Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

The best way makes loops is (copy do) copy do and add extra, for example
(10) (swap copy some (nip) (decrement swap copy do) choice do) copy do

or more general
Setup (Condition (Fail) (Succeed copy do) choice do) copy do

Thank you! I guess I'll have to implement some of the arithmetic words then - I don't know what was stopping me from making a utility block as you've described that wasn't explicitly presented as a word to be defined. Probably because stack based programming, as powerful and minimal and beautiful as it is, is still alien and daunting to the way I've always written software - it would have taken me a while to formulate the solution you've shown. Learning this and getting better at it is something I'm compelled to continue trying because I know deep down that there is something to what all the Forth people are on about.

Thanks for reading my long winded blog post, and thanks again for the help!

Here is my slow, long, but functioning solution for join:

() bury ( ) swap cat cat ( ) split do copy buryd swap cat cat (digd peek some (zap zap nip) (buryd bury copyd buryd cat digd cat swap copy do) choice do) copy do

(+1)

it looks like your starting to figure it out! Btw, I recently learned that instead of "(A B choice) copy do" you can have "(B if) copy do A" and it's slightly faster.