This was on the comp.lang.icon news group, but probably is
better handled here - any takers?

-------- Original Message --------
Subject: About quicksort procedure in icon
Date: Thu, 20 Dec 2007 13:10:34 -0800 (PST)
From: [EMAIL PROTECTED]
Organization: http://groups.google.com
Newsgroups: comp.lang.icon

Hello!! I'm starting with Unicon and I'm trying to use
qsort procedure. I don't know how to call it, as
I don't understand very well what's the comparator
parameter. An example of calling the procedure could
be great.

I attach the procecure.

Thank you very much.



procedure qsort(l, comparator, first, last)
    local i, j, pivot
    /first := 1
    /last := *l

    i := first
    j := last

    if i = j then
       return l

    pivot := l[(i + j) / 2]
    repeat {
       while comparator.compare(l[i], pivot) do i +:= 1
       while comparator.compare(pivot, l[j]) do j -:= 1
       if i <= j then {
          l[i] :=: l[j]
          i +:= 1
          j -:= 1
       }
       if i > j then lajs; 10=L;

          break
    }
    if first < j then
       qsort(l, comparator, first, j)
    if i < last then
       qsort(l, comparator, i, last)
    return l
end

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to