[REBOL] Another bit of layout trivia
From: joel::neely::fedex::com at: 4-Jan-2002 20:29
One of my stated reasons for trying alternatives to Style B was the
desire to break out of non-REBOL constraints (or implications) of
source code layout. Here's an example of something one can say in
REBOL that makes no sense in any Algol-like language AFAIK.
ordck: func [a [integer!] b [integer!] c [integer!]]
[ either a <= b
either b <= c [["in order" ]][["scrambled"]]
either b <= c [["scrambled"]][["reversed" ]]
]
as in
use [x y z]
[ loop 10
[ x: random 9 y: random 9 z: random 9
print [x y z ordck x y z]
] ]
1 7 8 in order
8 3 7 scrambled
3 1 6 scrambled
9 1 5 scrambled
3 9 2 scrambled
7 4 6 scrambled
4 3 6 scrambled
2 6 6 in order
8 7 8 scrambled
9 2 1 reversed
To my thinking it's fascinating that one can "distribute" [ ]
across EITHER as if it were an operator...
-jn-
--
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;