trueagi-io / hyperon-experimental

MeTTa programming language implementation
https://metta-lang.dev
MIT License
141 stars 47 forks source link

Implementing py-tuple py-list py-dict py-chain #671

Closed astroseger closed 5 months ago

astroseger commented 5 months ago

This PR adds py-tuple py-list py-dict py-chain into stdlibs This PR also updates sandbox simple_import examples

astroseger commented 5 months ago

@Necr0x0Der @besSveta I've made the following changes.

  1. py-tuple py-list py-dict and py-chain now require python tuple as a single parameter. So it will work as following:

    (py-tuple (1 (2 3)))    -> (1, (2,3))
    (py-list (1 (2 3 ))) -> [1, [2, 3]]
    (py-dict (("a" "b") ("c" "d"))) -> {"a":"b", "c" : "d"}
  2. Unit tests were added.

  3. py-dict will automatically convert Symbol into python string for keys: (py-dict ((a "b"))) -> {"a" : "b"}

  4. The most controversial change: all functions will pass non-grounded objects as it is (except Symbol for dictionary keys and Expressions in py-tuple and py-list). It means that the function (py-list (a b)) will create python list with two symbol atoms.