]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/MList.scl
Added first and last functions to MList module
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / MList.scl
index fc4f941144a69950360b1895359f1d5a7a471a0e..74b0c2482c4f2c1910aa987c0da63259a1b89e6c 100644 (file)
@@ -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 -> <Proc> a
+first s = get s 0
+
+"Returns the last element of a list"
+@inline
+last :: T a -> <Proc> a
+last s = get s (Java.isub (size s) 1)
+
 @inline
 iter :: (a -> <e> ()) -> T a -> <e,Proc> ()
 iter f s = Iterator.iter f (iterator s)