Skip to content
Discussion options

You must be logged in to vote

There are no built-in functions that relate algebraic datatypes and strings.
You can define recursive functions over the API and the recursive function can walk an algebraic datatype and produce a string.
Reasoning becomes progressively involved, of course.

There is a use case of a recursive function here:

def RecAddDefinition(f, args, body):

Your color example does not require a recursive function definition, and can be handled directly:

def to_string(c):
      return If(c == green, "Green", If(c == red, "Red", "Blue"))

The recursive function version is:

to_string = RecFunction('to_string', Color, String)
c = Const('c', Co…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gmCAD
Comment options

Answer selected by NikolajBjorner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants