💾 Archived View for idiomdrottning.org › slice captured on 2022-01-08 at 13:40:34. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

➡️ Next capture (2024-02-05)

-=-=-=-=-=-=-

Can you slice it, Artoo?

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.

call-vector and call-string