Skip to content

Commit

Permalink
Make take align with SRFI-1
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Mar 24, 2024
1 parent cf456e2 commit 1fcb441
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* replace `undefined` with `#void`, and `null` with `#null`
* characters are again unboxed into strings by JavaScript code [#329](https://github.com/jcubic/lips/issues/329)
* code that throw exception now return exit code 1
* change order of arguments in `take`
### Features
* add `vector-for-each` and `vector-copy!` function from R7RS
* add `string-for-each`, `string-downcase`, and `string-upcase` from R7RS
Expand Down
4 changes: 2 additions & 2 deletions dist/std.min.scm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions dist/std.scm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/std.xcb
Binary file not shown.
10 changes: 5 additions & 5 deletions lib/bootstrap.scm
Original file line number Diff line number Diff line change
Expand Up @@ -849,17 +849,17 @@

Returns a new function that limits the number of arguments to n."
(lambda args
(apply fn (take n args))))
(apply fn (take args n))))

;; -----------------------------------------------------------------------------
(define (take n lst)
"(take n list)
(define (take lst n)
"(take list n)

Returns n first values of the list."
(let iter ((result '()) (i n) (lst lst))
(let loop ((result '()) (i n) (lst lst))
(if (or (null? lst) (<= i 0))
(reverse result)
(iter (cons (car lst) result) (- i 1) (cdr lst)))))
(loop (cons (car lst) result) (- i 1) (cdr lst)))))

;; -----------------------------------------------------------------------------
(define (zip . lists)
Expand Down

0 comments on commit 1fcb441

Please sign in to comment.