fork download
  1. (eval-when (:compile-toplevel :load-toplevel :execute)
  2. (defun my-yoba-syntax-reader (stream char arg)
  3. (declare (ignore char arg))
  4. (flet ((skip-whitespaces ()
  5. (loop :for c := (read-char stream)
  6. :unless (member c '(#\Space #\Tab))
  7. :return (prog1 c (unless (member c '(#\) #\NewLine))
  8. (unread-char c stream)))))
  9. (expr (revline &aux (expr (nreverse revline)))
  10. (if (integerp (car expr))
  11. `(,(car expr) ,(cdr expr))
  12. `(,expr))))
  13. (loop :with body :and line :for c := (skip-whitespaces) :do
  14. (case c
  15. (#\NewLine
  16. (psetf line nil body (nconc body (expr line))))
  17. (#\)
  18. (return `(block nil (tagbody ,@body ,@(expr line)))))
  19. (t (push (read-preserving-whitespace stream t nil t) line))))))
  20.  
  21. (make-dispatch-macro-character #\$)
  22. (set-dispatch-macro-character #\$ #\( 'my-yoba-syntax-reader))
  23.  
  24. (defun factorial (n &aux r)
  25. $(00 SETQ R 1
  26. 10 IF (< N 1) (GO 50)
  27. 20 SETQ R (* R N)
  28. 30 SETQ N (1- N)
  29. 40 GO 10
  30. 50 RETURN R))
  31.  
  32. (dotimes (n 25)
  33. (format t "~&~d! = ~d" n (factorial n)))
Success #stdin #stdout 0.01s 25568KB
stdin
Standard input is empty
stdout
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
11! = 39916800
12! = 479001600
13! = 6227020800
14! = 87178291200
15! = 1307674368000
16! = 20922789888000
17! = 355687428096000
18! = 6402373705728000
19! = 121645100408832000
20! = 2432902008176640000
21! = 51090942171709440000
22! = 1124000727777607680000
23! = 25852016738884976640000
24! = 620448401733239439360000