Re: [racket] unwrapping a list

2012-06-11 Thread Jordan Johnson
ut 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

Re: [racket] unwrapping a list

2012-06-11 Thread Ben Goetter
(define-values (year month day) (apply values (regexp-split #rx"/" "2012/06/06"))) On 6/11/2012 12:24 PM, Jordan Schatz wrote: 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. Racket Users list: htt

Re: [racket] unwrapping a list

2012-06-11 Thread Neil Van Dyke
(apply (lambda (year month day) (printf "Year: ~S Month: ~S Day: ~S\n" year month day)) (regexp-split #rx"/" "2012/06/06")) Neil V. Racket Users list: http://lists.racket-lang.org/users

Re: [racket] unwrapping a list

2012-06-11 Thread Eli Barzilay
A few minutes ago, Jordan Schatz wrote: > > 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 ret

Re: [racket] unwrapping a list

2012-06-11 Thread Erik Silkensen
You could use match or match-let, e.g., (match-let ([(list year month day) (regexp-split #rx"/" "2012/06/06")]) …) http://docs.racket-lang.org/reference/match.html On Jun 11, 2012, at 8:24 PM, Jordan Schatz wrote: > > Is there a way to unwrap or explode a list? I don't see it in the docs, bu