I hope to post the majority of the code soon, after I run a few more tests. For now, here's how I add two lists of numbers in Erlang. Please let me know if there's a better way.
Update:
The best way to do this is (thanks to Daniel Larsson):
lists:zipwith(fun(X,Y) -> X+Y end, [1,2],[3,4])
Old 'n busted way:
add_measures(OldMeasures, NewMeasures) ->
add_measures(OldMeasures, NewMeasures, []).
add_measures([Old|OldRest], [New|NewRest], Accum) ->
add_measures(OldRest, NewRest, [Old+New|Accum]);
add_measures([], [], Accum) -> lists:reverse(Accum).
0 comments:
Post a Comment