maris@lemmy.world to Programmer Humor@programming.dev · 2 个月前Gambling with Lainlemmy.worldimagemessage-square31linkfedilinkarrow-up1353arrow-down111
arrow-up1342arrow-down1imageGambling with Lainlemmy.worldmaris@lemmy.world to Programmer Humor@programming.dev · 2 个月前message-square31linkfedilink
minus-squareChaoticNeutralCzech@feddit.orglinkfedilinkEnglisharrow-up12·2 个月前The chance is actually 1 in 7 because both 0 and 6 are included in the randInt() range.
minus-squarer00ty@kbin.lifelinkfedilinkarrow-up5·2 个月前Oh right. I thought it might work the same as range etc in python, where is does one less than you specify… Coming from, well every other language this really threw me off on my first python excursion.
minus-squareChaoticNeutralCzech@feddit.orglinkfedilinkEnglisharrow-up1·2 个月前Any language… except MATLAB. Fuck MATLAB. (Their arrays even start at 1, what the fuck?!)
minus-squarewheezy@lemmy.mllinkfedilinkarrow-up2arrow-down1·2 个月前Lua starts at 1 too. It’s infuriating. I believe for the same historical reason Matlab does. Both meant for non CS people.
minus-squareshape_warrior_t@programming.devlinkfedilinkEnglisharrow-up1·2 个月前You can get the exclusive behaviour with random.randrange. (Relevant Stack Overflow question with a somewhat interesting answer)
The chance is actually 1 in 7 because both 0 and 6 are included in the
randInt()
range.Oh right. I thought it might work the same as range etc in python, where is does one less than you specify… Coming from, well every other language this really threw me off on my first python excursion.
Any language… except MATLAB. Fuck MATLAB.
(Their arrays even start at 1, what the fuck?!)
Lua starts at 1 too. It’s infuriating. I believe for the same historical reason Matlab does.
Both meant for non CS people.
You can get the exclusive behaviour with
random.randrange
. (Relevant Stack Overflow question with a somewhat interesting answer)