grailbio / reflow

A language and runtime for distributed, incremental data processing in the cloud
Apache License 2.0
965 stars 52 forks source link

How to take a power of a number? #105

Closed olgabot closed 5 years ago

olgabot commented 5 years ago

Hello, How can one take the power of a number in Reflow? I'm using Reflow to switch between programs where one requires its "sketch size" in log2, and the other requires it in the absolute number, so I'd like to toggle between them. I didn't see a power or exponent operator in the language description.

For example, I'd like to be able to do this:

    sketch_size := 2**log2_sketch_size

Warmest, Olga

jcharum commented 5 years ago

If you are looking for integer powers of base 2, you can achieve this today with:

func pow2(exp int) = 1 << exp
sketch_size := pow2(log2_sketch_size)

Maybe that is helpful?