Contact me

March 11th, 2009

Please send your comments, suggestions and Erlang code examples that you think it’s must-have to trung dot n dot k at gmail dot com

  1. Onty
    March 21st, 2012 at 15:06 | #1

    hi, can u add more examples about spawn? i want to measure performance of the erlang mnesia db, to do that i wanna measure time taken as number of processes increase… so any idea how?

    thanks

  2. Trung
    March 21st, 2012 at 17:36 | #2

    Hi Onty,

    If you have a book Programming Erlang from Joe Amstrong, in chapter 8, section 8.4 mentions about the performance of spawning a process. You can refer to it for more details.

    In a nut shell, you can use erlang:system_info(process_limit) to find out the max number of process you can create. If I have time, I will create a post about this.

    Thanks,

    Trung

  3. Xinli Niu
    June 25th, 2013 at 23:53 | #3

    Hi, I saw your examples of quicksort in http://erlangexamples.com/tag/quicksort/.I doubt whether the following implementation tail recursion.
    Since
    SortedSmallers = qsort(Smallers),
    SortedGreaters = qsort(Greaters),
    SortedSmallers ++ [Pivot] ++ SortedGreaters.
    is nothing different from
    qsort(Smallers) ++ [Pivot] ++ qsort(Greates)

    %% Quick Sort
    %% Think thru, you’ll see it very easy to understand :p
    qsort([]) -> [];
    qsort([Single]) -> [Single];
    qsort([Pivot|Rest]) ->
    {Smallers, Greaters} = qsort(Pivot, Rest),
    SortedSmallers = qsort(Smallers),
    SortedGreaters = qsort(Greaters),
    SortedSmallers ++ [Pivot] ++ SortedGreaters.

    qsort(Pivot, List) -> qsort(Pivot, [], [], List).

    qsort(_Pivot, Smallers, Greaters, []) -> {Smallers, Greaters};
    qsort(Pivot, Smallers, Greaters, [First|Rest]) when First
    qsort(Pivot, [First|Smallers], Greaters, Rest);
    qsort(Pivot, Smallers, Greaters, [First|Rest]) when First >= Pivot ->
    qsort(Pivot, Smallers, [First|Greaters], Rest).

  4. Trung
    June 26th, 2013 at 13:32 | #4

    I think that’s not tail recursion as the control must return then modify the return value

  1. No trackbacks yet.