[racket] unwrapping a list

From: Jordan Schatz (jordan at noionlabs.com)
Date: Mon Jun 11 15:24:40 EDT 2012

Is there a way to unwrap or explode a list? I don't see it in the docs, but it
seems like it would be a common thing.

This is what I want to do:

(define-values (year month day)
  (regexp-split #rx"/" "2012/06/06"))

But regexp-split returns a list, not values, so I'd like to "unwrap" the list
and just have the values...

I can do it manually:
(define tmp (regexp-split #rx"/" "2012/06/06"))
(define year (first tmp))
(define month (second tmp))
(define day (third tmp))

But thats ugly.

Being able to 
(let ([year month day (regexp-split #rx"/" "2012/06/06")])
  )
Would be handy too...

- Jordan


Posted on the users mailing list.