#Why list.range e int.range is so different ?

1 messages · Page 1 of 1 (latest)

azure ivy
#

I just wanted to generate a list in a range, I didn't understand why the additional ones are what they are for? Why not list.range since it's so simple? Just a question, it hasn't bothered me at all I just think it's a little verbose

azure ivy
#

Looking at the implementation what I understood is that receiving an accumulator, it becomes agnostic to what kind of "list" it generates as long as it receives a function that aggregates to this accumulator, thinking better this is a very cool idea on how to generate a list, very cool!

limber parrot
#

Yeah it got replaced because list.range wasn't all that useful and usually folks piped it immediately into list.map or list.fold

#

it's the same as list.range(from, to) |> list.fold(acc, reducer) but skips the intermediate list

azure ivy
#

oooh

limber parrot
#

so in practice it's usually simpler to use that new function and it's faster!

azure ivy
#

i understands now

limber parrot
#

(just not in the case where you.. actually need a list of integers) 😄

azure ivy
#

This implementation isn't that complicated to use; if you need more instructions, I think it would become rather tedious to write. For simple situations, but in my case, I'm basically studying sets and practicing a bit, so this implementation will be very useful when I need to express more complex constraint notations.

dense olive
#

We changed it because we did research on how it was used and found it was never actually used to create a list of ints. It was always used to do some looping, which it wasn’t a good design for