Serpent7776

@Serpent7776@programming.dev

This profile is from a federated server and may be incomplete. Browse more on the original instance.

Index arrays with ordinals instead of integers with custom literals (programming.dev)

I did a code that uses custom literals to allow indexing arrays with ordinals (1st, 2nd, 3rd), all at compile time. Additionally _st works only with 1, _nd only with 2, _rd only with 3. Zero and negative numbers are also not supported and fail compilation....

Serpent7776,

There’s no purpose really. It was more of “wonder if I can” and also nice way to learn custom literals.

Serpent7776,

Yeah, that was basically it.

Serpent7776,

It should be easy to edit the existing code to add support for i18n, but there’s probably no way to make in generic (except for macros).

Serpent7776,

I can actually define this in TCL:


<span style="color:#323232;">% proc ifn't {cond cmds} {if {!$cond} {uplevel $cmds}}
</span><span style="color:#323232;">% ifn't false {puts </span><span style="color:#0086b3;">12</span><span style="color:#323232;">}
</span><span style="color:#323232;">12
</span><span style="color:#323232;">% ifn't true {puts </span><span style="color:#0086b3;">12</span><span style="color:#323232;">}
</span><span style="color:#323232;">% 
</span>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • rosin
  • mdbf
  • osvaldo12
  • ethstaker
  • tacticalgear
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • modclub
  • Youngstown
  • everett
  • slotface
  • kavyap
  • JUstTest
  • GTA5RPClips
  • khanakhh
  • cisconetworking
  • tester
  • ngwrru68w68
  • normalnudes
  • Durango
  • InstantRegret
  • cubers
  • megavids
  • Leos
  • anitta
  • lostlight
  • All magazines