tests2.l 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. (def s "abcdefghijklmnopqrstuvwxyz0123456789ABCD")
  2. (def i 0)
  3. (while (lt i 40) (do (print (cons (get s (+ i 1)) (get s i))) (def i (+ i 1))))
  4. (def i 0)
  5. (def j 0)
  6. (def s "........................................")
  7. (def loopit (fn
  8. (while 1 (do
  9. (def i 0)
  10. (def j 0)
  11. (while (lt j 40) (do
  12. (def s "........................................")
  13. (def i 0)
  14. (while (lt i 40) (do (put s i (get "*" 0)) (put s (- i j) (get "." 0)) (def i (+ i 1)) (print s)))
  15. (def j (+ j 1))
  16. ))
  17. (gc)
  18. ))))
  19. (def test (fn a b (print (+ a (+ a b)))))
  20. (def test (fn x y color (print (+ (* y 1920) x))))
  21. # todo: put32 put64
  22. # todo: sane for/range/generator
  23. (def fbfile (open "/framebuffer"))
  24. (def pixel (fn x y color (put32 fb (* 4 (+ x (* y 1920))) color)))
  25. (def y 50)
  26. (def x 50)
  27. (def c 0)
  28. (def paint (fn (do
  29. (def y 50)
  30. (def x 50)
  31. (while (lt y 640) (do
  32. (def x 0)
  33. (while (lt x 480) (do
  34. (pixel x y (+ c (* x y)))
  35. (def x (+ x 1))
  36. ))
  37. (def y (+ y 1))
  38. ))
  39. (def c (+ c 0x020202))
  40. (send fbfile 0)
  41. (gc)
  42. )))
  43. (while 1 (paint))
  44. (def fbfile (open "/framebuffer"))
  45. (def pixel (fn x y color (do (put fb (* 4 (+ x (* y 1920))) color) (send fbfile 0))))
  46. (def con (open "/console"))
  47. (def buf (alloc-str 128))
  48. (def c 32)
  49. (def i 0)
  50. (def readline (fn (do
  51. (def buf (alloc-str 128))
  52. (def c 32)
  53. (def i 0)
  54. (while (gt c 10) (do (def c (recv con)) (put buf i c) (def i (+ i 1))))
  55. buf
  56. )))
  57. (def f1 (fn a b (* a b)))
  58. (def f2 (fn a b c d (+ (f1 b a) (f1 d c))))
  59. (f2 4 3 2 1)
  60. (let a 3)