#binomial coefficient

9 messages · Page 1 of 1 (latest)

frank igloo
#

I tried to recreate the binomial coefficient in Typst. The following function should be correct, but ends with the error "cannot join array with integer" when I call the function ncr(10,3) somewhere.

let ncr(n,k) = {
let result = 1
for i in range(1, k + 1) {
result = result * (n - i + 1)
}
return result
}

frank igloo
mellow fog
#

It will be included as a native math function in the next release. It is already available if you use the github version (without the webapp)

valid ether
#

By default, every single line in a code block (which includes functions) is joined

#

So if you write like
let a = {
[a]
[b]
[c]
}

a Will be [abc]

#

However lines with an assignment (including “let …”) don’t return anything and are ignored for that purpose

#

Just in case you’re not aware of this

frank igloo
#

I was learning how code blocks work.
But I guess no I understand.
Thanks!