From: Hannu Niemistö Date: Mon, 9 Oct 2017 05:06:20 +0000 (+0300) Subject: Merge "(refs #7531) Functions first and last to Prelude" X-Git-Tag: v1.31.0~138 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=b61161c26b1711e075a685b00d961978640acb82;hp=19fa38f6cd07e0917e5f25e009a90617ce431488 Merge "(refs #7531) Functions first and last to Prelude" --- 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