Sometimes it's hard to believe Felix is SOO dang good! This works now:
var squares = \{ (?x,?y) : int * int | y == x * x \} ; println$ (3,9) \in squares; The general form is \{ pattern : type | predicate \} A predicate is any expression evaluating to bool, which may use the variables in the pattern match. We have to specify the type of the pattern, and our patterns have ugly ? in them sometimes, but otherwise this is similar to a mathematical set. A set_form is a real object. Any object with a method has_elt: T -> bool acts like a set courtesy of these definition in std/algebra/set.flx: interface set_form[T] { has_elt: T -> bool; } fun \in[T] (elt:T, s:set_form[T]) => s.has_elt elt; If your object has other methods you can "cast" them away with a coercion to meet the specification. It's easy to define the union now: fun \cup[T] (A:set_form[T], B:set_form[T]) => \{ ?x : T | x \in A or x \in B \}; I will do some more work on this. * At present, \{ \} can must be used. It's possible the parser will work with plain {} * To display it right you need to go into math mode: \( \{ (?x,?y) : int * int | y == x * x \} \) which will also display the \( \) parents ;( I may be able to fix this, I'm not sure: not all program code looks right in math mode. * \mid works better than |, whether it should be allowed, or flx_web should just change the | I don't know (matches can be used in the expression so it could be confused .. ) -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language