]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "(refs #7531) Functions first and last to Prelude"
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 9 Oct 2017 05:06:20 +0000 (08:06 +0300)
committerGerrit Code Review <gerrit2@www.simantics.org>
Mon, 9 Oct 2017 05:06:20 +0000 (08:06 +0300)
bundles/org.simantics.scl.runtime/scl/Prelude.scl

index f06acb29fce55e74e98c111364ede07908947df9..8fcd3ced191d6f2ebbcc9c595021206e5b5e684f 100644 (file)
@@ -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