Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Move encode to universal opertors

...

Code Block
languagejavascript
themeConfluence
a = { "colors" : "many",
      "pi" : [3,1,4,1,5,6,9],
      "foo" : {"bar" : {"10":"I like cheese"}}
    };
c = a.delete(["foo", "bar", "10"])
// c = { "colors" : "many",
//       "pi" : [3,1,4,1,5,6,9],
//       "foo" : {"bar": {}}
// }

encode()

The encode() operator returns a string containing the JSON representation of the data structure to which it is applied. For example:

Code Block
languagejavascript
themeConfluence
a = {"a" : 10, "b" : [1, 3, "hello"]};
b = a.encode() // b = "{'a' : 10, 'b' : [1, 3, 'hello']}";

The encode() operator takes an optional positive integer argument specifying that the map should be pretty printed with newlines and indents with that number of spaces.

filter()

The filter() operator takes a function as its only argument and returns a map. The new map contains any members of the original map for which the function evaluates to true. The function given as the argument must take two arguments and return a Boolean value. The function is applied to the key and value of each member of the map in turn. The number of elements in the new map will be less than or equal to the length of the original map. For example:

...