Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Reduce over the range [1..n]

BQN, 8 bytes {𝔽´1+↕𝕩} Try it! basic fold builtin version. Use as a dyadic 1-modifier. Longer than APL since evaluated output is shorter than using first class functions. A more fun recursive...

posted 2y ago by Razetime‭  ·  edited 2y ago by Razetime‭

Answer
#3: Post edited by user avatar Razetime‭ · 2021-08-11T12:48:31Z (over 2 years ago)
  • # [BQN](https://mlochbaum.github.io/BQN/), 8 bytes
  • ```
  • {𝔽´1+↕𝕩}
  • ```
  • [Try it!](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7MfCdlL17KPCdlajwnZS94oqR8J2VqSkoMTziiaDwnZWpKeKXtuKKo+KAv/CdlYox4oaT8J2VqX0xKzHihpPihpXwnZWpfQoKCgoK4p+oK19mIDUKLV9mIDUKw5dfZiA14p+p)
  • basic fold builtin version. Use as a dyadic 1-modifier.
  • Longer than APL since evaluated output is shorter than using first class functions.
  • A more fun recursive implementation without fold:
  • ```
  • {1𝔽{(π•¨π”½βŠ‘π•©)(1<≠𝕩)β—ΆβŠ£β€Ώπ•Š1↓𝕩}1+1↓↕𝕩}
  • ```
  • A previous(wrong) version of this exposed a bug which prevented the program from erroring [here](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7RuKGkPCdlL3ii4QxeyjwnZWoRuKKj/CdlakpKMOX4omg8J2VqSnil7bwnZWO4oC/8J2VijHihpPwnZWpfTErMeKGk+KGlfCdlal9CgoKK19nIDU=).
  • # [BQN](https://mlochbaum.github.io/BQN/), 8 bytes
  • ```
  • {𝔽´1+↕𝕩}
  • ```
  • [Try it!](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7MfCdlL17KPCdlajwnZS94oqR8J2VqSkoMTziiaDwnZWpKeKXtuKKo+KAv/CdlYox4oaT8J2VqX0xKzHihpPihpXwnZWpfQoKCgoK4p+oK19mIDUKLV9mIDUKw5dfZiA14p+p)
  • basic fold builtin version. Use as a dyadic 1-modifier.
  • Longer than APL since evaluated output is shorter than using first class functions.
  • A more fun recursive implementation without fold:
  • ```
  • {1𝔽{(π•¨π”½βŠ‘π•©)(1<≠𝕩)β—ΆβŠ£β€Ώπ•Š1↓𝕩}1+1↓↕𝕩}
  • ```
  • <del>A previous(wrong) version of this exposed a bug which prevented the program from erroring [here](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7RuKGkPCdlL3ii4QxeyjwnZWoRuKKj/CdlakpKMOX4omg8J2VqSnil7bwnZWO4oC/8J2VijHihpPwnZWpfTErMeKGk+KGlfCdlal9CgoKK19nIDU=).</del>
  • **EDIT:** [the bug is fixed!](https://github.com/mlochbaum/BQN/commit/a08a343e20ef6c848ce2ea89dc70cbeca72c766d)
#2: Post edited by user avatar Razetime‭ · 2021-08-11T12:17:08Z (over 2 years ago)
  • # [BQN](https://mlochbaum.github.io/BQN/), 8 bytes
  • ```
  • {𝔽´1+↕𝕩}
  • ```
  • [Try it!](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7MfCdlL17KPCdlajwnZS94oqR8J2VqSkoMTziiaDwnZWpKeKXtuKKo+KAv/CdlYox4oaT8J2VqX0xKzHihpPihpXwnZWpfQoKCgoK4p+oK19mIDUKLV9mIDUKw5dfZiA14p+p)
  • basic fold builtin version. Use as a dyadic 1-modifier.
  • Longer than APL since evaluated output is shorter than using first class functions.
  • A more fun recursive implementation without fold:
  • ```
  • {1𝔽{(π•¨π”½βŠ‘π•©)(1<≠𝕩)β—ΆβŠ£β€Ώπ•Š1↓𝕩}1+1↓↕𝕩}
  • ```
  • A previous(wrong) version of this had a bug which prevented the program from erroring [here](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7RuKGkPCdlL3ii4QxeyjwnZWoRuKKj/CdlakpKMOX4omg8J2VqSnil7bwnZWO4oC/8J2VijHihpPwnZWpfTErMeKGk+KGlfCdlal9CgoKK19nIDU=).
  • # [BQN](https://mlochbaum.github.io/BQN/), 8 bytes
  • ```
  • {𝔽´1+↕𝕩}
  • ```
  • [Try it!](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7MfCdlL17KPCdlajwnZS94oqR8J2VqSkoMTziiaDwnZWpKeKXtuKKo+KAv/CdlYox4oaT8J2VqX0xKzHihpPihpXwnZWpfQoKCgoK4p+oK19mIDUKLV9mIDUKw5dfZiA14p+p)
  • basic fold builtin version. Use as a dyadic 1-modifier.
  • Longer than APL since evaluated output is shorter than using first class functions.
  • A more fun recursive implementation without fold:
  • ```
  • {1𝔽{(π•¨π”½βŠ‘π•©)(1<≠𝕩)β—ΆβŠ£β€Ώπ•Š1↓𝕩}1+1↓↕𝕩}
  • ```
  • A previous(wrong) version of this exposed a bug which prevented the program from erroring [here](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7RuKGkPCdlL3ii4QxeyjwnZWoRuKKj/CdlakpKMOX4omg8J2VqSnil7bwnZWO4oC/8J2VijHihpPwnZWpfTErMeKGk+KGlfCdlal9CgoKK19nIDU=).
#1: Initial revision by user avatar Razetime‭ · 2021-08-11T12:16:55Z (over 2 years ago)
# [BQN](https://mlochbaum.github.io/BQN/), 8 bytes
```
{𝔽´1+↕𝕩}
```

[Try it!](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7MfCdlL17KPCdlajwnZS94oqR8J2VqSkoMTziiaDwnZWpKeKXtuKKo+KAv/CdlYox4oaT8J2VqX0xKzHihpPihpXwnZWpfQoKCgoK4p+oK19mIDUKLV9mIDUKw5dfZiA14p+p)

basic fold builtin version. Use as a dyadic 1-modifier.

Longer than APL since evaluated output is shorter than using first class functions.

A more fun recursive implementation without fold:

```
{1𝔽{(π•¨π”½βŠ‘π•©)(1<≠𝕩)β—ΆβŠ£β€Ώπ•Š1↓𝕩}1+1↓↕𝕩}
```

A previous(wrong) version of this had a bug which prevented the program from erroring [here](https://mlochbaum.github.io/BQN/try.html#code=X2bihpB78J2UvcK0MSvihpXwnZWpfQoKX2fihpB7RuKGkPCdlL3ii4QxeyjwnZWoRuKKj/CdlakpKMOX4omg8J2VqSnil7bwnZWO4oC/8J2VijHihpPwnZWpfTErMeKGk+KGlfCdlal9CgoKK19nIDU=).