X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FMList.scl;h=74b0c2482c4f2c1910aa987c0da63259a1b89e6c;hp=fc4f941144a69950360b1895359f1d5a7a471a0e;hb=083af64921be0776de06f568e616fb835b9dc23f;hpb=92f850a1a57b6156e92cbb405f29c9a0ecba2b9b diff --git a/bundles/org.simantics.scl.runtime/scl/MList.scl b/bundles/org.simantics.scl.runtime/scl/MList.scl index fc4f94114..74b0c2482 100644 --- a/bundles/org.simantics.scl.runtime/scl/MList.scl +++ b/bundles/org.simantics.scl.runtime/scl/MList.scl @@ -24,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)