Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features and improvements to iterable objects #99

Merged
merged 1 commit into from
Mar 26, 2019

Conversation

catb0t
Copy link
Contributor

@catb0t catb0t commented Mar 26, 2019

  • add the any, all and none Set methods, which
    necessitate a dclone that can sometimes be
    preferred over conversion to an Array

  • .any, .all, and .none on Set and Array can be
    called without a block, like map

  • Block: new constants, IDENTITY and LIST_IDENTITY
    which return their argument or arguments,
    respectively, to lessen runtime overhead for
    these tiny but common callables.

User code can construct these with Block.identity
and Block.list_identity.

  • Array: use the IDENTITY block if a method that
    wants a block, wasn't called with one.
    This eliminates some runtime overhead for
    nested loops, and cleans up the code with
    fewer immediate anonymous subs that can
    introduce typos.

  • add the Hash.linear_selection method, which
    creates a Hash that is a subset of a hash,
    given an iterable argument of keys

  • linear_selection, useful on its own, is used
    to implement Set-like operations on Hashes,
    with Sets, Hashes, Arrays, and other iterables
    on the RHS.

  • Now it's possible to intersect, difference,
    union and symdiff Hashes with other objects.
    These operate primarily on the Hashes' keys.

  • Last, Set.difference is extended to allow a
    Hash on the RHS, for subtracting a Hash's
    keys from a Set without needing to iterate
    it twice.

- add the any, all and none Set methods, which
    necessitate a dclone that can sometimes be
    preferred over conversion to an Array

- .any, .all, and .none on Set and Array can be
    called without a block, like map

- Block: new constants, IDENTITY and LIST_IDENTITY
    which return their argument or arguments,
    respectively, to lessen runtime overhead for
    these tiny but common callables.

User code can construct these with Block.identity
    and Block.list_identity.

- Array: use the IDENTITY block if a method that
    wants a block, wasn't called with one.
    This eliminates some runtime overhead for
    nested loops, and cleans up the code with
    fewer immediate anonymous subs that can
    introduce typos.

- add the Hash.linear_selection method, which
    creates a Hash that is a subset of a hash,
    given an iterable argument of keys

- linear_selection, useful on its own, is used
    to implement Set-like operations on Hashes,
    with Sets, Hashes, Arrays, and other iterables
    on the RHS.

- Now it's possible to intersect, difference,
    union and symdiff Hashes with other objects.
    These operate primarily on the Hashes' keys.

- Last, Set.difference is extended to allow a
    Hash on the RHS, for subtracting a Hash's
    keys from a Set without needing to iterate
    it twice.
@trizen trizen merged commit 8fd5591 into trizen:master Mar 26, 2019
@trizen
Copy link
Owner

trizen commented Mar 26, 2019

Good work! Thanks!

@catb0t catb0t deleted the iter-mth branch March 26, 2019 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants