{ 1 } [ { 1 7 3 7 6 3 7 } arg-max ] unit-test
{ 0 } [ { 1 7 3 7 6 3 7 } arg-min ] unit-test
+
+{ t } [ { 1 2 3 4 5 } 1 first= ] unit-test
+{ t } [ { 1 2 3 4 5 } 2 second= ] unit-test
+{ t } [ { 1 2 3 4 5 } 3 third= ] unit-test
+{ t } [ { 1 2 3 4 5 } 4 fourth= ] unit-test
+{ t } [ { 1 2 3 4 5 } 5 last= ] unit-test
+{ t } [ 4 { 1 2 3 4 5 } 5 nth= ] unit-test
+
+{ t } [ { 1 2 3 4 5 } [ 1 = ] first? ] unit-test
+{ t } [ { 1 2 3 4 5 } [ 2 = ] second? ] unit-test
+{ t } [ { 1 2 3 4 5 } [ 3 = ] third? ] unit-test
+{ t } [ { 1 2 3 4 5 } [ 4 = ] fourth? ] unit-test
+{ t } [ { 1 2 3 4 5 } [ 5 = ] last? ] unit-test
+{ t } [ 4 { 1 2 3 4 5 } [ 5 = ] nth? ] unit-test
: arg-where ( ... seq quot: ( ... elt -- ... ? ) -- ... indices )
[ dup length iota zip ] dip
[ first-unsafe ] prepose filter values ; inline
+
+: first= ( seq elt -- ? ) [ first ] dip = ; inline
+: second= ( seq elt -- ? ) [ second ] dip = ; inline
+: third= ( seq elt -- ? ) [ third ] dip = ; inline
+: fourth= ( seq elt -- ? ) [ fourth ] dip = ; inline
+: last= ( seq elt -- ? ) [ last ] dip = ; inline
+: nth= ( n seq elt -- ? ) [ nth ] dip = ; inline
+
+: first? ( seq quot -- ? ) [ first ] dip call ; inline
+: second? ( seq quot -- ? ) [ second ] dip call ; inline
+: third? ( seq quot -- ? ) [ third ] dip call ; inline
+: fourth? ( seq quot -- ? ) [ fourth ] dip call ; inline
+: last? ( seq quot -- ? ) [ last ] dip call ; inline
+: nth? ( n seq quot -- ? ) [ nth ] dip call ; inline