Skip to content

Recursion and function evaluation #75

@CICS-Oleg

Description

@CICS-Oleg

Suppose we have a function like this

(: rec-func (-> Expression Atom))
(= (rec-func $expr)
    (trace! $expr
    (if-decons-expr $expr $head $tail
        (let $res ($head) (let () (println! $res) (rec-func $tail)))
        (println! "processing finished"))))

We want to pass some other functions as arguments

(= (func1) 1)
(= (func2) 2)
(= (func3) 3)

without preliminary execution.

This type of call can't be resolved:

!(rec-func (func1 func2 func3))

The output is

[(trace! (func1 func2 func3) (if-decons-expr (func1 func2 func3) $head#21 $tail#22 (let $res#23 ($head#21) (let () (println! $res#23) (rec-func $tail#22))) (println! "processing finished")))]

However with the previous versions of Metta the output was

(func1 func2 func3)
1
(func2 func3)
2
3
3
()
processing finished

That is still not what we want, but it resolved by the interpreter.

The problem is how to achieve behavior like that:

(func1 func2 func3)
1
(func2 func3)
2
(func3)
3
()
processing finished

with the current state of Metta?

Metadata

Metadata

Labels

answeredTutorial question is answered but not added to docshelp wantedExtra attention is neededquestionFurther information is requestedtutorialTutorial question

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions