From: Hannu Niemistö Date: Fri, 6 Oct 2017 06:56:59 +0000 (+0300) Subject: (refs #7531) Functions first and last to Prelude X-Git-Tag: v1.31.0~138^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=9dada94874a646bc63fc73ed1fd431456ce50889;p=simantics%2Fplatform.git (refs #7531) Functions first and last to Prelude Change-Id: Ic8839efc97a619658e570f435c23ac0c1d9b3e18 --- 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