Becoming Patient in Writing Programs
symbo1ics.com
symbo1ics.com
What got me interested was how another language which used consistent data structure for its syntax would look here in comparison.
So here is my stab at it using Rebol...
; Array Access
pick x i
x/:i ; PATH! alternative
; Function call
f x
; Arithmetic
(a / 2) + (b * c) + square-root d
; Conditional Branching (part 1)
either a = b [x] [y]
Rebol doesn't have else if so this looks a little clumsy: ; Conditional Branching (part 2)
either a == b [
doThis a
x
][
either c == d [
doThat b
y
][z]
]
And it doesn't have a cond either. However its easy to add one :) cond: func [cond-list] [
foreach line cond-list [
c: compose line
if true? c/1 [break/return do c/2]
]
]
cond [
[(a = b) [doThis a x]]
[(c = d) [doThat b y]]
[true [z]]
]