Adam,
  Good job. You answered the question I asked.  Thank you.

Everyone else,
   Yes, I told you I could usually come up with ways around what I was 
asking for, but there could be problems with what you have suggested.  I 
haven't had time to do more detailed testing, so there might be more use 
cases where what you are suggesting won't work.  

I think where not having something like Lua's unpack function could be 
problematic is in control structures when you have a variable number of 
arguments.  Using the language that I started this discussion with  F is 
the cond function.  The seq A can have a variable number of elements 
depending on user input:  A1 = [true 1 false 2], or A2= [false 1 false 
2 true 3 false 4], where A1 and A2 are two different possible A.

In this case like this I believe destructing is right out.

Further, apply won't work either. Try one of these:  
(apply cond [true 1 false 2])
(apply 'cond [true 1 false 2])

On cond you can get around this by using
(eval (cons 'cond [true 1 false 2]))


But so far I haven't come up with a way of doing this in core.logic's 
conde.  Neither of these work. Of course this could be because my 
understanding of core.logic is not that great.

(run* [x]
    (apply 'conde
         [[(== "tea" x) s#]
          [(== "cup" x) u#]]))

(run* [x]
    (eval (cons 'conde
         [[(== "tea" x) s#]
          [(== "cup" x) u#]])))






On Tuesday, November 6, 2012 11:36:31 AM UTC-5, the80srobot wrote:
>
> If I understand this right, you're looking for something like Lua's unpack 
> function. AFAIK you will not be able to do this in Clojure using functions, 
> because Clojure functions can only return one argument. The only way to 
> achieve this behavior would by by transforming your calls using reader 
> macros and then eval. I do not recommend doing this.
>
> I understand that something like unpack is a more general case of apply, 
> but I can't think of any scenario where apply isn't enough - out of 
> interest, what are you trying to do?
>
> -Adam
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to