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

FIND /same option #1720

Closed
Siskin-Bot opened this issue Feb 15, 2020 · 0 comments
Closed

FIND /same option #1720

Siskin-Bot opened this issue Feb 15, 2020 · 0 comments
Labels
Oldes.resolved Bugs/wishes with Oldes' fixes/features Red compatibility Issues and changes required for compatibility with Red language Test.written Type.wish

Comments

@Siskin-Bot
Copy link
Collaborator

Siskin-Bot commented Feb 15, 2020

Submitted by: BrianH

The /same option would search for the SAME? value in a block-like series, rather than an equivalent value. For other types that FIND applies to, /same would be a noop because the equivalence tested is the same one used by SAME? already. This should be even faster than a normal FIND.

This request is partly in response to #1708.

; Example code:
find/same b :val

; Equivalent code:
forall b [if same? :val first b [break/return b]]


Imported from: CureCode [ Version: alpha 109 Type: Wish Platform: All Category: Native Reproduce: Always Fixed-in:none ]
Imported from: metaeducation#1720

Comments:

Rebolbot commented on Oct 26, 2010:

Submitted by: maxim

YESSSS

I've had to make this using a looped find and same?

  • it is orders of magnitude faster on searches, when items from a dataset have to be searched in said dataset. example, to get the new index after some sorting algorithm, or to get a row from a db search when your criteria is the result of a query in that database.

  • its also useful in GUIs to determine selection from a list which has several times the same text but from different sources.


Rebolbot commented on Oct 26, 2010:

Submitted by: maxim

this is much faster than above example

until [either (same? pick (r: find blk :val) 1 :val) [r][not blk: :r]]

Rebolbot commented on Oct 26, 2010:

Submitted by: BrianH

That would not be faster for blocks that contain a lot of references to equivalent but not the same object/module/block/whatever as the value you are looking for. The FIND does a full EQUAL?-style comparison, and enough of those add up quickly. SAME? is much faster than EQUAL?.


Rebolbot commented on Nov 2, 2010:

Submitted by: maxim

I know SAME? is faster, but going through REBOL loops was soo much slower than FIND that except for that specific case you gave, it was several hundred times faster in most cases, the larger the series, the bigger the difference.

having FIND/SAME would make that several times faster on ALL datatypes, which is why I'd be really happy for this wish to be granted. :-)


Rebolbot added the Type.wish on Jan 12, 2016


Oldes added a commit to Oldes/Rebol3 that referenced this issue Oct 13, 2020
@Oldes Oldes added Oldes.resolved Bugs/wishes with Oldes' fixes/features Test.written Red compatibility Issues and changes required for compatibility with Red language labels Oct 13, 2020
@Oldes Oldes closed this as completed Nov 22, 2020
Oldes added a commit to Oldes/Rebol3 that referenced this issue Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Oldes.resolved Bugs/wishes with Oldes' fixes/features Red compatibility Issues and changes required for compatibility with Red language Test.written Type.wish
Projects
None yet
Development

No branches or pull requests

2 participants