]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7531) Functions first and last to Prelude 82/1082/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 6 Oct 2017 06:56:59 +0000 (09:56 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 6 Oct 2017 10:57:51 +0000 (13:57 +0300)
Change-Id: Ic8839efc97a619658e570f435c23ac0c1d9b3e18

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
 
     "`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
 
 instance IndexedSequence [] where
     (!) = getList