Re: [elixir-core:6602] Proposal: Enum.reject for Enum.compact

2016-11-17 Thread OvermindDL1
Yeah you could do `&(&1)` or so for an inline identity, though definitely not as clear. :-) Constant is not as succinct though: `&(fn->&1 end)` And still not clear. ^.^ On Thursday, November 17, 2016 at 12:14:39 PM UTC-7, Drew Olson wrote: > > Ignore my comment about not being about to use t

Re: [elixir-core:6600] Proposal: Enum.reject for Enum.compact

2016-11-17 Thread Drew Olson
While we're wishing for things, I've also wanted constant/1 a few times: constant(3).() # => 3 Especially for things like creation of Agents. On Thu, Nov 17, 2016 at 1:08 PM, Drew Olson wrote: > I've also often wished for an identity/1 in Kernel, especially because you > cannot easily represen

Re: [elixir-core:6599] Proposal: Enum.reject for Enum.compact

2016-11-17 Thread Drew Olson
I've also often wished for an identity/1 in Kernel, especially because you cannot easily represent it with the short function syntax. On Thu, Nov 17, 2016 at 12:33 PM, OvermindDL1 wrote: > `identity : 'a -> 'a` is the most common function declaration like that in > almost every functional langua

Re: [elixir-core:6601] Proposal: Enum.reject for Enum.compact

2016-11-17 Thread Drew Olson
Ignore my comment about not being about to use the shorter function syntax. I was confused about the precedence of &. On Thu, Nov 17, 2016 at 1:08 PM, Drew Olson wrote: > I've also often wished for an identity/1 in Kernel, especially because you > cannot easily represent it with the short functi

Re: [elixir-core:6599] Proposal: Enum.reject for Enum.compact

2016-11-17 Thread OvermindDL1
`identity : 'a -> 'a` is the most common function declaration like that in almost every functional language, would be nice to have in kernel. On Thursday, November 17, 2016 at 10:48:20 AM UTC-7, Louis Pop wrote: > > Hiya > > I'd like an identity function in Kernel, that's for sure. > > I think a

Re: [elixir-core:6597] Proposal: Enum.reject for Enum.compact

2016-11-17 Thread Louis Pop
Hiya I'd like an identity function in Kernel, that's for sure. I think an identity function being the default argument to filter would be quite nice. I find reject a bit strange, I don't set why it exists when we have filter. Cheers, Louis On Thu, 17 Nov 2016, 17:40 Tallak Tveide, wrote: > I

[elixir-core:6597] Proposal: Enum.reject for Enum.compact

2016-11-17 Thread Tallak Tveide
I assume you mean the default function should be ''' fn x -> !x end ''' To reject any falsey value. It does seem reasonable, but I dont think it is nearly as readable as 'compact', so I vote nay to this one... In fact, isn't this a better option? (Or equally good) ''' def filter(enum, fun \\ f

[elixir-core:6595] Proposal: Enum.reject for Enum.compact

2016-11-17 Thread Bruce Tate
Every couple of months, we get a request for Enum.compact. So far, the main argument against it is that Enum.reject list, &is_nil/1 is sufficient. When you compare the difference in a pipe, you can see a significant difference in readability. It really is a pervasive use case. list |> nil_or_res