-
Notifications
You must be signed in to change notification settings - Fork 7
clean up functions for smoother run #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding flatten
, it outputs (Error (bc (→ B C)) IncorrectNumberOfArguments)
, meaning that somewhere down the line, as flatten
manipulates the expression it ends up with (bc (→ B C))
and the MeTTa interpreter tries to run it. I don't know why it didn't fail before.
Do you mind attempting to figure out what is wrong?
The following much simpler expression fails for the same reason
!(flatten (: bc A))
Surely, we should be able to prevent MeTTa from running intermediary expressions, using quote
or such. Or maybe modify the code so that it does not create such intermediary expression, not sure.
;; Test len-str | ||
!(assertEqual | ||
(len-str "abc") | ||
3) | ||
|
||
(: concat-str (-> String String String)) | ||
(= (concat-str $lhs $rhs) (charsToString ($lhs $rhs))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this is an exploit of weak typing, charsToString
is not supposed to work with strings. Although it works, I would recommend to use https://github.com/singnet/ai-dsl/blob/aaa702e9eb6c95268b085ed1906bba6f728ea76f/experimental/ai-service-composition/english-to-chinese-song/etcs-combinator-data-uncurry-xp.metta#L203
(chain (eval (stringToChars $joined-str)) $str-expr ;; working version befor edit just characters are returned as 'A' instead of "A" .. | ||
;; attempt to fix that using charsToString function | ||
(chain (toString $str-expr) $result | ||
(return $result))))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it is not used anywhere, maybe split-str
can be removed.
(chain (eval (charsToString ($head))) $head-str | ||
(chain (eval (toString $tail)) $rest | ||
(chain (cons-atom $head-str $rest) $result (return $result)))) | ||
(return ()))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thus this could be removed as well (I suppose).
On my end, I am getting |
I'm running 0.2.6, but maybe it is not relevant, though I suppose it is probably indeed better if you use the latest version, just in case. |
The reason for the IncorrectNumberOfArguments error is that we've defined bc as
Using the same variable name bc in the test
causes (bc (→ B C)) to be evaluated, which results in IncorrectNumberOfArguments. |
No description provided.