[racket] List functions instead of string functions?

From: Danny Yoo (dyoo at hashcollision.org)
Date: Fri May 3 14:10:39 EDT 2013

Strings and lists are both sequences, so you can write functions that
work on sequences.  For example:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket

(define (peel seq)
  (define n (sequence-length seq))
  (define seq-without-head
    (sequence-tail seq 1))
  (define seq-without-ends
    (for/list ([s seq-without-head]
               [_ (- n 2)])
      s))

  seq-without-ends)

;; Examples:
(peel "hello world this is a test")
(peel '(hello world this is another test))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Can you give more details on what you're trying to do?

Posted on the users mailing list.