]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/scl/MList.scl
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / MList.scl
index 6cafe6bf4426b6091f8b28488008a451cface46b..74b0c2482c4f2c1910aa987c0da63259a1b89e6c 100644 (file)
@@ -9,6 +9,7 @@ importJava "java.util.List" where
     size :: T a -> <Proc> Integer
     isEmpty :: T a -> <Proc> Boolean
     get :: T a -> Integer -> <Proc> a
+    set :: T a -> Integer -> a -> <Proc> Maybe a
     
     add :: T a -> a -> <Proc> ()
     addAll :: T a -> [a] -> <Proc> ()
@@ -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 -> <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)