An Erlang implementation of lists:seq for floats

If you want to use lists:seq/3 with floats you will notice that the standard implementation only works with integers. So I wrote a quick & dirty way to do it with floats.

You can use it just like you would use lists:seq/3

If anybody has a better implementation I would love to see it.

3 Responses to “An Erlang implementation of lists:seq for floats”


  1. 1 jean

    Dede, Stick to understandable posts dude :) I like the TED and ‘philosophic’ threads but this is a little too G33Ky my friend.

    Btw how’s the ‘I-want-to-learn-something-new-every-day’ project running?

    Cheers and Merry X-Mas

  2. 2 Andreas

    Hi
    im new to erlang (3 Days) so please don“t be harsh on me ;)
    I also need a list of float values.
    Your solution do not work with negative minimum values.

    lists:map(fun(X)->X/10 end,lists:seq(-1*10,1*10))

    [-1.0,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0.0,0.1,
    0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]

    Would work.

  3. 3 andrew

    Well Andreas, you are right. My implementation won’t work with negative values because it uses logarithmic. You can use your implementation, or use mine with positive values and subtract with map fun(X) -> X-10.

Leave a Reply