Re: is my understanding correct for function identity?

2011-08-15 Thread Mats Rauhala
Another function in the same way is 'const :: a - b - a' (on haskell, but easy to make in clojure if it doesn't exist) which disregards the second argument and always returns the first. This example is in haskell, but let's say that you're creating a histogram, meaning that you go through a list

Re: is my understanding correct for function identity?

2011-08-14 Thread abp
I wanted to add the map/cycle sample, then thougt of clojuredocs and here you go: http://clojuredocs.org/clojure_core/clojure.core/identity On 14 Aug., 00:25, Alan Malloy a...@malloys.org wrote: On Aug 13, 12:45 pm, jaime xiejianm...@gmail.com wrote: I found an interesting function identity

is my understanding correct for function identity?

2011-08-14 Thread Stephen Compall
While the use it as an argument case is important, it can also be useful when writing functions that return functions, when you want to provide a do nothing response. In those cases, just don't forget that identity will throw if given ≠1 arguments. -- You received this message because you

Re: is my understanding correct for function identity?

2011-08-14 Thread jaime
Hey guys, the clojuredocs link seems interesting and a good place for studying/referencing Clojure. :-) On Aug 15, 12:11 am, abp abp...@googlemail.com wrote: I wanted to add the map/cycle sample, then thougt of clojuredocs and here you go:  

Re: is my understanding correct for function identity?

2011-08-14 Thread jaime
It's great to hear so many useful responses/tips -- it's really helpful for people who is leaning Clojure, especially for a beginner like me. Thank you all! -:) On Aug 14, 12:45 am, jaime xiejianm...@gmail.com wrote: I found an interesting function identity which will do nothing but only

is my understanding correct for function identity?

2011-08-13 Thread jaime
I found an interesting function identity which will do nothing but only returns the parameter passed to it. The next minute I came up a question: then what's the purpose of this function? -- I've tried to figure out reasons of existence of identity. The only reason that I can imagine is this:

Re: is my understanding correct for function identity?

2011-08-13 Thread Mark Engelberg
(filter identity l) is a great way of removing all the false and nil items from l -- 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

Re: is my understanding correct for function identity?

2011-08-13 Thread Thorsten Wilms
On 08/13/2011 06:45 PM, jaime wrote: The only reason that I can imagine is this: because we often use higher-order functions, these higher-order functions will accept functions as its parameters, in such a situation, when we want to use a higher-order function but don't want to pass any real

Re: is my understanding correct for function identity?

2011-08-13 Thread Ken Wesson
On Sat, Aug 13, 2011 at 1:57 PM, Thorsten Wilms t...@freenet.de wrote: On 08/13/2011 06:45 PM, jaime wrote: Are there other functions for the same purpose? I don't see how there could be, for the very same purpose. Though you might want to consider splitting up functions some more, instead.

Re: is my understanding correct for function identity?

2011-08-13 Thread Sean Corfield
On Sat, Aug 13, 2011 at 9:45 AM, jaime xiejianm...@gmail.com wrote: The only reason that I can imagine is this: because we often use higher-order functions, these higher-order functions will accept functions as its parameters, in such a situation, when we want to use a higher-order function

Re: is my understanding correct for function identity?

2011-08-13 Thread Alan Malloy
On Aug 13, 12:45 pm, jaime xiejianm...@gmail.com wrote: I found an interesting function identity which will do nothing but only returns the parameter passed to it. The next minute I came up a question: then what's the purpose of this function? -- I've tried to figure out reasons of existence