Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // nie ogonowo
- def listLength1[A](l: List[A]): Int = {
- if (l != Nil)
- 1 + listLength(l.tail)
- else
- 0
- }
- // ogonowo
- def listLength2[A](l: List[A]): Int = {
- def length_aux(l: List[A], len: Int): Int =
- if (l != Nil)
- length_aux(l.tail, len + 1)
- else
- len
- length_aux(l, 0)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement