First pass at a scheme backend
This commit is contained in:
@@ -9,8 +9,8 @@ record List1 a where
|
||||
head1 : a
|
||||
tail1 : List a
|
||||
|
||||
split1 : String → String → List1 String
|
||||
split1 str by = case split str by of
|
||||
splitBy1 : String → Char → List1 String
|
||||
splitBy1 str by = case splitBy str by of
|
||||
Nil => str ::: Nil
|
||||
x :: xs => x ::: xs
|
||||
|
||||
@@ -22,6 +22,6 @@ unsnoc {a} (x ::: xs) = go x xs
|
||||
go x (y :: ys) = let (as, a) = go y ys in (x :: as, a)
|
||||
|
||||
splitFileName : String → String × String
|
||||
splitFileName fn = case split1 fn "." of
|
||||
splitFileName fn = case splitBy1 fn '.' of
|
||||
part ::: Nil => (part, "")
|
||||
xs => mapFst (joinBy ".") $ unsnoc xs
|
||||
|
||||
@@ -9,6 +9,13 @@ snoclen {a} xs = go xs Z
|
||||
go Lin acc = acc
|
||||
go (xs :< x) acc = go xs (S acc)
|
||||
|
||||
snoclen' : ∀ a. SnocList a → Int
|
||||
snoclen' {a} xs = go xs 0
|
||||
where
|
||||
go : SnocList a → Int → Int
|
||||
go Lin acc = acc
|
||||
go (xs :< x) acc = go xs (1 + acc)
|
||||
|
||||
snocelem : ∀ a. {{Eq a}} → a → SnocList a → Bool
|
||||
snocelem a Lin = False
|
||||
snocelem a (xs :< x) = if a == x then True else snocelem a xs
|
||||
|
||||
Reference in New Issue
Block a user