This works:

(match (vector 1 2 3 4)
 [(vector a b (app add1 c) d)
  (list a b c d)])
; => '(1 2 4 4)

Suppose instead I wanted to have a pattern like so (this does not work):

(match (vector 1 2 3 4)
  [(vector a (app + b ..2 x) c) (list a b c x)]
; => '(1 (2 3) 4 5))  ;  NB:  does not work

Is there a way to do this?


Less trivially, I'd like to be able to do something like this:

#lang racket
(struct person (name age) #:prefab)
(struct horse (color owner) #:prefab)

; The following does not work
(match (vector 'brown 'bob 23)
  [(vector the-color (app (curry apply person) args ... the-owner))
   (horse the-color the-owner)])

I've been through the pattern matching docs in some detail and tried
various things, but my brain-fu is weak.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKoeJL-YzSQ_SZ9te9OQ0HgmKiXW19624E8H6fScfFB2zpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to