Commit Graph
17 Commits
Author SHA1 Message Date
Thorbjørn Lindeijer 4555a47465 feat: add lazy Sequence.skip and Sequence.take methods with SkipSequence and TakeSequence classes
Implement SkipSequence and TakeSequence as lazy iterator-producing wrappers in the core Sequence class. SkipSequence advances past the first count elements on initial iteration, while TakeSequence tracks taken count via _taken field and returns null when exceeded. Include documentation in sequence.markdown, update wren_core.wren.inc, and add test files for both methods covering edge cases (zero, negative, overflow counts).
2015-04-06 15:54:04 +00:00
Thorbjørn Lindeijer f86239dac1 fix: update Sequence.list references to toList in documentation
Replace remaining references to the renamed `Sequence.list` method with `Sequence.toList` across the core sequence documentation. This includes updating the `join` method description to refer to "sequence" instead of "list", removing the deprecated `list` method section, and correcting code examples that used `.list` to now use `.toList` for eager evaluation.
2015-04-06 15:21:32 +00:00
Thorbjørn Lindeijer 5b71ac0c56 feat: replace eager list-based map/where with deferred MapSequence and WhereSequence classes
Introduce MapSequence and WhereSequence subclasses of Sequence that apply transformations lazily during iteration instead of building intermediate lists. Update Sequence.map and Sequence.where to return these deferred wrappers, modify all existing tests to call .list on results, and add new infinite-sequence tests verifying lazy behavior on Fibonacci iterators.
2015-03-28 21:51:50 +00:00
Thorbjørn Lindeijer 343bfa7a84 feat: add Sequence.each method for side-effect iteration without list creation
Add a new `each` method to the Sequence class that iterates over elements
calling a provided function for each, serving as a side-effect-only
alternative to `map` when the resulting list is not needed. This is
particularly important for the upcoming change where `map` will return a
new sequence instead of mutating in place, as demonstrated by updating
the README and index examples to use `each` with Fiber.yield. Includes
documentation in the Sequence API reference and three new test cases
covering normal iteration, empty sequences, and non-function argument
error handling.
2015-03-28 19:35:20 +00:00
Thorbjørn Lindeijer 33d1217d6a feat: add Sequence.list method to convert any sequence into a List
Implements a new `list` method on the Sequence class that iterates over all elements and collects them into a new List instance. Includes documentation in the core sequence docs and a test case verifying correct behavior with a custom sequence implementation.
2015-03-27 21:59:58 +00:00
Thorbjørn Lindeijer 3e65af35c3 chore: add Thorbjørn Lindeijer to AUTHORS file with email address
Fix missing closing angle bracket on Raymond Sohn's email and append
new contributor entry for Thorbjørn Lindeijer <bjorn@lindeijer.nl>.
2015-03-25 23:01:34 +00:00
Thorbjørn Lindeijer ed559673ea feat: add Num.pi constant and trigonometric function tests for acos, asin, atan, cos, sin, tan 2015-03-19 20:12:50 +00:00
Thorbjørn Lindeijer 9a01d4b489 feat: reverse argument order of List.insert to index-first convention
The previous signature `insert(element, index)` was counter-intuitive and inconsistent with every major language's list API. This commit swaps the parameters to `insert(index, element)`, matching the convention used by Ruby, JavaScript, C++, Lua, C#, Java, and Python. All documentation, C implementation, and test files are updated to reflect the new order.
2015-03-15 21:51:24 +00:00
Thorbjørn Lindeijer c717b8d3fd feat: add Num.atan(x) method mapping to C atan2 for quadrant-aware arc tangent
Adds a new `atan(_)` primitive method to the Num class that wraps the C
`atan2` function, allowing callers to compute the arc tangent of the
number divided by a given argument `x` while using the signs of both
numbers to determine the correct quadrant of the result. The
implementation registers the primitive `num_atan2` in the core VM
initialization and documents the new method in the core library
reference.
2015-03-15 15:43:02 +00:00
Thorbjørn Lindeijer cbe0676e79 fix: correct source file paths in generate_builtins.py from src/ to src/vm/
The copy_builtin function was reading and writing builtin C source files
from the wrong directory (src/ instead of src/vm/), causing the script
to fail when run from the project root. Updated both the read and write
file paths to use the correct src/vm/ prefix.
2015-03-15 14:55:51 +00:00
Thorbjørn Lindeijer b22040577e feat: move contains method from List to Sequence and add tests for List and Range
Add a generic `contains` implementation on the `Sequence` base class, removing the duplicate method from `List`. This allows all sequence types (including Range) to use the method without per-class redefinition. Include new test files for `List.contains` and `Range.contains` covering ordered, backwards, and exclusive ranges.
2015-03-15 14:43:10 +00:00
Thorbjørn Lindeijer ac414a24fd feat: add acos, asin, atan trigonometric methods to Num class
Implement arc cosine, arc sine, and arc tangent primitives in the VM core
and document them in the Num API reference.
2015-03-14 13:52:16 +00:00
Thorbjørn Lindeijer 2e6cb23b56 feat: add Num.tan method to core library and documentation
Add the missing `tan` method to the Num class, implementing the tangent
trigonometric function. This fills the gap between the existing `sin` and
`cos` methods, providing a complete set of basic trigonometric operations.

- Register `num_tan` primitive in the VM core initialization
- Implement `DEF_PRIMITIVE(num_tan)` using C's `tan()` math function
- Add documentation entry for `tan` in the core library reference
2015-03-14 13:40:23 +00:00
Thorbjørn Lindeijer 9dc939380c feat: add Sequence.count(predicate) method and update documentation
Implement a new `count(f)` method on the Sequence class that accepts a predicate function and returns the number of elements for which the predicate evaluates to true. The implementation iterates over the sequence, calling `f.call(element)` on each element and incrementing a counter when the result is truthy.

Also update the documentation for both Sequence and List classes: add full documentation for the new `count(predicate)` method on Sequence, and change the terminology in List docs from "items" to "elements" for consistency. Add three test files covering the basic predicate behavior, non-boolean return values from the predicate, and the error case when a non-function argument is passed.
2015-03-14 13:17:21 +00:00
Thorbjørn Lindeijer bf3590d47a docs: fix inconsistent initial balance in Wren example and broken sentence grammar 2015-03-01 14:18:58 +00:00
Thorbjørn Lindeijer 8f54dc5f76 feat: add Sequence.any method as complement to Sequence.all
Adds a new `any` method to the Sequence class that tests whether any element
in the sequence passes the given predicate function, returning true on the
first match or false if none match. Includes documentation, core library
source update, and three new test files covering basic functionality,
non-boolean return values, and non-function argument error handling.
2015-02-28 20:45:39 +00:00
Thorbjørn Lindeijer c4be1e70ca perf: replace closure-based fib with static class method for 6% speedup
Refactor the Fibonacci benchmark to use a static method on a class instead of a recursive closure, eliminating closure overhead and yielding consistent performance improvement.
2015-02-28 20:14:28 +00:00