codereport / jsource

J Language Source Code. Livestream links ⬇️
https://www.youtube.com/playlist?list=PLVFrD1dmDdvfVhYLU_iKkV67X9XqCJLWe
Other
38 stars 20 forks source link

Code example for first 10 odd numbers on APL is incorrect #206

Closed herwinw closed 3 years ago

herwinw commented 3 years ago

It looks like in APL starts at 1 instead of 0, the code snippet linked in the readme generates the sequence, 3, 5 .. 21

juntuu commented 3 years ago

I think it just assumes index origin to be set to zero.

      ⎕IO←0
      ⍳4
0 1 2 3
herwinw commented 3 years ago

I tried the Runnable link from the README, that iota is 1-indexed for me. I'm not sure whether that's a global default, or it saves something in cookies which causes the result to differ depending on that.

juntuu commented 3 years ago

Since TryAPL has index origin 1 by default, some possible fixes would be:

codereport commented 3 years ago

We decided to go with ¯1+2×⍳10. Thanks for pointing this out.