mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 09:32:53 -06:00
Transfer: fixed bug in prelude partition. Fixed naming of tuple field names, made it 1-based as in docs, instead of 0-based as before.
This commit is contained in:
@@ -577,10 +577,10 @@ gtrue = GuardExp true
|
|||||||
|
|
||||||
|
|
||||||
mkETuple :: [Exp] -> Exp
|
mkETuple :: [Exp] -> Exp
|
||||||
mkETuple = ERec . zipWith (\i -> FieldValue (Ident ("p"++show i))) [0..]
|
mkETuple = ERec . zipWith (\i -> FieldValue (Ident ("p"++show i))) [1..]
|
||||||
|
|
||||||
mkPTuple :: [Pattern] -> Pattern
|
mkPTuple :: [Pattern] -> Pattern
|
||||||
mkPTuple = PRec . zipWith (\i -> FieldPattern (Ident ("p"++show i))) [0..]
|
mkPTuple = PRec . zipWith (\i -> FieldPattern (Ident ("p"++show i))) [1..]
|
||||||
|
|
||||||
-- | Apply an expression to a list of arguments.
|
-- | Apply an expression to a list of arguments.
|
||||||
apply :: Exp -> [Exp] -> Exp
|
apply :: Exp -> [Exp] -> Exp
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ partition : (A : Type) -> (A -> Bool) -> List A -> Pair (List A) (List A)
|
|||||||
partition _ _ [] = ([],[])
|
partition _ _ [] = ([],[])
|
||||||
partition A p (x::xs) =
|
partition A p (x::xs) =
|
||||||
let r : Pair (List A) (List A) = partition A p xs
|
let r : Pair (List A) (List A) = partition A p xs
|
||||||
in if p x then (x :: fst r, snd r) else (fst r, x :: snd r)
|
in if p x then (x :: r.p1, r.p2) else (r.p1, x :: r.p2)
|
||||||
|
|
||||||
|
|
||||||
-- Instances:
|
-- Instances:
|
||||||
|
|||||||
Reference in New Issue
Block a user