Skip to main content
added 593 characters in body
Source Link
Jeff Zeitlin
  • 469
  • 1
  • 3
  • 11

SECOND GOLFING (my own discovery):

APL (Dyalog Unicode), 63 bytes

f←{⍵↑⊃,/1,¨⌽¨1,¨2⍴⍨¨1+2×1-⍨⍳1+⌈⍟⍵}

Try it online!

Explanation of golfing: The expression that was formerly subscripted does not need to be parenthesized if using ⍵↑ instead of [⍳⍵]. Savings, 2bytes.

SECOND GOLFING (my own discovery):

APL (Dyalog Unicode), 63 bytes

f←{⍵↑⊃,/1,¨⌽¨1,¨2⍴⍨¨1+2×1-⍨⍳1+⌈⍟⍵}

Try it online!

Explanation of golfing: The expression that was formerly subscripted does not need to be parenthesized if using ⍵↑ instead of [⍳⍵]. Savings, 2bytes.

added 3 characters in body
Source Link
RGS
  • 14.1k
  • 1
  • 57
  • 116

This answer returns the entire sequence up to the requested value.

This answer returns the entire sequence to the requested value.

This answer returns the entire sequence up to the requested value.

added 685 characters in body
Source Link
Jeff Zeitlin
  • 469
  • 1
  • 3
  • 11

FIRST GOLFING (courtesy ngn):

APL (Dyalog Unicode), 65 bytes

f←{⍵↑(⊃,/1,¨⌽¨1,¨2⍴⍨¨1+2×1-⍨⍳1+⌈⍟⍵)}

Try it online!

Explanation of golfing:

[⍳⍵] is the same as [1 2 3 4 5 6 ... ⍵], 
      which is the first ⍵ items of the vector being subscripted.
      That's the same as 
⍵↑    "Take" the first ⍵ items.  Savings, 2bytes.

FIRST GOLFING (courtesy ngn):

APL (Dyalog Unicode), 65 bytes

f←{⍵↑(⊃,/1,¨⌽¨1,¨2⍴⍨¨1+2×1-⍨⍳1+⌈⍟⍵)}

Try it online!

Explanation of golfing:

[⍳⍵] is the same as [1 2 3 4 5 6 ... ⍵], 
      which is the first ⍵ items of the vector being subscripted.
      That's the same as 
⍵↑    "Take" the first ⍵ items.  Savings, 2bytes.
Source Link
Jeff Zeitlin
  • 469
  • 1
  • 3
  • 11
Loading