Solutions of some puzzles in Scheme (Lisp), my first experience with it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
650 B

#!/usr/bin/guile -s
!#
#!(display "Hello, world!\n")!#
(use-modules (ice-9 rdelim))
#!(let ((x (read)))
(display (* x x))
(newline))
!#
(define (read-myline)
(read-line))
(define (read-lines)
(let loop ((line (read-line)))
(if
(eof-object? line)
'()
(cons line (loop (read-line))))))
(define (sum lines)
(if
(null? lines)
0
(+ (string-length (car lines)) (sum (cdr lines)))
))
(display (sum (read-lines)))
#!(let loop ((line (read)))
(format #t "line: ~a\n" line)
(display (* line line))
(if (not (eof-object? line))
(begin
(format #t "read next line\n")
(loop (read)))))!#