Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Racket

Name: Anonymous 2011-01-28 7:43

Why Racket doesn't have a uniform collection interface? It's fucking stupid to have string-ref, vector-ref, list-ref etc in the language.

Name: Doctor Racket !RACKET/.HY 2011-01-28 8:03

>>3

(define (sequence-ref seq n)
  (let-values (((next? next) (sequence-generate seq)))
    (let loop ((r '()))
      (if (next?) (loop (next)) r))))
(sequence-ref '(1 2 3) 2) ; 3
(sequence-ref #(1 2 3) 2) ; 3
(sequence-ref "123" 2)    ; #\3
(sequence-ref #"123" 2)   ; 51 (#\3)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List