lazylist - Removing duplicates from lazy list Ocaml -


i need remove duplicates lazy list. here piece of code managed write have no clue on how fix work properly.

i know how using regular list, lazy list still new me, happy help. here piece of code tried write:

let rec removeduplicate = function lnil -> lnil |lcons(x,xf) -> x::(removeduplicate (list.filter (fun -> a<>x) xf));; 

thanks in advance help.

the first problem, see in code, instead of building lazy list in second clause, you're building ocaml's built-in list, :: consing operator. also, can't use list.filter on tail part, since operates on values of type 'a list, not yours list.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -