Skip to content

Commit

Permalink
!275 Improve rich-vector%make-string in (liii lang)
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii committed Mar 3, 2025
1 parent 8bc35fb commit 1344e70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
14 changes: 6 additions & 8 deletions GoldfishLang.tmu
Original file line number Diff line number Diff line change
Expand Up @@ -2576,13 +2576,13 @@
<\goldfish-chunk|goldfish/liii/lang.scm|true|true>
(chained-define (%map f)

\ \ (rich-string
\ \ ((%to-vector)

\ \ \ \ (%to-vector :map f
\ \ \ :map f

\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :map (lambda (c) (rich-string :value-of c))
\ \ \ :map (@ _ :make-string)

\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ :make-string)))
\ \ \ :make-string))

\;
</goldfish-chunk>
Expand Down Expand Up @@ -2635,12 +2635,10 @@
\;
</goldfish-chunk>

\;

<paragraph|rich-string%to-vector>

<\goldfish-chunk|goldfish/liii/lang.scm|true|true>
(chained-define (%to-vector)
(define (%to-vector)

\ \ (if (string-null? data)

Expand Down Expand Up @@ -5340,7 +5338,7 @@

\ \ \ \ \ \ \ \ \ \ \ (middle (string-join (map as-string (vector-\<gtr\>list data)) sep)))

\ \ \ \ \ \ (string-append start middle end))))
\ \ \ \ \ \ (rich-string (string-append start middle end)))))

\;
</scm-chunk>
Expand Down
12 changes: 6 additions & 6 deletions goldfish/liii/lang.scm
Original file line number Diff line number Diff line change
Expand Up @@ -474,18 +474,18 @@
(else (loop (cdr lst) (+ index 1)))))))))

(chained-define (%map f)
(rich-string
(%to-vector :map f
:map (lambda (c) (rich-string :value-of c))
:make-string)))
((%to-vector)
:map f
:map (@ _ :make-string)
:make-string))

(define (%count pred?)
((%to-vector) :count pred?))

(define (%to-string)
data)

(chained-define (%to-vector)
(define (%to-vector)
(if (string-null? data)
(rich-vector :empty)
(let* ((bv (string->utf8 data))
Expand Down Expand Up @@ -1092,7 +1092,7 @@
(receive (start sep end) (parse-args xs)
(let* ((as-string (lambda (x) (if (string? x) x (object->string x))))
(middle (string-join (map as-string (vector->list data)) sep)))
(string-append start middle end))))
(rich-string (string-append start middle end)))))

(define (%set! i x)
(when (or (< i 0) (>= i (length data)))
Expand Down

0 comments on commit 1344e70

Please sign in to comment.