2021-12-01 09:48:33 is there a common word that takes 3 arguments and drops one of the two depending on the third? thinking about IIF in other languages or IF as a function like IF(a,b,c) where it returns b or c depending on a 2021-12-01 09:49:18 : IIF IF DROP ELSE NIP THEN ; 2021-12-01 09:53:37 ?DROPNIP or something 2021-12-01 10:50:46 I've used `select` for that 2021-12-01 10:58:00 im working on a markup file to describe peephole optimization patterns and im using a primitive stack language for calculations 2021-12-01 10:58:24 so trying to get away with no return stack so no structures or loops 2021-12-01 10:59:38 changing = and <> to return 1 instead of -1 for true lets you multiple and add values which is like a primitive functional IF 2021-12-01 11:01:02 : FOO IF 5 ELSE 7 THEN ; -> DUP 5 * SWAP NOT 7 * + 2021-12-01 11:09:24 what is your NOT ? 2021-12-01 11:09:51 (on my forth, I get I get either -5 or -7 with that, not 5 or 7, and under gforth, using INVERT, the same) 2021-12-01 11:12:01 0 becomes 1 and 1 becomes 0 2021-12-01 11:55:25 this won't work on a standard forth where flags are equal to -1 and 0 2021-12-01 12:17:37 right but you have structures and a return stack and everything on standard forths 2021-12-01 12:18:10 im just doing it like this for this one off markup language reader that isnt a full forth so i was curious if theres already a good way to do it in forth rather than suggesting this be added to forth or anything 2021-12-01 12:32:01 MrMobius: you could use pick and roll to do the hard things of accessing deep stack elements. 2021-12-01 12:33:22 wouldn't require a second stack. 2021-12-01 12:35:31 imode, right. im just saying implementing IF and THEN requires a second stack so easier to make a word that selects from two values 2021-12-01 12:37:49 eh. 2021-12-01 12:38:08 I couldn't parse that. 2021-12-01 12:47:15 i mean in a simple markup file where you need to list some short calculations you can use stack based calculations because theyre easier to implement 2021-12-01 12:48:02 but i didnt want to implement a full forth so asking about doing IF as a function instead of IF/THEN so dont need return stack 2021-12-01 12:53:07 you could do some variant of `pick` instead of `if` if you wanted to. 2021-12-01 12:53:49 `0 pick` is `dup`, so you could have a negative value indicate a `drop` and use different sentinels to select between a and b. 2021-12-01 17:23:36 Done day 1 advent of code in standard forth https://pastebin.com/raw/CAX9WH5B https://pastebin.com/raw/A2j4En77 2021-12-01 17:23:53 This year I'm abusing the built-in parsing rather than reading from a file 2021-12-01 17:24:38 I mean we already have a load of words for parsing, so it's a bit mad to reimplement that to read a separate file 2021-12-01 17:24:48 That's not thinking like a true forther 2021-12-01 18:10:45 veltas, that is probably thinking like a true forther. I think that's what the POL book was getting at. 2021-12-01 18:29:12 http://forth.works/share/d96d31b6ee05a9493a79799ffa4f29fa is my solution for day 1