<evdubs>
t0xik, depending on what you're doing (like processing a list of elements), it might be "better code style" to use things like filter (called select in ruby), map, and, reduce
m27frogy has joined #ruby
m27frogy has quit [Read error: Connection reset by peer]
Synthead has quit [Ping timeout: 244 seconds]
m27frogy has joined #ruby
braincrash has quit [Quit: bye bye]
<t0xik>
evdubs: thx!
<t0xik>
i knew there had to be a continue equivalent
<t0xik>
too bad we cant break out of a large nested set of loops with a "goto label;" which fair warning is the only reason to use goto's
braincrash has joined #ruby
<evdubs>
curiously, what's your use case for large nested loops?
laaron- has joined #ruby
laaron has quit [Remote host closed the connection]
<baweaver>
^ that. It's called the XY problem, you want a specific solution and fixate on that when another solution may be available t0xik
<t0xik>
evdubs: its a normal thing todo in the c language, which was my first language.
xco has quit [Quit: xco]
<t0xik>
using a goto , to exit a set of loops without having to break through each one
<t0xik>
its rare but , i was just curious. as i was reading "book of ruby"
<baweaver>
Most of the time you use methods from Enumerable
<baweaver>
Name a use case from C where you would use a goto and we can show you a method from Ruby to do the same
<t0xik>
i just gave your a use case...
<havenwood>
?xkcd 292
<ruby[bot]>
havenwood: I don't see no 292, whom should I tell about xkcd?
<mnemon>
it's definitely faster than doing it in ruby
<ryouba>
hmm
<ryouba>
interesting
<ryouba>
*shrug*, then
conta has joined #ruby
renich_ has joined #ruby
cnsvc has joined #ruby
Swyper has quit [Remote host closed the connection]
renich has quit [Ping timeout: 255 seconds]
<adam12>
ryouba: One of the answers (the one that calls f.getc) is _kinda_ similar to the C implementation (at least the FreeBSD one https://github.com/freebsd/freebsd/blob/master/usr.bin/wc/wc.c). You could benchmark them and see which perform better.
lxsameer has quit [Ping timeout: 245 seconds]
_joes_ has joined #ruby
<havenwood>
ryouba: parallel with wc would be faster yet for that particular problem, or hadoop even
Synthead has joined #ruby
<havenwood>
ryouba: it's pretty fast to just: File.open(filename).sum { 1 }
<havenwood>
ryouba: it's not going to beat a multi-process, tailored approach - if speed is essential
<adam12>
havenwood: nice trick with sum { 1 }.
<havenwood>
adam12: tyty!
<havenwood>
adam12: i felt a little guilty about not closing the file ;)
<ryouba>
havenwood: i didn't understand ... "parallel with wc"?
<al2o3-cr>
i conclude this is the fastest: File.read(foo).each_line.count
za1b1tsu has joined #ruby
<ytti>
i belive that'll read entire file to memory
<al2o3-cr>
anyway `wc -l` from ruby will damn slow.
Synthead has quit [Remote host closed the connection]
<ytti>
it offends my aesthethics too
clemens3 has quit [Ping timeout: 250 seconds]
gix has joined #ruby
grilix has quit [Ping timeout: 246 seconds]
grilix has joined #ruby
cnsvc has quit [Remote host closed the connection]
crankharder has joined #ruby
cow[moo] has joined #ruby
conta has quit [Quit: conta]
Devalo has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
aupadhye has quit [Ping timeout: 250 seconds]
htc^ has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
orbyt_ has joined #ruby
livcd has quit [Ping timeout: 250 seconds]
mostlybadfly has quit [Quit: Connection closed for inactivity]
GreyHame has joined #ruby
<graft>
wc -l from ruby will almost definitely be faster than anything involving ruby reading and scanning strings
GreyHame has quit [Client Quit]
<graft>
in fact i would place money on it without doing any research
aupadhye has joined #ruby
<baweaver>
It is, by about 10x graft
<baweaver>
I was curious so I looked.
sauvin has quit [Remote host closed the connection]
<baweaver>
I kinda wonder if that holds up in TruffleRuby
<baweaver>
havenwood: `wc -l` vs `File.open(...).foreach.count` in TruffleRuby?
<baweaver>
Don't have it installed on the work computer, should probably fix that
agent_white has joined #ruby
<adam12>
Anyone seen a way to simulate ARGF? (single stream of endless File objects)
Devalo has quit [Remote host closed the connection]
Tempesta has quit [Quit: See ya!]
Devalo has joined #ruby
<adam12>
Actually nm. I thought it was lazy but ARGF.read just reads in everything.
agent_white has quit [Quit: brb]
mikecmpbll has joined #ruby
<al2o3-cr>
baweaver: prove it
<ryouba>
shouldn't CSV be capable of reading in lines that have all non-empty fields quoted with some of the fields containing newlines and the end of a row having a windows line-ending?
Devalo has quit [Ping timeout: 250 seconds]
<ryouba>
(it's giving "/usr/lib64/ruby/2.6.0/csv/parser.rb:273:in `parse': Do not allow except col_sep_split_separator after quoted fields in line 1. (CSV::MalformedCSVError)")
Devalo has joined #ruby
agent_white has joined #ruby
<al2o3-cr>
baweaver: ?
gell5 has joined #ruby
<al2o3-cr>
also, foreach on a file desc.
<al2o3-cr>
i want to see figures.
<al2o3-cr>
file obj*
claudiuinberlin has joined #ruby
<al2o3-cr>
wc -l is ~10x slower on my machine
crankharder has quit [Ping timeout: 245 seconds]
Tempesta has joined #ruby
<al2o3-cr>
we are talking about `` or %x() here yeah?
<al2o3-cr>
so creating a subshell and all.
<al2o3-cr>
graft: you anything to add?
<al2o3-cr>
and i'll bet you too! how much?
livcd has joined #ruby
cd has joined #ruby
mostlybadfly has joined #ruby
<al2o3-cr>
cd: /etc
zachk has quit [Changing host]
zachk has joined #ruby
livcd has quit [Ping timeout: 255 seconds]
brool has joined #ruby
RedSnarf has joined #ruby
aupadhye has quit [Ping timeout: 245 seconds]
lytol has joined #ruby
jmcgnh has quit [Excess Flood]
jmcgnh has joined #ruby
Devalo has quit [Remote host closed the connection]
Devalo has joined #ruby
AJA4350 has joined #ruby
aupadhye has joined #ruby
aupadhye has quit [Ping timeout: 268 seconds]
Devalo has quit [Remote host closed the connection]
Swyper has quit [Remote host closed the connection]
Devalo has joined #ruby
suukim has quit [Quit: Konversation terminated!]
Devalo has quit [Ping timeout: 244 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kyrylo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has quit [Ping timeout: 250 seconds]
orbyt_ has joined #ruby
AJA4350 has quit [Ping timeout: 246 seconds]
Tempesta has quit [Read error: Connection reset by peer]
Tempesta has joined #ruby
Tempesta has joined #ruby
Tempesta has quit [Changing host]
Ai9zO5AP has quit [Quit: WeeChat 2.4]
AJA4350 has joined #ruby
<al2o3-cr>
ryouba: ???????????????
cgfbee has quit [Ping timeout: 245 seconds]
crankharder has joined #ruby
cgfbee has joined #ruby
<al2o3-cr>
ryouba: Здравейте
za1b1tsu has quit [Remote host closed the connection]
<ryouba>
al2o3-cr: sorry, got called away from the computer
<ryouba>
al2o3-cr: and, hello!
<al2o3-cr>
np
i1nfusion has quit [Remote host closed the connection]
<ryouba>
Zarthus: there's two newlines, then the "missing" '"' is on the next line ... i think al2o3-cr saw it
Nicmavr has quit [Read error: Connection reset by peer]
i1nfusion has joined #ruby
livcd has joined #ruby
<Zarthus>
i always thought csv was newline delimited
<Zarthus>
fancy that
<ryouba>
al2o3-cr: that still gives "/usr/lib64/ruby/2.6.0/csv/parser.rb:276:in `parse': Unquoted fields do not allow \r or \n in line 3. (CSV::MalformedCSVError)"
Nicmavr has joined #ruby
<ryouba>
Zarthus: it's been years since i've seen something like this
<ryouba>
it *should* work ... i mean, libreoffice makes it work without effort
<Zarthus>
may the next case be many years from now too :)
<ryouba>
heck yeah
<ryouba>
this is the first time ruby's CSV library is letting me down
<Zarthus>
i would say throwing an exception is expected in this case ;)
<Zarthus>
just my personal opinion
Devalo has quit [Remote host closed the connection]
Devalo has joined #ruby
Devalo has quit [Remote host closed the connection]
Devalo has joined #ruby
ur5us has joined #ruby
Devalo has quit [Ping timeout: 244 seconds]
<ryouba>
hmm
<ryouba>
my personal opinion is that if libreoffice blows ruby out of the water something's not right
Devalo has joined #ruby
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
kyrylo has joined #ruby
mostlybadfly has quit [Quit: Connection closed for inactivity]
Swyper has joined #ruby
nucc has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Devalo has quit [Remote host closed the connection]
Deesl has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ryouba>
wow
<ryouba>
attitude or no attitude ... *his* shit works
livcd has quit [Ping timeout: 250 seconds]
bmurt has joined #ruby
polishdub has quit [Remote host closed the connection]
nowhere_man has joined #ruby
griffindy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
livcd has joined #ruby
Swyper has quit [Remote host closed the connection]
mostlybadfly has joined #ruby
al2o3-cr has joined #ruby
tdy has joined #ruby
Swyper has joined #ruby
spacesuitdiver has quit [Ping timeout: 245 seconds]
bambanx has joined #ruby
Swyper has quit [Ping timeout: 250 seconds]
_joes_ has quit [Ping timeout: 250 seconds]
renich_ has quit [Quit: renich_]
renich_ has joined #ruby
Devalo has joined #ruby
<ryouba>
gnight ruby
tau has quit [Quit: HAUEHAUHEA]
Devalo has quit [Ping timeout: 245 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
lido has quit [Ping timeout: 246 seconds]
spacesuitdiver has joined #ruby
clemens3 has quit [Ping timeout: 255 seconds]
cgfbee has quit [Ping timeout: 246 seconds]
ivanskie has joined #ruby
ur5us has joined #ruby
cgfbee has joined #ruby
zeroquake has joined #ruby
Fernando-Basso has quit [Remote host closed the connection]
<zeroquake>
Hey , i have hash like xyz = {:something : [1 , 2, 3, 4]} , if i want combine those values to a string "1234" , how can i do that without changing the value of xyz
k0mpa has joined #ruby
<baweaver>
&ri Enumerable#transform_values
<rubydoc>
Found no entry that matches class Enumerable instance method transform_values