X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FMList.scl;h=74b0c2482c4f2c1910aa987c0da63259a1b89e6c;hb=6c99e980d250fb9201aba93be7dcb1f55564dccd;hp=6cafe6bf4426b6091f8b28488008a451cface46b;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.runtime/scl/MList.scl b/bundles/org.simantics.scl.runtime/scl/MList.scl index 6cafe6bf4..74b0c2482 100644 --- a/bundles/org.simantics.scl.runtime/scl/MList.scl +++ b/bundles/org.simantics.scl.runtime/scl/MList.scl @@ -9,6 +9,7 @@ importJava "java.util.List" where size :: T a -> Integer isEmpty :: T a -> Boolean get :: T a -> Integer -> a + set :: T a -> Integer -> a -> Maybe a add :: T a -> a -> () addAll :: T a -> [a] -> () @@ -23,6 +24,16 @@ removeLast l = if isEmpty l then Nothing else Just (remove l (Java.isub (size l) 1)) +"Returns the first element of a list" +@inline +first :: T a -> a +first s = get s 0 + +"Returns the last element of a list" +@inline +last :: T a -> a +last s = get s (Java.isub (size s) 1) + @inline iter :: (a -> ()) -> T a -> () iter f s = Iterator.iter f (iterator s)