Skip to content

Commit

Permalink
Updated stdlib_mettalog.metta: Renamed If function to MettaMorph-If f…
Browse files Browse the repository at this point in the history
…or consistency with naming conventions, refined conditional logic handling, and improved documentation to clarify usage and expected behavior for new function definitions.
  • Loading branch information
TeamSPoon committed Jan 3, 2025
1 parent 4f5ba7a commit fb2e92c
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions prolog/metta_lang/stdlib_mettalog.metta
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@
(: case (-> Expression Atom Atom))
(: combine (-> $t $t $t))
(: import! (-> hyperon::space::DynSpace Atom (->)))
(: If (-> Bool Atom Atom Atom))
(: If (-> Bool Atom Atom))
(= (If True $then) $then)
(= (If False $then) (let $n 0 (let $n 1 $n)))
(= (If $cond $then $else) (if $cond $then $else))


(@doc type-check
(@desc "The value of type-check determines MeTTa's type-checking behavior. Set via pragma!. When set to auto (i.e. !(pragma! type-check auto)), types are checked immediately on adding an expression to the space. By default, when unset (or set to anything other than auto), types are checked only on evaluation. For example !(+ 1 \"2\") would trigger a type violation, but (= (foo $x) (+ $x \"2\")) would not, unless type-check is set to auto, in which case both would trigger type violations."))
Expand Down Expand Up @@ -183,22 +179,21 @@ For example:
(predicate-arity function-arity 2)
(function-arity function-arity 1)

;; MettaMorph-If Function

;; If Function

(iz If MeTTa)
(@doc If
(iz MettaMorph-If MeTTaMorph)
(@doc MettaMorph-If
(@desc "Conditional function that evaluates and returns one of the provided atoms based on a boolean condition.")
(@params (
(@param "Boolean condition")
(@param "Atom to return if condition is True")
(@param "Atom to return if condition is False (optional)")))
(@return "Either the second or third argument depending on the condition"))
(: If (-> Bool Atom Atom Atom))
(: If (-> Bool Atom Atom))
(= (If True $then) $then)
(= (If False $then) (let $n 0 (let $n 1 $n))) ; Placeholder for False condition
(= (If $cond $then $else) (if $cond $then $else))
(: MettaMorph-If (-> Bool Atom Atom Atom))
(: MettaMorph-If (-> Bool Atom Atom))
(= (MettaMorph-If True $then) $then)
(= (MettaMorph-If False $then) (let $n 0 (let $n 1 $n))) ; Placeholder for False condition
(= (MettaMorph-If $cond $then $else) (if $cond $then $else))

;; Arity Assignments

Expand Down

0 comments on commit fb2e92c

Please sign in to comment.