Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
36
Task/Extend-your-language/Red/extend-your-language.red
Normal file
36
Task/Extend-your-language/Red/extend-your-language.red
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
Red [ "Extend your language - Hinjolicious"]
|
||||
|
||||
; This function will print a string as a heading and print any codes
|
||||
; to the screen before executing it.
|
||||
demo: function [s b] [print ["^/==" s "==^/"] print [mold/only b "^/^/Output:"] do b]
|
||||
|
||||
demo "Creating a custom control structure if-both" [
|
||||
if-both: function [cond1 cond2 both-body first-body second-body none-body] [
|
||||
c1: do cond1
|
||||
c2: do cond2
|
||||
case [
|
||||
all [c1 c2] [do both-body]
|
||||
c1 [do first-body]
|
||||
c2 [do second-body]
|
||||
true [do none-body]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
demo "Testing it" [
|
||||
random/seed now
|
||||
|
||||
test: does [
|
||||
if-both [(random 100) > 50] [(random 100) < 50] [
|
||||
print "both"
|
||||
][
|
||||
print "first"
|
||||
][
|
||||
print "second"
|
||||
][
|
||||
print "none"
|
||||
]
|
||||
]
|
||||
|
||||
loop 10 [test]
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue