#ruby-lang - Mon 12 Mar 2007 between 18:55 and 19:14



EludiasAn approach for large array would be more like:
kesVbest you can do is just use a counting sort. that would be O(n)
Eludiascounter = Hash.new(0); arr.each { |i| counter[i] += 1 }; arr.find_all { |i| i > 1 }
..which is indeed O(n). [...but has nothing to do with sort]
SilowyiEludias thanks, I for some reason didn't think about that.
kesVEludias: a counting sort is not a real sort
it's pretty much exactly what you gave there ;)
EludiaskesV: O. Ok then :)
Silowyitechnically a counting sort would be
counter = Array.new; arr.each { |i| counter[i] += 1 }; etc...
but that's being purist :P
kesVwell, if you only have integers
Silowyitrue
kesVwith more complex objects you need a map. and obviously counting sort only works if we know we are dealing with a restricted range of objects
bobwhoopsso I'm still stuck on how to use module PTY. I can read stuff from a curses program with reader.read(n), but I'd like to be able to read all the input available at once. Can someone just point me in the right direction?
technomancydoes this evaluate to Feb 28 for anyone else? Date.parse('March 1 2007').to_time
i've confirmed it on two 64-bit machines, and it works fine on the two 32-bit machines i've tried
anyone?
Eludiastechnomancy: Returns 1 march here (32 bits).
technomancyinteresting
j2mAm I alive?
Eludiasbobwhoops: Probably use select() and sysread()...
bobwhoopsEludias: thanks
jontecI need some help... I have a string, a regular html tag... I'm trying to match it with regex so that I can delete it... with the string "<a href=\"\"", why doesn't /<.>/ match it? /<./ does
Eludiasbobwhoops: while true; select([io]); buffer = io.sysread(1500); break if !buffer; end
bobwhoopsjontec: /<.*>/
jontecbobwhoops: oh! I didn't realize that I needed a quantifier, thanks. :D
ehirdif i do
x = NEW OBJECT HERE
y = x
does y take up the whole memory space of x
or is it just a small reference?
Eludiasehird: Same as Java. Small reference.
ehirdjust because i'm in #java doesn't mean i come from java thank you :(
Eludiasehird: Ok, you're going to #java then :) ?
ehirdno, i'm taking a look at java while sticking with ruby for most things :P
Eludiasehird: (exceptions: Fixnums. Those are copied and take up the whole memory space of x. But you won't notice.)
gnufiedEridius, will this work: arr.find_all { |i| i.count > 1 } ?
where arr would be the array?
Eludiasgnufied: That will return an array containg double-values, yes.

Page: 2 9 16 23 30 37 44 51 

IrcArchive