Skip to content

Instantly share code, notes, and snippets.

@andruby andruby/my_lib.erl
Created Nov 23, 2009

What would you like to do?
[Erlang] lists:seq for floats
%% This lets you do stuff like
1> my_lib:seq_float(10.01,10.13,0.02).
-module (my_lib).
-export ([seq_float/3]).
seq_float(Min, Max, Inc, Counter, Acc) when (Counter*Inc + Min) >= Max ->
seq_float(Min, Max, Inc, Counter, Acc) ->
seq_float(Min, Max, Inc, Counter+1, [Inc * Counter + Min|Acc]).
seq_float(Min, Max, Inc) ->
seq_float(Min, Max, Inc, 0, []).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.