uiua-lang / uiua

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

Strange `indexof` behavior #540

Closed langfield closed 2 months ago

langfield commented 2 months ago

In the documentation, there is the following example.

> ⊗ 2 [1_2_3 4_5_6]
[1 3]

If the index cannot be found, the ⧻ length of the searched-in array is returned.

It appears not to conform to this description of behavior. Is this something undocumented, or a bug, or am I misunderstanding something?

PieVieRo commented 2 months ago

nah its correct it's a 2-dimensional array

[1 2 3]
[4 5 6]

and the function is applied to every row of the array individually the first element is 1 because 2 is in the second position (index 1) the second element is 3 because 2 isn't found in the second row, so it returned its length (3 elements)

langfield commented 2 months ago

Ah thanks very much, apologies for polluting your issue tracker.


From: PieVieRo @.> Sent: Friday, August 30, 2024 1:25 PM To: uiua-lang/uiua @.> Cc: langfield @.>; Author @.> Subject: Re: [uiua-lang/uiua] Strange indexof behavior (Issue #540)

nah its correct it's a 2-dimensional array [1 2 3] [4 5 6] and the function is applied to every row of the array individually the first element is 1 because 2 is in the second position (index 1) the second element is 3 because 2 isn't found

nah its correct it's a 2-dimensional array

[1 2 3] [4 5 6]

and the function is applied to every row of the array individually the first element is 1 because 2 is in the second position (index 1) the second element is 3 because 2 isn't found in the second row, so it returned it's length (3 elements)

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/uiua-lang/uiua/issues/540*issuecomment-2322024178__;Iw!!KGKeukY!yMMIuvLx__EbVh3o7nAodjPaSpyupzzvCPewjpZGxDfZ97xma6m5qqk0bCcomcZJow3AV8hjRYbCIHwsuFb1lygsiJlSnA$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNIZ5JQTGI3NKBDIKISDZUCTIRAVCNFSM6AAAAABNMVH2P2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRSGAZDIMJXHA__;!!KGKeukY!yMMIuvLx__EbVh3o7nAodjPaSpyupzzvCPewjpZGxDfZ97xma6m5qqk0bCcomcZJow3AV8hjRYbCIHwsuFb1lyhwaEFUdg$. You are receiving this because you authored the thread.Message ID: @.***>