feat: add Sequence.any method and update docs, tests, and core source

Implement the `any` method on the Sequence class that returns true if any element passes the given predicate function. Update the core.wren library source, the C embedded source string in wren_core.c, and add comprehensive test files for normal usage, non-bool return values, and non-function argument error handling. Also fix a typo in the QA documentation and correct the initial account balance in the example.
This commit is contained in:
Bob Nystrom
2015-03-03 15:23:47 +00:00
7 changed files with 42 additions and 4 deletions
+10
View File
@@ -0,0 +1,10 @@
var a = [1, 2, 3]
var b = a.any {|x| x > 3 }
IO.print(b) // expect: false
var d = a.any {|x| x > 1 }
IO.print(d) // expect: true
var e = [].any {|x| true }
IO.print(e) // expect: false
+1
View File
@@ -0,0 +1 @@
IO.print([1, 2, 3].any {|x| "truthy" }) // expect: true
+1
View File
@@ -0,0 +1 @@
[1, 2, 3].any("string") // expect runtime error: String does not implement 'call(_)'.