uiua-lang / uiua

A stack-based array programming language
https://www.uiua.org
MIT License
1.59k stars 116 forks source link

Add style warning, or interpreter optimization, for `first select` #377

Closed bkDJ closed 9 months ago

bkDJ commented 9 months ago

I've seen some uiua videos on YouTube where people do the sort idiom select rise dup, but they only want the first item so they follow up with first. What do you think about prodding them in the right direction with a style guideline, or having the interpreter perform the fastest possible calculation for a given end result.

Values ← ⌊×1e9 [⍥⚂1e6]

⍜now(⊢⊏⍖.) Values
⍜now(⊡⊢⍖.) Values
⍜now(/↥) Values

The time difference is 2 orders of magnitude apart.

kaikalii commented 9 months ago

This has been added in 563d98bb94b86b0cd9f3.