💾 Archived View for idiomdrottning.org › slice captured on 2022-07-16 at 14:06:40. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
➡️ Next capture (2024-02-05)
-=-=-=-=-=-=-
Here is an generic slice multimethod for Scheme.
(slice '(hello now there you are) 1 3)
⇒ (now there)
(slice "so this is where you are hiding" 3 7)
⇒ (#\t #\h #\i #\s)
(let ((str "so this is where you are hiding")) (set! (slice str 3 7) "that") str)
⇒ “so that is where you are hiding”
(slice 1243153 -3 -0)
⇒ (1 5 3)
Because of Scheme’s call-by-value semantics, set! doesn’t work on numbers♥
This is just a functional wrapper on call-list, call-vector and call-string from earlier today.