feat: add contains method to List and update Set example to new operator syntax

Add a `contains(element)` method to the `List` class in the core library,
enabling linear search for an element across all list items. Update the
`example/set.wren` file to use the new Wren operator syntax for `|`, `+`,
`&`, and `-` methods, replacing old function-style parameter definitions
with block-style closures. Also fix trailing whitespace throughout the
Set example and embed the new `contains` method into the C source string
in `src/wren_core.c` for the built-in List class.
This commit is contained in:
Kyle Marek-Spartz
2015-01-09 22:02:40 +00:00
parent e6fb918cc7
commit b949886707
3 changed files with 49 additions and 24 deletions
+9
View File
@@ -84,6 +84,15 @@ static const char* libSource =
" }\n"
" return result\n"
" }\n"
"\n"
" contains(element) {\n"
" for (item in this) {\n"
" if (element == item) {\n"
" return true\n"
" }\n"
" }\n"
" return false\n"
" }\n"
"}\n"
"\n"
"class Range is Sequence {}\n";