X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FPrelude.scl;fp=bundles%2Forg.simantics.scl.runtime%2Fscl%2FPrelude.scl;h=8fcd3ced191d6f2ebbcc9c595021206e5b5e684f;hp=f06acb29fce55e74e98c111364ede07908947df9;hb=9dada94874a646bc63fc73ed1fd431456ce50889;hpb=5bed099be36a76e204265abb2f471d84050c0d66 diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index f06acb29f..8fcd3ced1 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -1162,6 +1162,14 @@ class IndexedSequence f where "`seq ! i` returns the `i`th element of the sequence `seq`. Indexing starts from zero." (!) :: f a -> Integer -> a +"Returns the first element of a sequence" +@inline +first l = l!0 + +"Returns the last element of a sequence" +@inline +last l = l!(length l-1) + instance IndexedSequence [] where (!) = getList