File: recursion.star

package info (click to toggle)
golang-starlark 0.0~git20240725.42030a7-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 1,296 kB
  • sloc: makefile: 8; sh: 8
file content (14 lines) | stat: -rw-r--r-- 259 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Tests of Starlark recursion and while statement.

# This is a "chunked" file: each "---" effectively starts a new file.

# option:recursion

load("assert.star", "assert")

def fib(n):
	if n <= 1:
		return 1
	return fib(n-1) + fib(n-2)

assert.eq(fib(5), 8)