Activity Graph

Page 1 of 1


[05:41:36] leftylink: Remote host closed the connection
[07:53:09] leftylink: has joined #ruby
[07:53:14] leftylink: has joined #ruby-offtopic


[03:43:35] leftylink: NOW WE'LL NEVER KNOW
[17:42:36] leftylink: no reason to even consider regretting it, it was a good pun, bud


[22:28:15] leftylink: remember that sudoku bug... there was a small subproblem of "make a public statement that makes it likely I know the answer, but doesn't give too much away"
[22:41:06] leftylink: o. yeah if it had just been a "find the unspecified bug in these 300 lines" I probably wouldn't have bothered


[00:46:52] leftylink: heh, I accidentally used `next` in a lambda when I instead meant to use `return`, but it was fine. TIL I guess
[00:47:04] leftylink: &>> ->{ next 5 }[]
[00:47:16] leftylink: can't do that if it's a function though
[00:47:24] leftylink: &>> def f; next 5; end; f


[01:01:10] leftylink: dmwit: in ruby 2.4 or later, try Hash#transform_values


[20:05:29] leftylink: correction: the result of the expression is false, but `result` is true.
[20:06:01] leftylink: &>> xxx = (result = true and false); [xxx, result]
[20:08:12] leftylink: the ruby console shows you the value of the last expression, which is not necessarily the same as the value assigned to any variables that may have been present


[09:21:02] leftylink: &>> ["a".match(/a$/), "a".match("a$"), "will_never_match_a".match("/a$/"), "could_m/a/tch".match("/a/")]
[10:51:02] leftylink: well, if you have https://en.wikipedia.org/wiki/Sed installed, you could consider using it


[04:38:33] leftylink: ocampa: if manjaro is using arch's package for that, then https://www.archlinux.org/packages/community/any/ruby-irb/ may be necessary
[04:42:29] leftylink: whoa, I never knew such a command existed


[05:31:38] leftylink: you didn't store the result of change.round(2)
[10:27:48] leftylink: oh lol whoops
[10:27:54] leftylink: wouldn't have had that problem in an even-sized board


[08:28:38] leftylink: Ping timeout: 250 seconds
[08:28:55] leftylink: has joined #ruby-offtopic
[08:28:55] leftylink: has joined #ruby
[08:51:22] leftylink: you can consider %02d for the formatting part
[08:52:00] leftylink: &>> '%02d:%02d:%02d' % [0, 1, 22]


[17:22:57] leftylink: maybe a file w/ one element per line is good


[16:33:23] leftylink: Quit: Lost terminal
[16:44:36] leftylink: has joined #ruby
[16:44:40] leftylink: has joined #ruby-offtopic


[08:11:16] leftylink: that sounds fun. I would consider something like running imagemagick in a loop, https://imagemagick.org/script/convert.php has the deets
[08:11:42] leftylink: and ffmpeg can probably put all the frames into a webm


[01:10:52] leftylink: I seem to recall a way to preserve the old one before overriding it, mabe it was something to do with `method(:receive_direct_message_alerts=)` . sorry I don't have the exact stuff right now
[01:12:18] leftylink: &>> def asdf; :hello end; m = method(:asdf); def asdf; :overridden end; m.call
[01:12:53] leftylink: considerably more janky, it is true that module prepend is a less jank way
[21:44:02] leftylink: that `if @instance << x` seems deceptive if the expectation is that it will always be truthy. if it absolutely must be on one line, perhaps `false.tap { @instance << x}` instead?
[21:44:43] leftylink: or I guess you can go all the way with the tapping, so `@instance.include?(x).tap { |b| @instance << x unless b }`
[21:48:20] leftylink: I'd prefer `;` in the situation. `and` is still implying that the truthiness of `@instance << x` matters
[21:48:23] leftylink: when we expect it to not
[21:59:58] leftylink: also since it was never explicitly stated... there *was* a bit of uncertainty about `@instance` but I suppose the assumption in most of my statements was that it was either an array or a string, therefore `<<` will always be truthy
[22:06:40] leftylink: recall that for the given code to make sense we also have to intersect that set with the set of things that have `include?` ... also that I assumed that `includes?` in the original was misspelled


[23:35:53] leftylink: that wouldn't be gary bernhardt's boundaries talk, would it...


[13:34:28] leftylink: uh I guess if you wanted to golf it you can use postfix while on _
[13:34:41] leftylink: &>> a=0; f=->{a+1>3}; _ while f[]; p :hello
[13:38:39] leftylink: oops, can you not do that in a script... uh, maybe something silly like `0 while f[]` then
[13:39:29] leftylink: that's a "correct! nil! wat" moment
[13:43:05] leftylink: I also meant a+=1
[13:43:26] leftylink: should have printed out more things to verify that things were actually working
[13:44:53] leftylink: and that needs parens too, that's great
[13:44:59] leftylink: the += I mean
[13:45:20] leftylink: yeah so I guess it'd be something like
[13:45:43] leftylink: &>> a = []; i = 0; f = ->{ a << i; (i += 1) < 3}; p while f[]; a
[23:10:54] leftylink: more parens are needed
[23:12:09] leftylink: I had not thought to do that until it was just brought up, but it is interesting
[23:14:48] leftylink: okay so I played around with where the parens should go, this is interesting
[23:15:12] leftylink: &>> ruby -e 'def rawr(num); raise "no" if num.even?; num end; test = rawr(2) rescue rawr(4) rescue rawr(5); test
[23:15:23] leftylink: &>> ruby -e 'def rawr(num); raise "no" if num.even?; num end; test = (rawr(2) rescue rawr(4)) rescue rawr(5); test
[23:15:55] leftylink: &>> ruby -e 'def rawr(num); raise "no" if num.even?; num end; test = rawr(2) rescue (rawr(4) rescue rawr(5)); test
[23:21:28] leftylink: oh no, that would be why
[23:21:29] leftylink: I pasted too much
[23:21:39] leftylink: no wonder that was all messed up
[23:22:35] leftylink: a submission to a ruby obfuscation contest
[23:26:20] leftylink: okay, now I'm ready
[23:26:22] leftylink: &>> def f(num); raise "no" if num.even?; num end; t1 = f(2) rescue f(4) rescue f(5); t2 = f2 rescue (f(4) rescue f(5)); t3 = (f(2) rescue f(4)) rescue f(5); (t4 = f(2) rescue f(4)) rescue f(5); p [t1, t2, t3, t4]
[23:26:28] leftylink: so I'm forced to assume that t1 is parsed like t4
[23:26:39] leftylink: maybe there are some other possible parses that result in the same
[23:45:39] leftylink: &ast>> t1 = f(2) rescue f(4) rescue f(5)
[23:47:31] leftylink: that is indeed an interesting parse
[23:52:59] leftylink: I would think it's equally valid (or not) as an other use of modifier-rescue
[23:53:17] leftylink: I do wonder about why one bound tighter than the = and the other didn't though


[10:03:35] leftylink: &>> at_exit { p :Etesting }
[10:03:43] leftylink: oops ,accidental E
[10:03:55] leftylink: unfortunately, either way guess this is not helpful
[10:04:42] leftylink: oh, but it does get shown in the link


[07:33:11] leftylink: which index contains the number 1
[07:46:17] leftylink: save a line by changing the reduce to a .with_object


[13:40:13] leftylink: why does it need to take a block? why is a string not acceptable?
[13:41:34] leftylink: this has not convinced me that a block is needed
[13:50:26] leftylink: note that the "if no block is given" is likely to be done with block_given?
[14:11:52] leftylink: the same way you would reverse words anywhere else
[14:13:48] leftylink: and that should tell you that `yield` is evaluating to a string. so you use the variety of string methods at your disposal
[14:55:37] leftylink: depends on how surprised you want to be
[14:56:07] leftylink: &>> a=%w(hello world); b=a.map(&:upcase!); p a + b
[14:56:25] leftylink: that may be seen as surprising
[14:56:35] leftylink: so one would rather use just upcase in that scenario
[14:56:38] leftylink: &>> a=%w(hello world); b=a.map(&:upcase); p a + b
[15:32:10] leftylink: hmm. I think I such a situation, it's better to just omit the arg
[15:32:23] leftylink: as in, omit the `(&block)` entirely
[20:34:52] leftylink: well that sounds like a time for refinements doesn't it


[22:57:20] leftylink: since we talk about ioccc, remember about https://github.com/tric


[17:47:51] leftylink: well, you have a REPL at your disposal. you should strongly consider using it to evaluate some useful expressions
[17:48:00] leftylink: for example, what would 'a-z'.include?('x') be?
[17:51:10] leftylink: because 'a-z' is a string, to see the behaviour of 'a-z'.include?(whatever) , you would see what String#include? does.
[17:51:21] leftylink: &ri String#include?
[18:14:02] leftylink: regarding "are elements of the string" - then logically, the code should include some reference to the string there.
[18:14:57] leftylink: counterexample: "aardvark"
[18:17:58] leftylink: I'd do something like `line !~ /bar/ || line =~ /foo` I suppose ?
[18:18:10] leftylink: oh wait, other way around
[18:18:52] leftylink: `line !~ /foo/ || line =~ /bar/` . I think I'm translating "P implies Q" right this time...
[18:21:06] leftylink: if it must have some rspec syntax... you could use something like `expect(file.lines).to be_all { |line| line =~ whatever }`
[18:21:35] leftylink: because `be_x` in general becomes `thing.x?`
[18:28:30] leftylink: the error message for when the `be_all` is violated might be a bit less than ideal since it doesn't tell you exactly which line violated it. I might suggest something like `file.each_line { |line| next if line.include?('ext'); expect(line).to whatever }`
[18:28:50] leftylink: assuming I'm not violating some rspec style recommendations egregiously
[18:40:13] leftylink: maybe it'd make the test clearer anyway to do it in two stages rather than try with one regex
[19:05:28] leftylink: huh, haven't seen satisfy before, interesting
[19:09:49] leftylink: it's the "always return 0" syntax (sarcasm, but true in this case)
[19:10:05] leftylink: well, perhaps I give too much away
[19:10:32] leftylink: it is true that Swyper should carefully consider what `["a", "b"].index{"b"}` evaluates to
[19:10:46] leftylink: (and yes it is just a normal block)
[19:10:56] leftylink: with the associated consequences
[19:11:34] leftylink: you have a REPL at your disposal
[19:12:01] leftylink: that's one of the best things it's to be used for
[19:16:55] leftylink: index{song_name}
[19:35:15] leftylink: well, you look at all the ways in which your computed answer differs from the expected answer, and then you tackle them one by one. for example, you see that one_week_wonders returns "di" in the result, when it should. so you figure out why it does that, and fix that
[19:35:33] leftylink: s/when it should/when it should not/
[19:40:03] leftylink: was the radition of releasing on christmases upheld?
[19:40:39] leftylink: https://www.ruby-lang.org/en/news/2018/12/25/ruby-2-6-0-released/ yeah
[22:30:37] leftylink: x successively takes on the values "bob", "tod", and "jon"
[22:30:50] leftylink: therefore, the block evaluates names["bob"] which will cause the tyep error
[22:31:04] leftylink: well, if you want it to take on the values 0, 1, 2, there's Array#each_index for that
[22:36:08] leftylink: x takes on the value 0..2, therefore names[0..2] is also an array
[22:36:25] leftylink: &>> [0..2].each { |x| puts x }
[22:37:21] leftylink: x takesas in, the block is evaluated *once*, with x = 0..2


[03:41:57] leftylink: I guess I can still help by commenting on the gist, but apparently that requires a github acct
[03:48:11] leftylink: notice that 1: your `ordered_vowel_word?` requires that the word contains all vowels, which the tests do *not* require. 2: "i before e" is a spelling rule not an alphabet order rule
[03:55:26] leftylink: &>> p ["asdf".include?("a"), "asdf".include?("b")]
[03:56:12] leftylink: but I think I have misunderstood your question
[03:56:21] leftylink: &>> p ["asdf".include?("as"), "asdf".include?("ad")]
[04:00:43] leftylink: because: of the vowels that appear (a, o), they are in order.
[04:00:57] leftylink: there is no requirement that any particular vowel must appear
[04:01:02] leftylink: only a requirement on the vowels that do appear
[04:01:46] leftylink: random's vowels (a, o) appear in order
[04:02:06] leftylink: okra's vowels (o, a) don't
[04:05:22] leftylink: "a word that skips one of those is not in order" - that would be the case if the question asked "the word must contain all the vowels in order"
[04:05:39] leftylink: instead, the question asks "the words vowels must be in order", therefore it only applies to whichever vowels happen to be in the word
[04:10:45] leftylink: well, a lot of the time my process is "how would I do it with pen and paper" and translate that to code. by the by, what *would* be your approach, if you were to be asked to do it with pen and paper?
[04:28:42] leftylink: your current approach splits the problem into two parts: 1) get the list of vowels of a word. 2) is this list in order?. your approach to 1 was already working, regardless of whether it uses regex. you were needing to find a way to do part 2. a possible way to do part 2 has now been revealed above, which you can combine with your way to do part 1 if you want.
[04:29:19] leftylink: or, you can come up with your own way to do part 2 if you want
[04:29:39] leftylink: in which case, we ask "how do we figure out whether a list of things is in order?"
[04:31:20] leftylink: the approach you described, if I understood it correctly, does work. you are free to use it or any other way you devise or find
[04:49:29] leftylink: (the leaving, I mean)
[06:22:47] leftylink: Swyper: sort does not remove duplicates
[06:22:52] leftylink: &>> [1, 1].sort
[17:20:16] leftylink: doable w/o index, but I guess it depends on how one wants to think about it
[17:54:10] leftylink: there is no uniq? . there is https://ruby-doc.org/core-2.5.3/Array.html#method-i-uniq-21 and https://ruby-doc.org/core-2.5.3/Array.html#method-i-uniq .
[17:54:33] leftylink: regardless of that, to answer the question "does it repeat", consider phrasing it as "have I seen it before?"
[18:11:01] leftylink: has joined #ruby-offtopic
[18:38:30] leftylink: because " " isn't empty
[18:38:35] leftylink: &>> " ".empty?
[18:39:23] leftylink: only "" is empty.
[18:39:26] leftylink: &>> "".empty?
[18:45:36] leftylink: it is helpful to remove code that does nothing, so that it does not confuse readers. the c.empty? part is doing nothing
[18:52:13] leftylink: as the docs will say, no... but see the docs for Enumerable#count with a block.
[19:14:54] leftylink: that is cool
[19:19:18] leftylink: Swyper: it's improtant to note, there's nothing magical about the syntax "a-z" || "A-Z". the expression evaluates to "a-z".
[19:19:50] leftylink: so the attempt of `"xyzZZ!".count("a-z" || "A-Z")` is exactly equal to `"xyzZZ!".count("a-z")`
[19:20:09] leftylink: to understand the logic of how it works, it is useful to understand that there is nothing magical going on with the syntax there
[19:20:27] leftylink: `"a-z" || "A-Z"` is evaluated just as it would be in any other context
[19:59:07] leftylink: &ri Enumerable#max_by
[19:59:14] leftylink: is my suggestion
[20:02:31] leftylink: or, if you insist on keeping the separate array of # of letters of each string, then you want Array#zip
[20:06:12] leftylink: my suggestion stnads.
[20:06:21] leftylink: or I guess you can use Enumerable#sort_by if you want
[20:46:22] leftylink: you forgot to say what error.
[20:50:56] leftylink: then you should define it
[20:50:59] leftylink: if you expect the test to work
[22:22:40] leftylink: because 2 != 14
[22:23:05] leftylink: or, well, 2.equal?(14) was false, to be more precise
[22:23:09] leftylink: but I was imprecise and just said !=


[15:31:34] leftylink: you might think it would loop infinitely, but during eval, __FILE__ is (eval)


[21:51:50] leftylink: unfortunately, you see that a thing has happened.
[21:51:55] leftylink: &>> a = Hash.new { [] }; a['uplime'] << true; a
[21:51:59] leftylink: the hash doesn't even contain anything at all
[21:52:13] leftylink: &>> a = Hash.new { |h, k| h[k] = [] }; a['test'] << true; a
[21:52:55] leftylink: "It is the block's responsibility to store the value in the hash if required"


[04:54:19] leftylink: that sounds like `become` in Smalltalk, but I'm not convinced `become` exists in Ruby
[04:54:51] leftylink: note that a `send` is going to be sent to the object representing `4` not `n`, so I'd be surprised if a `send` has the power to change the binding
[04:58:12] leftylink: hmm. ok, so I just found that `ruby -e 'a = 5; binding.local_variable_set(:a, 100); puts a'` prints 100, so that is one possible? (https://ruby-doc.org/core-2.4.0/Binding.html)
[04:58:23] leftylink: s/one possible/one possible way of making something happen/
[04:58:47] leftylink: may not be as clean as hoped for though
[04:58:56] leftylink: sec, today's advent is starting
[07:32:59] leftylink: ah right. yeah far as I can tell it'd have to be smething like that
[22:12:43] leftylink: (this comment is not productively helpful to the discussion): Ah, so we can think of it as a tri-state variable... which would be https://thedailywtf.com/articles/What_Is_Truth_0x3f_


[00:56:15] leftylink: baweaver: I would show you https://stackoverflow.com/questions/8353026/what-is-the-run-time-of-shift-unshift-in-a-ruby-array/47683752#47683752 regarding the efficiency of shift/unshift, but I guess knowing this still doesn't necessarily mean you do want to explain them
[00:56:51] leftylink: I guess it just means that the performance wouldn't be the reason to disqualify them; if you disqualify them it'd be for other reasons


[20:58:44] leftylink: Quit: decommission
[20:59:52] leftylink: has joined #ruby


[11:07:38] leftylink: maybe they had A STringent requirement on minimum length
[11:07:42] leftylink: ... I am sorry


[10:34:50] leftylink: interesting. I wonder if you could do take one elemtn, do the `each_with_object` to figure out how many mor elts to take, then get the rest of them


[09:55:26] leftylink: has joined #ruby