adam12 changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.0.2, 2.7.4, 2.6.8: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
darkstardev13 has joined #ruby
darkstarx has quit [Ping timeout: 260 seconds]
<nakilon> I don't like two things: 1. that it's downto, not down_to 2. that NilClass#to_i is 0 not exception
brw has quit [Quit: The Lounge - https://thelounge.chat]
<weaksauce> the nil thing is weird
<weaksauce> wonder why
brw has joined #ruby
brw has quit [Client Quit]
brw has joined #ruby
vit has quit [Ping timeout: 256 seconds]
<nakilon> it causes a bug that you don't notice the Nil that has to be treated properly
<nakilon> related to the more common of problem of bad practice to silent the nil
<nakilon> two days ago it resulted for me in calculating the mean value of an array of numbers incorrectly because I didn't notice I had to apply .compact before that
<nakilon> nils worked like 0 that was not intended
<weaksauce> ouch
darkstarx has joined #ruby
darkstardev13 has quit [Ping timeout: 256 seconds]
darkstarx has quit [Remote host closed the connection]
darkstarx has joined #ruby
Inline has quit [Ping timeout: 245 seconds]
lunarkitty has quit [Quit: Connection closed for inactivity]
Tempesta has quit [Quit: See ya!]
pwnd_sfw has quit [Quit: Ping timeout (120 seconds)]
pwnd_sfw has joined #ruby
danielsousaio has quit [Remote host closed the connection]
Tempesta has joined #ruby
Tempesta has quit [Excess Flood]
Tempesta has joined #ruby
Tempesta has quit [Changing host]
Tempesta has joined #ruby
Tempesta has quit [Excess Flood]
Tempesta has joined #ruby
Tempesta has quit [Changing host]
Tempesta has joined #ruby
Tempesta has quit [Excess Flood]
hansolo has joined #ruby
Tempesta has joined #ruby
Tempesta has quit [Changing host]
Tempesta has joined #ruby
Tempesta has quit [Excess Flood]
Tempesta has joined #ruby
Tempesta has quit [Changing host]
Tempesta has joined #ruby
Tempesta has quit [Excess Flood]
jpw has joined #ruby
ua_ has quit [Excess Flood]
ua_ has joined #ruby
hansolo has quit [Remote host closed the connection]
hansolo has joined #ruby
hansolo has quit [Remote host closed the connection]
hansolo has joined #ruby
hansolo has quit [Remote host closed the connection]
hansolo has joined #ruby
hansolo has quit [Remote host closed the connection]
hansolo has joined #ruby
dohtem has quit [Quit: Connection closed for inactivity]
supernova has joined #ruby
TzilTzal has joined #ruby
uberlinux has joined #ruby
uberlinux has quit [Remote host closed the connection]
lunarkitty has joined #ruby
TzilTzal has quit []
<ox1eef_> nil is beautiful, embrace nil and be aware of it at all times :)
menace has joined #ruby
menace has quit [Changing host]
menace has joined #ruby
justUnited has quit [Remote host closed the connection]
justUnited has joined #ruby
jpw has quit [Remote host closed the connection]
vit has joined #ruby
Tempesta has joined #ruby
Tempesta has quit [Excess Flood]
Tempesta has joined #ruby
Tempesta has quit [Changing host]
Tempesta has joined #ruby
Tempesta has quit [Excess Flood]
gr33n7007h has quit [Ping timeout: 256 seconds]
robotmay has joined #ruby
hololeap has quit [Remote host closed the connection]
hololeap has joined #ruby
tempate has joined #ruby
<tempate> Is there a way to reserve space on a ruby list?
Rounin has joined #ruby
fef has joined #ruby
lunarkitty has quit [Quit: Connection closed for inactivity]
_ht has joined #ruby
<ccooke> tempate: you can tell Ruby you want an array to be predeclared at a particular size - Array.new(n) will return a new array of size n (with every value returning nil). You can pass a default object or a default proc to generate default values if you wish
<ccooke> You can also use Array#
<ccooke> fill to fill in values
<tempate> but I don't want it to fill it with values
<tempate> I just want it not to resize it every time I push
<tempate> The equivalent of vector::reserve in c++
<ccooke> That's not possible with push. Array.push is defined in terms of resizing the array.
<ccooke> You would need to use different methods to get the effect you want
unmanbearpig has quit [Ping timeout: 268 seconds]
<ccooke> Why are you worrying about the array being resized?
<tempate> I'm just trying to improve my implementation of https://bpa.st/3GGA
unmanbearpig has joined #ruby
<tempate> I haven't done any Ruby for over a year so I'm a little rusty
<ccooke> Okay. So, assuming you have actually found that the array code is the bottleneck for you - and assuming that you know a maximum size for the array, you can trade space efficiency for a bit of speed. First, determine the maximum size the array could be. Then, use a variable to point to the current entry. Write your own version of push and pop that increment and decrement that variable (and preferably throw an
<ccooke> exception if they try to access out of bounds) and use them with an Array you have predefined to the maximum size
<ccooke> your access would then be something like 'arrayvar[pointer = pointer + 1] = value_to_push' and 'old_pointer = pointer; pointer -= 1; arrayvar[old_pointer]' to pop. Again, preferably with some bounds checking, because this way is much less safe.
<tempate> Alright
<tempate> This sounds like way too much, frankly
<tempate> I don't think it'll make that much of a difference anyway
<ccooke> (But I'd receommend doing some actual benchmarking first.
<tempate> Would you improve anything else Ruby wise?
<ccooke> there are better methods of testing for primeness, tbh
<tempate> Shoot
<tempate> I'm also interested from a Ruby perspective. There are so many methods that I never know if there's a method that just does what I'm implementing.
supernova has quit [Quit: No Ping reply in 180 seconds.]
supernova has joined #ruby
leonthemisfit has joined #ruby
leonthemisfit has quit [Changing host]
leonthemisfit has joined #ruby
reset has quit [Quit: reset]
supernova has quit [Ping timeout: 245 seconds]
tempate has quit [Quit: Leaving.]
supernova has joined #ruby
tempate has joined #ruby
tempate has quit [Quit: Leaving.]
_ht has quit [Ping timeout: 256 seconds]
_ht_ has joined #ruby
Pixi_ has joined #ruby
Pixi__ has joined #ruby
Pixi has quit [Ping timeout: 264 seconds]
Pixi_ has quit [Ping timeout: 256 seconds]
postmodern has joined #ruby
Inline has joined #ruby
Inline has quit [Quit: Leaving]
Inline has joined #ruby
_ht_ has quit [Ping timeout: 245 seconds]
_ht has joined #ruby
jpw has joined #ruby
<havenwood> I agree filling with `nil` would be the way for Arrays. Interestingly, String has the `:capacity` keyword.
<havenwood> String.new(capacity: 42_000_000)
menace has quit [Remote host closed the connection]
menace has joined #ruby
postmodern has quit [Quit: Leaving]
menace has quit [Changing host]
menace has joined #ruby
justUnited is now known as justCity
gr33n7007h has joined #ruby
Tempesta has joined #ruby
Tempesta has quit [Excess Flood]
goldfish has joined #ruby
goldfish has quit [Remote host closed the connection]
goldfish has joined #ruby
hololeap has quit [Remote host closed the connection]
hololeap has joined #ruby
tkonto has joined #ruby
dohtem has joined #ruby
Inline has quit [Remote host closed the connection]
Inline has joined #ruby
horribleprogram has joined #ruby
tkonto has quit [Quit: tkonto]
fercell has quit [Ping timeout: 268 seconds]
ferr_ has joined #ruby
Inline has quit [Read error: Connection reset by peer]
g0zart has joined #ruby
Inline has joined #ruby
Inline has quit [Read error: Connection reset by peer]
Inline_ has joined #ruby
Inline_ has quit [Remote host closed the connection]
goldfish_ has joined #ruby
goldfish has quit [Remote host closed the connection]
Inline has joined #ruby
Papa_ has joined #ruby
bandit_za has joined #ruby
bandit_za has left #ruby [#ruby]
ur5us has joined #ruby
hololeap has quit [Remote host closed the connection]
hololeap has joined #ruby
kaivai has quit [Quit: ZNC - https://znc.in]
kaivai has joined #ruby
menace has quit [Remote host closed the connection]
menace has joined #ruby
ur5us has quit [Ping timeout: 244 seconds]
menace has quit [Remote host closed the connection]
menace has joined #ruby
Inline has quit [Remote host closed the connection]
Inline has joined #ruby
Inline_ has joined #ruby
Inline_ has quit [Remote host closed the connection]
Inline_ has joined #ruby
zacts has joined #ruby
Inline has quit [Ping timeout: 268 seconds]
zacts has quit [Quit: leaving]
fef has quit [Ping timeout: 276 seconds]
g0zart has quit [Quit: Leaving]
horribleprogram has quit [Remote host closed the connection]
menace has quit [Quit: menace]
kaivai has quit [Quit: ZNC - https://znc.in]
reset has joined #ruby
kaivai has joined #ruby
hololeap has quit [Remote host closed the connection]
hololeap has joined #ruby
lunarkitty has joined #ruby
supernova has quit [Ping timeout: 245 seconds]
jpw has quit [Remote host closed the connection]
ua_ has quit [Ping timeout: 256 seconds]
ur5us has joined #ruby
ua_ has joined #ruby
tempate has joined #ruby
dohtem has quit [Quit: Connection closed for inactivity]
_ht has quit [Remote host closed the connection]
Inline_ is now known as Inline
tempate has quit [Quit: Leaving.]
supernova has joined #ruby
supernova has quit [Ping timeout: 245 seconds]
lunarkitty has quit [Quit: Connection closed for inactivity]
dohtem has joined #ruby
vit has quit [Ping timeout: 260 seconds]