Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type FieldSelector =
- | FactIndex of int
- | Sum of FieldSelector * FieldSelector
- | ProdLeft of FieldSelector
- | ProdRight of FieldSelector
- | Rec
- type Fact = int[]
- type TokenElement =
- | TEFact of Fact
- | TELeft of TokenElement
- | TERight of TokenElement
- | TEProd of TokenElement * TokenElement
- let lookupTE (fieldSelector:FieldSelector) (tokenElement:TokenElement) =
- let rec loop lsel te =
- match lsel, te with
- | FactIndex index, TEFact ar -> ar.[index]
- | Sum(fl, _), TELeft tel -> loop fl tel
- | Sum(_, fr), TERight ter -> loop fr ter
- | ProdLeft fs, TEProd(teFst,_) -> loop fs teFst
- | ProdRight fs, TEProd(_,teSnd) -> loop fs teSnd
- | Rec, te -> loop fieldSelector te
- loop fieldSelector tokenElement
- let listTE = TELeft <| TEFact [|1; 2|]
- let listTE2 = TERight <| TEProd(TEFact [|1; 2|],TELeft <| TEFact [|2; 3|])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement