2024-09-28 02:57:56 +00:00
|
|
|
fun x (a b :: r) {
|
2022-05-05 04:03:56 +00:00
|
|
|
|
|
|
|
| x y |
|
|
|
|
|
2024-04-20 17:24:27 +00:00
|
|
|
set x a
|
|
|
|
set y b
|
2022-05-05 04:03:56 +00:00
|
|
|
|
2024-04-20 17:24:27 +00:00
|
|
|
if (> a b) {
|
|
|
|
| a b |
|
|
|
|
set a (mod x y)
|
|
|
|
set b (+ x y)
|
|
|
|
set r (* a b)
|
|
|
|
} else {
|
|
|
|
| a b |
|
|
|
|
set a (* x y)
|
|
|
|
set b (- x y)
|
|
|
|
set r (* a b)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-09-03 03:18:08 +00:00
|
|
|
if (~= x a) (printf "ERROR: x is not equal to a\n")
|
|
|
|
if (~= y b) (printf "ERROR: y is not equal to b\n")
|
2024-04-20 17:24:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
t := (x 10 20)
|
2024-09-03 03:18:08 +00:00
|
|
|
if (~= t -2000) (printf "ERROR: t is not equal to -2000\n") \
|
2024-04-20 17:24:27 +00:00
|
|
|
else (printf "OK: %d\n" t)
|
|
|
|
set t (x 30 20)
|
2024-09-03 03:18:08 +00:00
|
|
|
if (~= t 500) (printf "ERROR: t is not equal to 500\n") \
|
2024-04-20 17:24:27 +00:00
|
|
|
else (printf "OK: %d\n" t)
|
|
|
|
|
|
|
|
|
2024-09-28 02:57:56 +00:00
|
|
|
fun x () {
|
2024-04-20 17:24:27 +00:00
|
|
|
|
|
|
|
| x y |
|
2022-05-05 13:04:04 +00:00
|
|
|
|
2024-04-20 17:24:27 +00:00
|
|
|
set x 99
|
|
|
|
try {
|
|
|
|
| x |
|
|
|
|
set x 88
|
2024-09-03 03:18:08 +00:00
|
|
|
if (~= x 88) (printf "ERROR: x is not 88\n") \
|
2024-04-20 17:24:27 +00:00
|
|
|
else (printf "OK: %d\n" x)
|
|
|
|
throw 1000
|
|
|
|
} catch (x) {
|
2024-09-03 03:18:08 +00:00
|
|
|
if (~= x 1000) (printf "ERROR: x is not 1000\n") \
|
2024-04-20 17:24:27 +00:00
|
|
|
else (printf "OK: %d\n" x)
|
|
|
|
set y x
|
|
|
|
}
|
|
|
|
|
2024-09-03 03:18:08 +00:00
|
|
|
if (~= x 99) (printf "ERROR: x is not 99\n") \
|
2024-04-20 17:24:27 +00:00
|
|
|
else (printf "OK: %d\n" x)
|
2024-09-03 03:18:08 +00:00
|
|
|
if (~= y 1000) (print "ERROR: y is not 1000\n") \
|
2024-04-20 17:24:27 +00:00
|
|
|
else (printf "OK: %d\n" y)
|
|
|
|
}
|
|
|
|
|
|
|
|
x
|
|
|
|
|
|
|
|
|
2024-07-09 14:44:24 +00:00
|
|
|
class T [ j ] {
|
2024-04-20 17:24:27 +00:00
|
|
|
|
2024-10-01 15:33:34 +00:00
|
|
|
fun(#classinst) new() {
|
2024-04-20 17:24:27 +00:00
|
|
|
set j 99
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2024-09-28 02:57:56 +00:00
|
|
|
fun x() {
|
2024-04-20 17:24:27 +00:00
|
|
|
set R {
|
|
|
|
| x |
|
|
|
|
set x 1
|
|
|
|
while (< x j) {
|
2024-09-28 02:57:56 +00:00
|
|
|
fun Q() x
|
2024-04-20 17:24:27 +00:00
|
|
|
set x (+ x 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set t (T:new)
|
|
|
|
t:x
|
|
|
|
set t (Q)
|
2024-09-03 03:18:08 +00:00
|
|
|
if (~= t 99) (print "ERROR: t is not 99\n") \
|
2024-04-20 17:24:27 +00:00
|
|
|
else (printf "OK: %d\n" t)
|
|
|
|
|
|
|
|
if (nqv? R false) (print "ERROR: R is not false\n") \
|
|
|
|
else (printf "OK: %O\n" R)
|
|
|
|
|
|
|
|
set v #(
|
|
|
|
(do |a b| (set a 10) (set b 20) (+ a b) )
|
|
|
|
(do |a b| (set a 11) (set b 21) (+ a b) )
|
|
|
|
999
|
2022-07-30 16:07:39 +00:00
|
|
|
)
|
|
|
|
|
2024-04-20 17:24:27 +00:00
|
|
|
set v2 #(30 32 999)
|
2022-07-30 16:07:39 +00:00
|
|
|
|
2024-04-20 17:24:27 +00:00
|
|
|
if (nql? v v2) (print "ERROR: v1 and v2 are not equal\n")\
|
|
|
|
else (printf "OK: v and v2 equal\n")
|
2022-07-30 16:07:39 +00:00
|
|
|
|