aboutsummaryrefslogtreecommitdiff
path: root/test2.lang
blob: a7892945f1541db81235443cacd2881dfe0c4bca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(import java.lang.System)
(require "./another" as another)

(defclass Tagged [[java.lang.String tag] [java.lang.Object value]])

(definterface Function
  (: apply (-> [java.lang.Object] java.lang.Object)))

(defclass Tuple0 [])
(defclass Tuple1 [[java.lang.Object _0]])
(defclass Tuple2 [[java.lang.Object _0] [java.lang.Object _1]])

(def const "IDENTITY")

(def variant (#Tag "value"))

(def (constant x y)
  x)

(def (constant2 x)
  (lambda [y] x))

(def (main args)
  (if true
    (let f (lambda [x] (lambda [y] (x y)))
         (let g (lambda [x] const)
              (:: (:: System out) (println (f g "WE'VE GOT CLOSURES!")))))
    (:: (:: System out) (println "FALSE"))))

## All of these work :D
#( (let output "IT WORKS!"
        (_. (_.. System out) (println ((lambda [x y] output) "TRUE" "YOLO")))) )#
#( (let output "IT WORKS!"
        (let f (lambda [x] (lambda [y] output))
             (_. (_.. System out) (println (f "TRUE" "YOLO"))))) )#
#( (let output "IT WORKS!"
        (_. (_.. System out) (println ((lambda [x] (lambda [y] output)) "TRUE" "YOLO")))) )#
#( (let output ((lambda [x y] x) "TRUE" "YOLO")
        (_. (_.. System out) (println output))) )#
#( (let f (lambda [x y] x)
        (_. (_.. System out) (println (f "TRUE" "YOLO")))) )#
## ((lambda [x y] (_. (_.. System out) (println x))) "TRUE" "YOLO")
## (_. (_.. System out) (println ((lambda [x y] x) "TRUE" "YOLO")))
#( (do (_. (_.. System out) (println true))
     (_. (_.. System out) (println (another/id 12345)))
     (_. (_.. System out) (println (constant "ONE" "TWO")))
     (_. (_.. System out) (println 2.3))
     (_. (_.. System out) (println #"Y"))
     (_. (_.. System out) (println "this\tis a\nstring"))
     (case (#Box "data")
       (#Box value)
       (_. (_.. System out) (println value)))) )#