Wouldn’t it be better to use `Stream.iterate/2` than try to embed this into a data structure?
`Stream.iterate(13, & &1 + 13) |> Enum.take(24)` It would take a little more effort to support front-unbounded, but that would be something more like: `Stream.iterate(-∞, & &1 + 13) |> Enum.take_while(& &1 <= 31331) |> Enum.take(256)` That would be `..31331`, I think. Assuming that `∞` is usefully defined as infinity that can be negated (it isn’t right now). More generally, ranges in Elixir are _extremely_ limited as they are abstractions of integer sequences and not continuous ranges as they might be in other languages (e.g., Ruby), so it’s not possible to ask whether a range covers a value. (I still haven’t figured out what I’d use an endless range for in Ruby, but that’s just me.) -a On Tue, Apr 6, 2021 at 7:48 PM Kevin Johnson <[email protected]> wrote: > > > Has there been any discussion about unbounded ranges? For instance in Haskell: > `take 24 [13,26..]` > > In our case the equivalent would be: > `13..//13 |> Enum.take(24)` > > or perhaps for the sake of being more explicit: > `13..∞//13` > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAAkfbUpJcM%2B-FEirXrj1bX4CYD7ciMe80vYh64p_09UQ7-1D0A%40mail.gmail.com. -- Austin Ziegler • [email protected] • [email protected] http://www.halostatue.ca/ • http://twitter.com/halostatue -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQtYagZ%3DiYqkW6f-n-5R0s7F1hPb3U3f_OFYd%3DYzwtqaZQ%40mail.gmail.com.
