Add range function and euler1 example
This commit is contained in:
parent
d07c480390
commit
9c0db610bf
2 changed files with 10 additions and 0 deletions
6
examples/euler1.lisp
Normal file
6
examples/euler1.lisp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
;; (defun range (start end)
|
||||||
|
;; (if (< start end)
|
||||||
|
;; (cons start (range (+ 1 start) end))
|
||||||
|
;; (list)))
|
||||||
|
|
||||||
|
(write-line (reduce + (filter (lambda (x) (or (zerop (mod x 3)) (zerop (mod x 5)))) (range 1 1000))))
|
|
@ -278,6 +278,10 @@ my %stdctx = (
|
||||||
|
|
||||||
return $number;
|
return $number;
|
||||||
},
|
},
|
||||||
|
'range' => sub {
|
||||||
|
my ($start, $end) = @_;
|
||||||
|
return [ $start .. ($end-1) ];
|
||||||
|
},
|
||||||
|
|
||||||
# String comparison
|
# String comparison
|
||||||
'string=' => sub { my ($a, $b) = @_; return to_lisp_bool($a eq $b); },
|
'string=' => sub { my ($a, $b) = @_; return to_lisp_bool($a eq $b); },
|
||||||
|
|
Loading…
Reference in a new issue