31 lines
752 B
Text
31 lines
752 B
Text
;;; Sort 3 variables
|
|
|
|
to gt? :a :b
|
|
if (and word? :a word? :b) [output before? :b :a]
|
|
if (and number? :a number? :b) [output :a > :b]
|
|
throw "ERROR
|
|
end
|
|
|
|
to swap :v1 :v2 ; swaps the values of the variables whose names are :v1 and :v2
|
|
make "t thing :v1
|
|
make :v1 thing :v2
|
|
make :v2 :t
|
|
end
|
|
|
|
to sort3 :v1 :v2 :v3 ; sorts the variables whose names are :v1, :v2 and :v3
|
|
if gt? thing :v1 thing :v2 [swap :v1 :v2]
|
|
if gt? thing :v1 thing :v3 [swap :v1 :v3]
|
|
if gt? thing :v2 thing :v3 [swap :v2 :v3]
|
|
end
|
|
|
|
make "a "lions,\ tigers,\ and
|
|
make "b "bears,\ oh\ my!
|
|
make "c "\(from\ the\ \"Wizard\ of\ OZ\"\)
|
|
sort3 "a "b "c
|
|
print :a print :b print :c
|
|
|
|
make "a 77444
|
|
make "b -12
|
|
make "c 0
|
|
sort3 "a "b "c
|
|
print :a print :b print :c
|