Files
newt/src/Data/List1.newt
Steve Dunham 3c2615ecc1 move idris version to orig and newt version to src.
Development is being done on the newt version now.
2025-02-15 16:36:29 -08:00

28 lines
607 B
Agda
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
module Data.List1
import Prelude
infixr 7 _:::_
record List1 a where
constructor _:::_
head1 : a
tail1 : List a
split1 : String String List1 String
split1 str by = case split str by of
Nil => str ::: Nil
x :: xs => x ::: xs
unsnoc : a. List1 a List a × a
unsnoc {a} (x ::: xs) = go x xs
where
go : a List a List a × a
go x Nil = (Nil, x)
go x (y :: ys) = let (as, a) = go y ys in (x :: as, a)
splitFileName : String String × String
splitFileName fn = case split1 fn "." of
part ::: Nil => (part, "")
xs => mapFst (joinBy ".") $ unsnoc xs