Skip to content

Feedback: better ternary example in documentation #145

@ArnoStrouwen

Description

@ArnoStrouwen

It took me some time to figure out why this didn't work

julia> using DynamicExpressions
       lt(x::Float64, a::Float64, b::Float64) = a * x + b
       unary_ops = (-, inv, exp)
       binary_ops = (+, *)
       ternary_ops = (lt,)
       operators = OperatorEnum(1 => unary_ops, 2 => binary_ops, 3 => ternary_ops)
       Node{Float64}(op=0x1, children=(Node{Float64}(val=1.0), Node{Float64}(val=2.0),Node{Float64}(val=3.0)))
ERROR: AssertionError: D2 <= max_degree(N)
Stacktrace:
 [1] node_factory
   @ ~/.julia/packages/DynamicExpressions/85cyI/src/Node.jl:409 [inlined]
 [2] #_#69
   @ ~/.julia/packages/DynamicExpressions/85cyI/src/Node.jl:362 [inlined]
 [3] AbstractExpressionNode
   @ ~/.julia/packages/DynamicExpressions/85cyI/src/Node.jl:347 [inlined]
 [4] top-level scope
   @ ~/SR playground/Q2.jl:7

I don't think there are any examples where the D type parameter is set manually:

julia> Node{Float64,3}(op=0x1, children=(Node{Float64,3}(val=1.0), Node{Float64,3}(val=2.0),Node{Float64,3}(val=3.0)))
lt(1.0, 2.0, 3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions