From 9dada94874a646bc63fc73ed1fd431456ce50889 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Fri, 6 Oct 2017 09:56:59 +0300 Subject: [PATCH] (refs #7531) Functions first and last to Prelude Change-Id: Ic8839efc97a619658e570f435c23ac0c1d9b3e18 --- bundles/org.simantics.scl.runtime/scl/Prelude.scl | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- 2.43.2