Activity Graph

Page 1 of 2 | Next »


[06:14:59] warrshrike: has joined #ruby
[06:15:31] warrshrike: https://dpaste.de/pzf8
[06:15:34] warrshrike: guys what wrong here
[06:16:00] warrshrike: the result should be a complete traversal of the tree but only the root is printed
[06:23:20] warrshrike: apeiros: just in time!
[06:23:24] warrshrike: https://dpaste.de/pzf8
[06:23:28] warrshrike: guys what wrong here
[06:23:30] warrshrike: the result should be a complete traversal of the tree but only the root is printed
[06:28:42] warrshrike: i know the issue is
[06:28:57] warrshrike: the if condition that checks if left is nil
[06:29:26] warrshrike: yup. however i cant figure out why
[06:29:30] warrshrike: for the life of me...
[06:29:36] warrshrike: i have arrived for Aid
[06:30:21] warrshrike: how could i be such a dumbass
[06:31:34] warrshrike: baweaver: btw does ruby frown on accessing instance variables this way
[06:32:03] warrshrike: isnt it a bit: Thou shalt use methods and not access variable directly
[06:33:04] warrshrike: hey your code is same as mine instead youre using three attr reads instead of one attre accible
[06:33:20] warrshrike: ah cool cool
[06:34:06] warrshrike: havenwood: btw i see you're working at Square. Cool! I didn't know they used ruby
[06:34:43] warrshrike: havenwood: i especially like :left syntax
[06:35:56] warrshrike: havenwood: oh wow really! I've been applying for summer internships and ive havent had much luck with ruby companies though ive looked. Do you guys have an intern program?
[06:36:04] warrshrike: havenwood: whats a kwargs
[06:37:54] warrshrike: havenwood: ohh. Yeah so if i did left = nil as opposed to left: nil, it wouldnt work in that kwarg style?
[06:38:32] warrshrike: havenwood: oh right. learn something new everyday
[06:39:13] warrshrike: the first big shock for me was when i learned that ruby doesnt have first class functions and you need to use implicit blocks with yield
[06:42:25] warrshrike: havenwood: oh yeah i know that about procs. I was still surprised when I found out that you can't just assign a function to a variable or send it as an argument etc.
[06:44:46] warrshrike: def print(j) puts s end; def runner(fun, x) fun x end; runner(print, "hi")
[06:45:17] warrshrike: this doesnt work
[06:46:11] warrshrike: yeah but its a round about way to do things
[06:46:36] warrshrike: i respect rubys way
[06:47:13] warrshrike: in this particular instance, i think javascript/clojure are doing it better
[06:48:16] warrshrike: baweaver: okay okay
[06:48:21] warrshrike: baweaver: when?
[06:48:28] warrshrike: i might watch it if its a good lecture
[06:49:03] warrshrike: baweaver: where do i watch it? fox news?
[06:52:06] warrshrike: baweaver: We are blood brothers then!
[07:06:23] warrshrike: awesome awesome
[07:11:18] warrshrike: Woot https://squareup.com/careers/jobs?type=Intern Maybe I'll see you guys in the summer ^_^
[07:15:04] warrshrike: baweaver: yeah im filling it out right now. I hope they at least interview me lol
[07:18:12] warrshrike: its quite annoying when you never hear back from a company you really want to work at. like, its still honorable when you fail an interview
[08:21:48] warrshrike: Quit: Page closed


[00:04:25] warrshrike: phaul: here you go class ListNode attr_accessor :val, :next def initialize(val, n) @val = val @next = n end end
[00:49:59] warrshrike: Ping timeout: 256 seconds


[23:50:27] warrshrike: has joined #ruby
[23:50:45] warrshrike: are ruby objects 'unique'
[23:51:07] warrshrike: i.e. i have a ruby linked list and I want to detect whether it has a circle
[23:52:12] warrshrike: if i do keep a pointer to the head and start iterating and checking if if (node == head)
[23:52:16] warrshrike: will this work?
[23:52:53] warrshrike: havenwood: does that make sense?
[23:53:26] warrshrike: also does equality work automatically for classes ala === javascript or does it have to be overloaded like c++
[23:55:34] warrshrike: so it seems like the .equal? method ('pointer equality') would work here?
[23:57:58] warrshrike: havenwood: yes but , h = 1, g = h, h.equals? g is true
[23:58:20] warrshrike: havenwood: this makes it look like ruby is doing pass by ref
[23:58:31] warrshrike: which isnt really true
[23:58:37] warrshrike: g = 7 wont update h
[23:58:44] warrshrike: im not trying to make hashes lol
[23:58:58] warrshrike: what is that lupine


[08:00:47] warrshrike: has joined #ruby
[08:01:01] warrshrike: is there chaining in ruby hashes
[08:01:36] warrshrike: i want to detect duplicates in a ruby array by putting them in a hash
[08:01:41] warrshrike: i.e. in O(N)
[08:02:03] warrshrike: so if the value is duplicate, it will hash to same key and i will know
[08:02:07] warrshrike: does that make sense?
[08:02:22] warrshrike: whats an appropriate data structure for that
[08:03:21] warrshrike: elomatreb: doesnt that do the same thing?
[08:03:31] warrshrike: i also want to implement it for learning purposes lol
[08:12:18] warrshrike: elomatreb: got it to work with str.hash and a ruby hash
[09:51:55] warrshrike: Ping timeout: 256 seconds


[21:53:52] warrshrike: has joined #ruby
[21:54:30] warrshrike: what s the difference between a lambda and an anonymous function
[21:55:38] warrshrike: hey anyone there
[21:55:52] warrshrike: long time buddy
[21:59:02] warrshrike: how are you man
[21:59:12] warrshrike: aging well I hope? Time treating you well?
[22:00:59] warrshrike: ah cool cool
[22:01:13] warrshrike: so what IS the difference between a lambda and an anonymous function/block
[22:01:25] warrshrike: is it the same thing with some doohickies added
[22:09:26] warrshrike: btw what happened to this place. there were a lot more people two years ago
[22:21:31] warrshrike: so any idea about lambdas and blocks
[22:27:23] warrshrike: has joined #RubyOnRails
[22:29:38] warrshrike: has left #RubyOnRails: ()


[11:04:40] warrshrike: has joined #ruby
[11:05:33] warrshrike: how is everyone?
[11:05:34] warrshrike: how is everyone?
[11:06:53] warrshrike: https://paste.ofcode.org/FvfhU22X8HFALR6rCpqCVg
[11:06:53] warrshrike: any ideas why this returns nil?
[11:09:36] warrshrike: tbuehlmann: why would either of those lines cause issues? I mean 23 is just a return statement
[11:10:12] warrshrike: definitely not 15 - removed it and still nil
[11:10:52] warrshrike: canton7: okay yeah youre right
[11:11:14] warrshrike: that was dumb of me
[11:12:15] warrshrike: okay so whats the low down on call by reference vs value in ruby
[11:12:31] warrshrike: its clear its all happening by ref here - is that universal?
[11:14:32] warrshrike: canton7: we pass around the objects, their addresses or copies of the objects?
[11:16:41] warrshrike: tbuehlmann: so the value the object is storing is directly given to the asignee?
[11:16:55] warrshrike: and the object used to assign doesnt have any further relevance?
[11:18:01] warrshrike: a = 7 b = a; object here means 7 right?
[11:19:13] warrshrike: so if i do this: a = 7 b = a b = 9
[11:19:17] warrshrike: a is not changed right?
[11:20:01] warrshrike: but this: a = 'x', b = a, b = b.uppercase
[11:20:06] warrshrike: a is now uppercase?
[11:20:15] warrshrike: because method is called on same object?
[11:21:37] warrshrike: canton7: hmm okay but then
[11:22:03] warrshrike: how does line 22 in my example code paste alter the original list?
[11:22:26] warrshrike: backpop[target-1].next = backpop[target+1]
[11:22:36] warrshrike: were skipping an element in the list here...i.e. removing it
[11:22:45] warrshrike: and this change is reflected in 'head'
[11:22:57] warrshrike: ah so it matters if the method is 'in place'?
[11:23:58] warrshrike: gotcha. like sort and sort!
[11:24:29] warrshrike: so its really call by value, but in some special cases the method may mutate the og obj/data structure
[11:29:44] warrshrike: canton7: my bad
[11:29:50] warrshrike: it passes objects
[11:34:12] warrshrike: canton7: goctha
[11:34:25] warrshrike: so now it works more or less
[11:34:27] warrshrike: https://paste.ofcode.org/KcnW9Y5Enjs6qT7Kxkajd3
[11:35:06] warrshrike: except for the corner cases where: [1,2], 1 and [1,2], 2
[11:35:12] warrshrike: canton7: no it makes edits
[11:35:43] warrshrike: it removes the element we are supposed to remove by assign prevs next to the one ahead of target...
[11:36:17] warrshrike: canton7: yes. it returns the same list minus one element
[11:36:46] warrshrike: the problem would be fairly trivial but im trying to do it in one pass...the trade off I chose is O(N) storage
[11:37:57] warrshrike: clearly the corner cases dont work because 0-1 is -1 and that returns nil from the array containing nodes...
[11:54:49] warrshrike: dminuoso: thank goodness the expert is in the house!
[11:54:54] warrshrike: that makes sense
[11:54:59] warrshrike: so its pass by value
[11:55:10] warrshrike: unless the value itself is being mutated
[11:56:12] warrshrike: okay go on...
[11:56:28] warrshrike: dminuoso: makes sense...
[11:56:37] warrshrike: a = 9, b = a, b = 10
[11:56:49] warrshrike: so now b points to a new 10 in memory
[11:56:58] warrshrike: and a is still pointing to 9
[11:57:33] warrshrike: a = Node(9), b = a, b = Node(10)
[11:57:38] warrshrike: how about linked lists?
[11:58:05] warrshrike: Right so lets say a = HEAD
[11:58:13] warrshrike: dminuoso: yeah i am
[11:58:53] warrshrike: dminuoso: okay....
[11:59:03] warrshrike: but then how is it call by value
[11:59:14] warrshrike: this -> is thought of as call by ref
[11:59:31] warrshrike: dminuoso: okay okay....
[11:59:42] warrshrike: that means its not relevant for the programmer?
[12:00:59] warrshrike: dminuoso: oh THAT call by value
[12:01:04] warrshrike: but as for passing things around
[12:01:09] warrshrike: those are done by reference
[12:01:34] warrshrike: dminuoso: arent c style pointers by ref?
[12:04:12] warrshrike: dminuoso: yes
[12:04:26] warrshrike: unless we do this: f(int &a)
[12:05:23] warrshrike: dminuoso: okay okay got it
[12:06:19] warrshrike: dminuoso: so in C
[12:07:34] warrshrike: if you do something like this: int i = 9; *int j = &i; j=*j+1
[12:07:39] warrshrike: wont this update i too?
[12:07:48] warrshrike: or am i thoroughly not making sense now? :P
[12:10:44] warrshrike: dminuoso: wow brilliant example
[12:10:49] warrshrike: and just like that
[12:10:54] warrshrike: everything was crystal clear
[12:11:01] warrshrike: so thats how linked lists work in ruby
[12:11:16] warrshrike: out of interest, is ruby built on c or something?
[12:12:46] warrshrike: also out of interest, is it just me or has this channel become wayy quiter
[12:12:55] warrshrike: haven't seen many of the regulars for a bit
[12:13:14] warrshrike: hope people haven't deserted to #python :P
[12:23:53] warrshrike: kke: no true, i just asked some illuminating questions
[12:24:22] warrshrike: kke: in seriousness you're probably right stackoverflow has becomes great and the amount of ruby info is very large but nonetheless
[12:24:36] warrshrike: i think there will never be a substitute for a personalized help
[12:24:48] warrshrike: i generally post my code snippets and ask for help :P
[12:25:05] warrshrike: I'll always be thankful to this channel they helped me during some dark nights
[12:25:08] warrshrike: and dangerous times
[12:25:44] warrshrike: has joined #RubyOnRails
[12:25:49] warrshrike: has left #RubyOnRails: ()
[12:29:46] warrshrike: kke: perhaps not a worthwhile question....
[12:45:24] warrshrike: Quit: Page closed


[12:51:33] warrshrike: has joined #ruby
[12:52:07] warrshrike: is there a queue like thing of fixed size which autoremoves the oldest element when a newer is pushed and size is full?
[13:00:45] warrshrike: nothing BUILT IN?
[13:00:55] warrshrike: even c++ had those stacks and queues in std
[13:08:08] warrshrike: Quit: Page closed


[11:53:25] warrshrike: has joined #ruby
[11:54:03] warrshrike: can someone give me some efficient code to test whether string has only unique characters
[11:54:18] warrshrike: no just alphabets weird stuff like this !@#$%^&*()_+[]\ too
[11:55:19] warrshrike: thanks in advance! ^_^
[11:55:33] warrshrike: you guys are the best community online. I know you wont let me down ^_^
[12:23:20] warrshrike: Ping timeout: 260 seconds
[12:43:07] warrshrike: has joined #ruby
[12:43:23] warrshrike: how to efficiently
[12:43:30] warrshrike: check if string has duplicates
[12:43:37] warrshrike: apeiros: brother you know?
[12:48:34] warrshrike: I need the needful
[12:48:37] warrshrike: nobody to help
[12:48:41] warrshrike: even asked in real life
[12:48:46] warrshrike: help required
[12:48:56] warrshrike: sorry english is not my 1 language
[12:49:18] warrshrike: href: yes brother href?
[12:54:06] warrshrike: href: simply that given a string, two characters should not occur more than once
[12:54:12] warrshrike: if they do, return negative
[12:54:17] warrshrike: if they don't positive
[12:56:14] warrshrike: so if i check the reduce accumulator everytime, wouldnt it be very inefficient
[12:56:29] warrshrike: I think this problem should be doable in N
[12:59:40] warrshrike: gotcha...thanks!
[13:11:10] warrshrike: Ping timeout: 260 seconds


[18:49:12] warrshrike: has joined #ruby
[18:49:29] warrshrike: how to efficiently rotate a singly linked list by k places in ruby
[18:50:05] warrshrike: most solutions i see are either swapping the values (as opposed to actual nodes) or just making a circle, taking new head, and breaking the circle.
[21:10:00] warrshrike: Ping timeout: 260 seconds


[22:26:10] warrshrike: has joined #ruby
[22:26:16] warrshrike: something weird is happening...
[22:26:44] warrshrike: def nearest_palindromic(n) half = n.sub(0, n.length/2) end
[22:26:50] warrshrike: print nearest_palindromic("230")
[22:27:05] warrshrike: runner.rb:9:in `sub': no implicit conversion of Integer into String (TypeError)
[22:27:17] warrshrike: is ruby somehow converting the string input to int?
[22:27:22] warrshrike: thats...weird
[22:27:27] warrshrike: id use an int if i wanted an int
[22:29:10] warrshrike: no thats not what its doing...
[22:29:16] warrshrike: but any idea whats wrong?
[22:31:52] warrshrike: nvm I got it I have been writing kotlin code for way too long please excuse my ignorance
[23:04:20] warrshrike: Ping timeout: 260 seconds


[17:48:18] warrshrike: `insertUser': undefined method `<<' for false:FalseClass (NoMethodError)
[17:48:25] warrshrike: this is the error^
[17:54:20] warrshrike: Ping timeout: 260 seconds