You have to use some triangularization to make sure that you get all values. Perhaps this is a reasonable ;-) method:
First write an iterator code that generates all strings, starting with the empty string, all one-character strings, all two-character strings, and so on.
Then stack another iterator that runs decode_value on all these strings, if decode_value succeeds, the value is generated as a part of the enumeration.
Try this,
#! /usr/local/bin/pike
int increment(array a) { for (int i = sizeof(a); i; ) { i--; if (++a[i] < 0x100) return 1; a[i] = 0; } return 0; }
int main(int argc, array(string) argv) { for (int l = 0; ;l++) { array a = allocate(l); do { object o; if (!catch (o = decode_value((string)a))) write("%O\n", o); } while (increment(a)); } }
Seems to generate some values, like 0, 0.0, and empty strings, arrays and multisets multiple times, though.
/ Niels Möller ()
Previous text:
2003-02-06 14:44: Subject: Xor
First all positive integers, then all negative integers, then floats, then strings, and then the objects, mappings arrays and multisets.
If we just define that order, my version is correct. :-)
/ Per Hedbor ()