<steveklabnik>
The list monad, in some sense, models computations which could return any number of values. Bind pumps values in, and catches all the values output. Such computations are known in computer science as nondeterministic. That is, a list [x,y,z] represents a value which is all of the values x, y, and z at once.
<steveklabnik>
is actually a pretty good summary
benanne has quit [Quit: kbai]
rfay has quit [Quit: This computer has gone to sleep]
mpan has quit [Read error: Connection reset by peer]
mpan has joined #ruby-lang
havenn has joined #ruby-lang
<oddmunds>
i am way to tired to make any sense of haskell right now
<steveklabnik>
:)
rfay has joined #ruby-lang
kain has quit [Read error: Operation timed out]
hgf has quit [Quit: hgf]
S1kx has quit [Ping timeout: 240 seconds]
Sambalero has joined #ruby-lang
<oddmunds>
i need to sleep. rue thanks for showing me what i needed rather than what i asked for. steveklabnik, thanks for depleting my mental batteries.
havenn has quit [Remote host closed the connection]
arooni-mobile has joined #ruby-lang
<steveklabnik>
:)
<steveklabnik>
goodnight!
arooni-mobile has quit [Ping timeout: 246 seconds]
hgf has joined #ruby-lang
Sambalero has quit [Remote host closed the connection]
lsegal has quit [Quit: Quit: Quit: Quit: Stack Overflow.]
kain has joined #ruby-lang
stardiviner has joined #ruby-lang
headius has joined #ruby-lang
headius has quit [Client Quit]
ledao has joined #ruby-lang
jtoy has joined #ruby-lang
hgf has quit [Quit: hgf]
kain has quit [Ping timeout: 252 seconds]
arooni-mobile has joined #ruby-lang
enebo has quit [Quit: enebo]
Madis has quit [Quit: ChatZilla 0.9.89 [Firefox 15.0/20120830123745]]
yats has quit [Read error: Connection reset by peer]
yats_ has joined #ruby-lang
goshakkk has joined #ruby-lang
kain has joined #ruby-lang
mistym has quit [Remote host closed the connection]
goshakkk has quit [Quit: Computer has gone to sleep.]
kain has quit [Ping timeout: 260 seconds]
lordnaz has joined #ruby-lang
lordnaz has quit [Client Quit]
sush24 has joined #ruby-lang
Nisstyre-laptop has quit [Read error: Connection reset by peer]
nariyal has joined #ruby-lang
piyush has quit [Ping timeout: 260 seconds]
kain has joined #ruby-lang
piyush has joined #ruby-lang
kain has quit [Ping timeout: 246 seconds]
workmad3 has joined #ruby-lang
rippa has joined #ruby-lang
ryanlecompte has joined #ruby-lang
voker57 has joined #ruby-lang
voker57 has quit [Changing host]
voker57 has joined #ruby-lang
__butch__ has joined #ruby-lang
yats__ has joined #ruby-lang
yats_ has quit [Read error: Connection reset by peer]
AlHafoudh has joined #ruby-lang
tRAS has quit [Ping timeout: 256 seconds]
justinmcp has joined #ruby-lang
wallerdev has quit [Quit: wallerdev]
kain has joined #ruby-lang
piyush has quit [Ping timeout: 246 seconds]
tRAS has joined #ruby-lang
kain has quit [Ping timeout: 248 seconds]
justinmcp has quit [Remote host closed the connection]
hakunin has quit [Remote host closed the connection]
hakunin has joined #ruby-lang
nariyal has quit [Ping timeout: 252 seconds]
hakunin has quit [Ping timeout: 260 seconds]
kain has joined #ruby-lang
Criztian has joined #ruby-lang
ryanlecompte has quit [Remote host closed the connection]
ryanlecompte has joined #ruby-lang
goshakkk has joined #ruby-lang
ryanlecompte has quit [Remote host closed the connection]
sush24 has quit [Quit: This computer has gone to sleep]
yats__ has quit [Read error: Connection reset by peer]
yats__ has joined #ruby-lang
OrganicCat has joined #ruby-lang
<OrganicCat>
When reading data from a flat file, how can I keep my memory footprint low? Read a chunk, close the file, then rinse and repeat?
workmad3 has quit [Ping timeout: 260 seconds]
undersc0re97 has quit [Quit: i use linux l o l]
woollyams has joined #ruby-lang
nariyal has joined #ruby-lang
justinmcp has joined #ruby-lang
undersc0re97 has joined #ruby-lang
nariyal has left #ruby-lang [#ruby-lang]
sepp2k has joined #ruby-lang
justinmcp has quit [Ping timeout: 246 seconds]
Shine-neko has joined #ruby-lang
yats__ has quit [Read error: Connection reset by peer]
yats__ has joined #ruby-lang
tbuehlmann has joined #ruby-lang
stiang has joined #ruby-lang
goshakkk has quit [Quit: Computer has gone to sleep.]
postmodern has quit [Quit: Leaving]
Madis has joined #ruby-lang
yats__ has quit [Read error: Connection reset by peer]
postmodern has joined #ruby-lang
yats__ has joined #ruby-lang
yats_ has joined #ruby-lang
<ryanf>
OrganicCat: you can use foreach or each_line
<ryanf>
you don't have to manage the memory manually; it just takes the file line by line
<ryanf>
File.foreach(filename) { |line| ... }
yats__ has quit [Ping timeout: 256 seconds]
stiang has quit [Quit: stiang]
yats_ has quit [Read error: Connection reset by peer]
yats__ has joined #ruby-lang
yats__ has quit [Read error: Connection reset by peer]
yats__ has joined #ruby-lang
yats__ has quit [Read error: Connection reset by peer]
yats__ has joined #ruby-lang
goshakkk has joined #ruby-lang
vlad_starkov has joined #ruby-lang
jamo has joined #ruby-lang
jamo has quit [Ping timeout: 260 seconds]
goshakkk has quit [Quit: Computer has gone to sleep.]
toretore has joined #ruby-lang
Madis_ has joined #ruby-lang
benanne has joined #ruby-lang
gruwl has joined #ruby-lang
vlad_starkov has quit [Remote host closed the connection]
Shine-neko has quit [Ping timeout: 245 seconds]
Madis has quit [Ping timeout: 246 seconds]
Madis has joined #ruby-lang
gruwl has left #ruby-lang [#ruby-lang]
Madis_ has quit [Ping timeout: 246 seconds]
ryanf has quit [Quit: leaving]
Madis_ has joined #ruby-lang
sush24 has joined #ruby-lang
goshakkk has joined #ruby-lang
vlad_starkov has joined #ruby-lang
Madis has quit [Ping timeout: 248 seconds]
tRAS has quit [Quit: Mother, did it need to be so high?]
Madis has joined #ruby-lang
justinmcp has joined #ruby-lang
Madis_ has quit [Ping timeout: 246 seconds]
Madis_ has joined #ruby-lang
yats_ has joined #ruby-lang
Madis_ has quit [Client Quit]
yats__ has quit [Ping timeout: 246 seconds]
Madis has quit [Ping timeout: 260 seconds]
Madis has joined #ruby-lang
x0F has quit [Disconnected by services]
x0F_ has joined #ruby-lang
x0F_ is now known as x0F
<OrganicCat>
ryanf: thanks
piyush has joined #ruby-lang
__butch__ has quit [Quit: Leaving.]
IPGlider has joined #ruby-lang
IPGlider is now known as Guest4365
Guest4365 has quit [Client Quit]
IPGlider_ has joined #ruby-lang
hackeron has quit [Remote host closed the connection]
yats_ has quit [Read error: Connection reset by peer]
IPGlider_ is now known as IPGlider
stiang has joined #ruby-lang
yats_ has joined #ruby-lang
Shine-neko has joined #ruby-lang
Shine-neko_ has joined #ruby-lang
apeiros_ has joined #ruby-lang
Shine-neko has quit [Ping timeout: 264 seconds]
Shine-neko has joined #ruby-lang
yats_ has quit [Ping timeout: 260 seconds]
Shine-neko_ has quit [Ping timeout: 255 seconds]
jayeola_ has joined #ruby-lang
jayeola has quit [Read error: Operation timed out]
<OrganicCat>
Will a file open each_line keep the file open for the duration the block runs? In other words, if I have a large file, will it continuosly read it into memory or close it after each line read?
vesan has quit [Ping timeout: 272 seconds]
jayeola has joined #ruby-lang
jayeola_ has quit [Ping timeout: 260 seconds]
stiang has quit [Quit: stiang]
Shine-neko_ has joined #ruby-lang
Shine-neko has quit [Ping timeout: 245 seconds]
Shine-neko_ is now known as Shine-neko
Shine-neko has quit [Client Quit]
A124 has joined #ruby-lang
goshakkk has quit [Quit: Computer has gone to sleep.]
vesan has joined #ruby-lang
ttilley has joined #ruby-lang
goshakkk has joined #ruby-lang
nazty has quit [Quit: Leaving]
KillerFox has joined #ruby-lang
conorreedy has quit [Read error: Connection reset by peer]
woollyams has quit [Quit: Computer has gone to sleep.]
Kogentasama has joined #ruby-lang
jxie has quit [Quit: leaving]
mojacc has joined #ruby-lang
mojacc has quit [Remote host closed the connection]
hackeron has joined #ruby-lang
IPGlider has quit []
nXqd has joined #ruby-lang
raya22 has joined #ruby-lang
Fullmoon has joined #ruby-lang
bastilian has joined #ruby-lang
nXqd has quit [Read error: Connection reset by peer]
nXqd has joined #ruby-lang
yats has joined #ruby-lang
justinmcp has quit [Remote host closed the connection]
Kogentasama has quit [Quit: #freenode]
hgf has joined #ruby-lang
Kogentsama has joined #ruby-lang
<Kogentsama>
Hello!
yats_ has joined #ruby-lang
<Kogentsama>
I have a newbie problem with threading in ruby, anyone in the mood to help me out?
hackeron_ has joined #ruby-lang
<Kogentsama>
This code here http://pastie.org/4927260 causes the following error: /home/user/NetBeansProjects/ImageDuplicateFinder/lib/main.rb:44: undefined method `each' for #<Thread:0x9af1280 dead> (NoMethodError)
yats has quit [Ping timeout: 256 seconds]
hackeron has quit [Ping timeout: 252 seconds]
<Kogentsama>
It kinda works on 43 Threads and then the error rises
<Kogentsama>
I am using ruby 1.9.3
justinmcp has joined #ruby-lang
gmci has joined #ruby-lang
yats_ has quit [Read error: Connection reset by peer]
yats_ has joined #ruby-lang
<burgestrand>
Kogentsama: threads.push Thread.new… not threads = Thread.new
<burgestrand>
Kogentsama: line #28
<Kogentsama>
oh !
<Kogentsama>
i try that :D
<burgestrand>
Kogentsama: also, you pass item to Thread.new(item), but do not accept it as block parameter
<burgestrand>
Kogentsama: probably do not have to pass it at all, but it is good practice to do so
<burgestrand>
Kogentsama: also, you have one global mutex for all files, your threads cannot run at the same time because of the mutex
<Kogentsama>
Oh okay, thanks for that
<burgestrand>
Kogentsama: you want to spend as little time in mutex.synchronize { … } as possible to use your threads to the max :)
<Kogentsama>
Ooh yeah i figured that, can i put the mutex around the filecount increment only?
<burgestrand>
Kogentsama: yeah, probably a good idea to add it around shahashes.merge(…) too
<burgestrand>
For CRuby it does not matter, but JRuby and Rubinius might not be so happy.
<burgestrand>
Kogentsama: so maybe just move down the mutex.synchronize two lines, so you do filebuf = … and filesha = … outside it
<Kogentsama>
Okay i moved it down, it runs definetly a bit quicker now
<burgestrand>
Kogentsama: do you have many items?
<Kogentsama>
1460 images
<burgestrand>
hehe, creating 1460 threads will make ruby kind of slow :)
<burgestrand>
Threads are nice and fairly cheap, but once you get more than a dussin or two you start seeing slowdowns because ruby spend more time switching between threads than running code inside them
<Kogentsama>
So i chunk them into threads of 20 or so?
piyush has quit [Ping timeout: 260 seconds]
<burgestrand>
Yeah, something like that, you can experiment with the number
<Kogentsama>
so its like 20 chunked .. processing .. next 20 ?
justinmcp has quit [Remote host closed the connection]
<burgestrand>
Kogentsama: probably you have your list of files, and your threads will each take one file, process it, and take another one. You wait until the list of files is empty (all processed)
<burgestrand>
Kogentsama: so maybe one thread will do all the work if all other threads are very slow
<Kogentsama>
burgestrand: I see. Looks great! Is it adviseable to use this at my early stage? I kinda want to grasp the concept first
<burgestrand>
Kogentsama: in that case I urge you to write your own threadpool. It’s a nice exercise, and is not too complicated.
<burgestrand>
It’s complicated, but when it comes to threads and stuff, writing a naive and simple threadpool is fairly straight-forward.
<burgestrand>
It becomes more complex when you want to restart crashed threads and such.
<Kogentsama>
burgestrand: Oh okay i will try that. I think i will play around with that Queue first and then chinking and if i get that concept somehow i will try on the Threadppol :]
<burgestrand>
Kogentsama: :)
<Kogentsama>
burgestrand: Thanks a lot! That was very helpful :]
<burgestrand>
Kogentsama: the threadpool I have written is the simplest thing that could possibly work, it’s not much code if you strip the comments, it might be useful to read through it
<burgestrand>
Kogentsama: once you understand how Queue works, you have a good base for understanding threadpool :)
<Kogentsama>
burgestrand: Okay! Then i will dive into it now :D
coffeejunk has quit [Quit: WeeChat 0.3.9-dev]
gaveen has quit [Ping timeout: 252 seconds]
coffeejunk has joined #ruby-lang
bastilian has quit [Read error: Connection reset by peer]
coffeejunk has quit [Client Quit]
<OrganicCat>
Looping through a list of objects, how can I setup a hashmap that stores and array in ruby? Something like this @user_visits[name] << user_value where 'name' is grabbed from another item generated during that time
<OrganicCat>
Getting this error undefined method `[]' for nil:NilClass
gaveen has joined #ruby-lang
wyhaines has joined #ruby-lang
BMF has joined #ruby-lang
enebo has joined #ruby-lang
coffeejunk has joined #ruby-lang
sush24 has quit [Quit: This computer has gone to sleep]
gaveen has quit [Ping timeout: 240 seconds]
<apeiros_>
OrganicCat: either you ensure that at least an empty array is present at @users_visits[name] before pushing to it
<apeiros_>
or you use @users_visits = Hash.new { |h,k| h[k] = [] }, which does that for you (but will create an empty array when accessing *any* key which has no value set)
tRAS has joined #ruby-lang
<apeiros_>
alternatively, use e.g. Enumerable#group_by to do the whole work for you
<ddd>
May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch! :) (Good morning, btw)
<OrganicCat>
apeiros: thanks much, gives me something to go on
anannie has quit [Remote host closed the connection]
tRAS has quit [Quit: Mother, did it need to be so high?]
irleif has quit [Quit: Computer has gone to sleep.]
jamo has joined #ruby-lang
yats__ has quit [Ping timeout: 246 seconds]
mistym has quit [Remote host closed the connection]
Kingy has joined #ruby-lang
jamo has quit [Ping timeout: 255 seconds]
ruurd has joined #ruby-lang
kain has quit [Ping timeout: 260 seconds]
mistym has joined #ruby-lang
mistym has quit [Changing host]
mistym has joined #ruby-lang
unsymbol has joined #ruby-lang
irleif has joined #ruby-lang
Nisstyre-laptop has joined #ruby-lang
piyush has joined #ruby-lang
nertzy2 has joined #ruby-lang
<andrewvos>
OrganicCat: Well you could just store a list of three page sequences and count them?
<andrewvos>
OrganicCat: Does each sequence start from their first hit, or from anywhere?
nertzy has quit [Ping timeout: 240 seconds]
Kogentsama has quit [Quit: Page closed]
irleif has quit [Quit: Computer has gone to sleep.]
Kingy__ has joined #ruby-lang
irleif has joined #ruby-lang
Kingy has quit [Ping timeout: 245 seconds]
Kingy__ has quit [Client Quit]
BMF has quit [Remote host closed the connection]
nertzy2 has quit [Quit: Leaving]
kain has joined #ruby-lang
nertzy has joined #ruby-lang
nertzy has quit [Client Quit]
nertzy has joined #ruby-lang
ruurd has quit [Quit: Leaving...]
jtoy has quit [Quit: jtoy]
jamjam has quit [Ping timeout: 246 seconds]
sepp2k has quit [Remote host closed the connection]
anannie has joined #ruby-lang
erichmenge has joined #ruby-lang
erichmenge has quit [Client Quit]
unsymbol has left #ruby-lang [#ruby-lang]
<OrganicCat>
andrewvos: each sequence can start from anywhere within their list, it's the top 3 most common sequences between users
kain has quit [Ping timeout: 260 seconds]
mistym has quit [Remote host closed the connection]
benanne has quit [Quit: kbai]
goshakkk has quit [Quit: Computer has gone to sleep.]
Mon_Ouie has quit [Ping timeout: 246 seconds]
Mon_Ouie has joined #ruby-lang
workmad3 has joined #ruby-lang
ryanlecompte has joined #ruby-lang
anon_456 has joined #ruby-lang
tRAS has joined #ruby-lang
jamjam has joined #ruby-lang
ruurd has joined #ruby-lang
kain has joined #ruby-lang
vlad_starkov has quit [Remote host closed the connection]
chimkan__ has quit [Quit: chimkan__]
rippa has quit [Ping timeout: 245 seconds]
Firstmate has joined #ruby-lang
<Firstmate>
Hi, I was reading the pragmatic programmer book and had a quick question. For class variables
<Firstmate>
when setting the value, does it change the value across all instances
<Firstmate>
or only within that objects ancestry
<workmad3>
Firstmate: it does, and it also changes it across all subclasses
jackhammer2022 has joined #ruby-lang
<workmad3>
Firstmate: in all honesty, ruby's class variables are a bit counter-intuitive in behaviour
<Firstmate>
So it's kind of like a modifiable static variable (from say java).
apeiros_ has joined #ruby-lang
nlpplz has joined #ruby-lang
<Firstmate>
static class variable*
<Firstmate>
If so, could you give a realistic usage of something like that?
kjr has joined #ruby-lang
<workmad3>
Firstmate: afaik, static class variables in java don't share across the entire inheritance hierarchy in quite as promiscuous manner
<Firstmate>
Ah right.
<Firstmate>
Forgot about that inheritance part of that.
<apeiros_>
heh, "in such a promiscuous manner" - love that
<Firstmate>
I meant more in the sense that changing it, changes it across all instances.
<Firstmate>
I guess I just really see when we'd want to do that.
<Firstmate>
really don't*
<workmad3>
Firstmate: yeah, it changes it across all instances of that class... and all instances of subclasses of that class... and (if the class variable was set in an ancestor class) then in all ancestor classes up to that point, and in all subclasses of all those ancestor classes...
<Firstmate>
mhm.
<workmad3>
Firstmate: it's why class instance variables tend to be used more than actual class variables
<Firstmate>
I see, thanks.
apeiros_ has quit [Remote host closed the connection]
<workmad3>
apeiros_: can you think of a better description of class variables than 'promiscuous'? :P
countdigi has quit [Quit: leaving]
Nisstyre-laptop has quit [Read error: Connection reset by peer]
justinseiter has quit [Ping timeout: 246 seconds]
<andrewvos>
OrganicCat: Write it out in sentences, then convert it to code.
<OrganicCat>
andrewvos: It's already in sentences and pseudocode actually, I was asking for someone to help convert it to code
<OrganicCat>
As a much easier question, how do I loop through an array of values and use the index so I can pinpoint various values? var[index], var[index+1], var[index+2], etc.
<tdy>
i think ary.each_with_index
<Mon_Ouie>
And you might actually want something like Enumerable#each_cons
goshakkk has joined #ruby-lang
no_worries has joined #ruby-lang
<OrganicCat>
I don't know the size of the array, so is each_cons useful?
<tdy>
oh cool, never knew about each_cons
heftig has quit [Quit: leaving]
<workmad3>
tdy: each_slice can also be useful ;)
<Mon_Ouie>
Sure. It just yields each element along with the (n-1) elements it is followed by.
<workmad3>
OrganicCat: defined? is an actual keyword, and it will check to see if local variables, ivars, constants, etc are actually defined, irrespective of contents
KA_ has quit [Quit: KA_]
tRAS has quit [Quit: Mother, did it need to be so high?]
s0ber has quit [Ping timeout: 260 seconds]
s0ber_ is now known as s0ber
<OrganicCat>
Yep, I found this worked better
<OrganicCat>
unless p1[2].nil?
<workmad3>
OrganicCat: you can also do 'if p1[2]'
Nisstyre-laptop has joined #ruby-lang
<workmad3>
OrganicCat: which builds on the detail that the only things that evaluate to 'false' in ruby are nil and false
<OrganicCat>
Same code, how would I define something like p1[index], p1[index+1], etc. since I'm already working with an each_with_index?
<OrganicCat>
Ah, I didn't know that
<tdy>
|p1, index|
<tdy>
but seems like each_cons would be a good fit for this?