Hi Adam,
I want to play to learn Clojure. It is not so much with a purpose in mind.
Yes, apply works well.
Le mercredi 20 mai 2015 23:14:43 UTC-4, Adam Morgan a écrit :
>
> Hi Pierre,
>
> If I understand you correctly, you are attempting to crack open a
> sequence, as ~@ would do in a macro. You are probably looking for apply.
>
> For example:
>
> (apply + '(1 2 3))
> 6
>
>
> On Wednesday, May 20, 2015 at 6:07:13 PM UTC-6, Pierre Thibault wrote:
>>
>> No:
>>
>> (type '())
>> clojure.lang.PersistentList$EmptyList
>>
>> It a list just like it should be.
>>
>> Le mercredi 20 mai 2015 20:02:22 UTC-4, Colin Yates a écrit :
>>>
>>> That's OK, I am also confused between '() which is a literal list and
>>> #{} which is a literal set :).
>>> On 21 May 2015 00:55, "Pierre Thibault" <[email protected]> wrote:
>>>
>>>> OK,
>>>>
>>>> I don't know how to write macros yet. I was confused.
>>>>
>>>> Thank you.
>>>>
>>>> Le mercredi 20 mai 2015 18:48:03 UTC-4, Colin Yates a écrit :
>>>>>
>>>>> @ (and deref) are used to dereference constructs which support
>>>>> multiple values over time; atoms, futures and promises etc. ~@ is a
>>>>> different thing entirely and is used to desplice lists in a macro.
>>>>>
>>>>> In your example, you aren't in a macro and '() is defining a set, I.e.
>>>>> it isn't a temperal construct.
>>>>> On 20 May 2015 23:43, "Pierre Thibault" <[email protected]> wrote:
>>>>>
>>>>>> For example:
>>>>>>
>>>>>> (def foo '(1 2 3))
>>>>>> (+ @foo)
>>>>>>
>>>>>> Does not work. I am expecting 6.
>>>>>>
>>>>>> Le mercredi 20 mai 2015 18:37:05 UTC-4, Colin Yates a écrit :
>>>>>>>
>>>>>>> @my-atom is the same as (deref my-atom), is that what you mean?
>>>>>>> On 20 May 2015 23:35, "Pierre Thibault" <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Is possible to use the operator '@' alone? In the Joy Of Clojure
>>>>>>>> book it is presented as '~@'. I would like an example.
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Clojure" group.
>>>>>>>> To post to this group, send email to [email protected]
>>>>>>>> Note that posts from new members are moderated - please be patient
>>>>>>>> with your first post.
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>> [email protected]
>>>>>>>> For more options, visit this group at
>>>>>>>> http://groups.google.com/group/clojure?hl=en
>>>>>>>> ---
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Clojure" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to [email protected].
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Clojure" group.
>>>>>> To post to this group, send email to [email protected]
>>>>>> Note that posts from new members are moderated - please be patient
>>>>>> with your first post.
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected]
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/clojure?hl=en
>>>>>> ---
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Clojure" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to [email protected]
>>>> Note that posts from new members are moderated - please be patient with
>>>> your first post.
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/clojure?hl=en
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.