[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

expanding lists



(apply make-x vals)

Chris Uzdavinis wrote:

> 
> Suppose I have a struct:
> 
>   (define-struct x (a b c))
> 
> and I have a list:
> 
>   (define vals '(1 2 3))
> 
> Is there a way to construct the structure directly from the list?  The
> constructor is expecting arguments, and I have a list of 3 elements.
> I'd like to be able to do something like this:
> 
>   (make-x vals))
> 
> or somethign like that.  Otherwise to construct my struct I have to do
> something that feels wrong/unnecessary:
> 
>   (make-x (car vals) (cadr vals) (caddr vals))
> 
> Is there a way to do this in one step?  Essentially, an "unlist"
> capability. 
> 
> The real problem is that I'm using a regular expression to extract
> multiple values from a string, and then create a struct from those
> values.  But the regexp-match returns a list, and the struct wants
> initializers for each member as seperate values.
> 
> Am I just missing something obvious?  (Thanks in advance.)
> 
> -- 
> Chris
> 
>