Skip to content
Snippets Groups Projects
Commit 50e4ccd7 authored by Mikaël Mayer's avatar Mikaël Mayer
Browse files

Added range on List

parent 97bf1cc8
No related branches found
No related tags found
No related merge requests found
...@@ -573,6 +573,13 @@ object List { ...@@ -573,6 +573,13 @@ object List {
else Cons[T](x, fill[T](n-1)(x)) else Cons[T](x, fill[T](n-1)(x))
} ensuring(res => (res.content == (if (n <= BigInt(0)) Set.empty[T] else Set(x))) && } ensuring(res => (res.content == (if (n <= BigInt(0)) Set.empty[T] else Set(x))) &&
res.size == (if (n <= BigInt(0)) BigInt(0) else n)) res.size == (if (n <= BigInt(0)) BigInt(0) else n))
/* Range from start (inclusive) to until (exclusive) */
@library
def range(start: BigInt, until: BigInt): List[BigInt] = {
require(start <= until)
if(until <= start) Nil[BigInt]() else Cons(start, range(start + 1, until))
} ensuring{(res: List[BigInt]) => res.size == until - start }
@library @library
def mkString[A](l: List[A], mid: String, f : A => String) = { def mkString[A](l: List[A], mid: String, f : A => String) = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment