Skip to content

Commit

Permalink
add string-for-each #269
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jan 21, 2024
1 parent 479295e commit e397846
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
### Bugfix
* fix `let-values` to allow binding to list [#281](https://github.com/jcubic/lips/issues/281)


## 1.0.0-beta.18
### Breaking
* change undocumented arguments to `lips.exec` into an object
Expand Down
5 changes: 3 additions & 2 deletions dist/std.min.scm

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

14 changes: 13 additions & 1 deletion 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.
14 changes: 13 additions & 1 deletion lib/R7RS.scm
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,27 @@

Returns new string from applying function fn to each element
of the strings, similar to map for lists."
(typecheck "string-map" fn "function" 1)
(if (or (= (length rest) 0) (not (every string? rest)))
(error "string-map: function require at least 1 string")
(vector->string (apply vector-map fn (map string->vector rest)))))

;; -----------------------------------------------------------------------------
(define (string-for-each fn . rest)
"(string-for-each fn string1 stringr2 ...)

apply a function fn to each element of the strings, similar string-map.
But the return value is undefined."
(typecheck "string-for-each" fn "function" 1)
(if (or (= (length rest) 0) (not (every string? rest)))
(error "string-for-each: function require at least 1 string")
(apply vector-for-each fn (map string->vector rest))))

;; -----------------------------------------------------------------------------
(define (dynamic-wind before thunk after)
"(dynamic-wind before thunk after)

Accepts 3 procedures/lambdas and executes before, then thunk, and
Accepts 3 procedures/lambdas and executes before, then thunk, and
always after even if an error occurs in thunk."
(before)
(let ((result (try (thunk)
Expand Down

0 comments on commit e397846

Please sign in to comment.