Changeset 40175 in project


Ignore:
Timestamp:
06/06/21 11:22:59 (8 days ago)
Author:
Idiomdrottning
Message:

I forgot to document the slice operator earlier

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/brev-separate

    r40171 r40175  
    462462
    463463
     464==== slice
     465Here is an generic slice multimethod for Scheme.
     466
     467 (slice '(hello now there you are) 1 3)
     468
     469⇒ (now there)
     470
     471 (slice "so this is where you are hiding" 3 7)
     472
     473⇒ (#\t #\h #\i #\s)
     474
     475 (let ((str "so this is where you are hiding"))
     476   (set! (slice str 3 7) "that")
     477   str)
     478
     479⇒ "so that is where you are hiding"
     480
     481 (slice 1243153 -3 -0)
     482
     483⇒ (1 5 3)
     484
     485Because of Scheme's call-by-value semantics, {{set!}} doesn't work on
     486numbers.♥
     487
     488
    464489=== Doing stuff
    465490
Note: See TracChangeset for help on using the changeset viewer.