Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as F# by Dan ( 14 years ago )
type 'a Zipper = ('a list)*('a list)

let head = function
    | (_,[])   -> None
    | (_,h::t) -> Some h

let mkzip l = ([],l)

let right = function
    | (_,[])   -> None
    | (l,h::t) -> Some (h::l,t)

let left = function
    | ([],_)   -> None
    | (h::t,r) -> Some (t,h::r)

let myz : int Zipper = ([1;2;3],[4;5;6])

right myz |> Option.bind right |> Option.bind head
right myz |> Option.bind right 
          |> Option.bind right 
          |> Option.bind right

 

Revise this Paste

Children: 46122
Your Name: Code Language: