Looking at Dllist.skip, this looks like a bug.  A better implementation of skip might be:

let skip node idx =
    let rec loop idx n =
        if idx == 0 then
            n
        else if idx>0 then
            loop (idx -1) n.next
        else
            loop (idx + 1) n.prev
    in
    loop idx node

(The current version doesn't use n.prev for negative arguments).  If there are no complains, I'll make this change.



On 10/3/05, Pierre-Antoine Delsart <delsart@lps.umontreal.ca> wrote:

Hello people,

Is it normal that I can't have Dllist.skip work as I expect using
negative arguments ?

Here is an exemple of what I'm trying with extlib 1.4 :

> ocaml  -I /<path_to_extlib>/ /<path_to_extlib>/extLib.cma

let ll = Dllist.create 0;;
Dllist.add ll 4;;
Dllist.add ll 8;;
Dllist.add ll 5012;;
let printl a = print_string ((string_of_int a)^"\n");;
Dllist.iter printl ll;;
let ll1 = Dllist.skip ll 1;;
Dllist.iter printl ll1;;
let ll1m = Dllist.skip ll (-1);;
Dllist.iter printl ll1m;;


I expect the operation on ll1 and ll1m to behave differently, however I
have exactly the same result ... as if the negative sign was not taken
into account.

Am I doing something wrong ?

Thanks for your help.

PA.


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
ocaml-lib-devel mailing list
ocaml-lib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ocaml-lib-devel