#Convert Field type to Number

4 messages · Page 1 of 1 (latest)

dense sandal
#

How can I get the value from a Bool array in a recursion function using an index of type Field

feral pelican
#

Direct conversion from a Field type to a Number is not typically feasible, If you need to work with a numeric value alongside a Field, I would suggest you maintain a parallel numeric representation (e.g., an integer) alongside the Field for scenarios where you need a number.

dense sandal
#

How can I do this

jade shuttle
#

@dense sandal I'm going to answer the original question:

How can I get the value from a Bool array in a recursion function using an index of type Field
you usually do this type of array processing with O(n) constraints. Something like

let oneHot = range(n).map(i => index.equals(i));
let elementAtIndex = Provable.switch(oneHot, Bool, boolArray);