Idiomdrottning’s homepage

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")

⇒ “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.