[erlang-questions] conses in erlang?

not norwegian swede <>
Wed Jul 2 10:33:00 CEST 2008


can i use conses in erlang?
like in scheme, then i only need one function. is the range func in erlang ood erlang-style or is there a better way to do it?

(define (seq a b)
    (if (< a b)
        (cons a (seq (+ a 1) b))
        '()))

-module(test).
-export([range/2]).
      
range(Start, End) when Start < End, is_integer(Start), is_integer(End) -> 
    seq(Start, End, []).

seq(Start, End, List) ->
    if Start =< End ->
        seq(Start + 1, End, List ++ [Start]);
    true ->
    List
end.



      ___________________________________________________
Sök efter kärleken!
Hitta din tvillingsjäl på Yahoo! Dejting: http://ad.doubleclick.net/clk;185753627;24584539;x?http://se.meetic.yahoo.net/index.php?mtcmk=148783
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080702/66fef7a6/attachment.html>


More information about the erlang-questions mailing list