« Back to channel list

#ruby - 24 February 2018

« Back 1 day Forward 1 day »
[00:02:00] apeiros: has joined #ruby
[00:04:38] tAn: has joined #ruby
[00:06:12] SeepingN: has joined #ruby
[00:08:41] konsolebox: has joined #ruby
[00:12:33] someuser: has joined #ruby
[00:13:03] safetypin: has joined #ruby
[00:15:01] gary_: has joined #ruby
[00:15:05] dviola: has joined #ruby
[00:19:23] Azure: has joined #ruby
[00:21:09] jaruga: has joined #ruby
[00:22:40] Azure: has joined #ruby
[00:27:11] ramfjord: has joined #ruby
[00:28:11] banisterfiend: has joined #ruby
[00:33:11] ramfjord: has joined #ruby
[00:38:15] banisterfiend: has joined #ruby
[00:39:47] gary: has joined #ruby
[00:41:21] sanscoeur: has joined #ruby
[00:42:38] alfiemax: has joined #ruby
[00:43:52] karapetyan: has joined #ruby
[00:45:07] agent_white: has joined #ruby
[00:45:42] alfiemax_: has joined #ruby
[00:47:19] beauby: has joined #ruby
[00:48:20] gr33n7007h: has joined #ruby
[00:48:41] zenspider: has joined #ruby
[00:49:47] Azure: has joined #ruby
[00:52:33] gary_: has joined #ruby
[00:53:47] workmad3: has joined #ruby
[00:58:46] jeffreylevesque: has joined #ruby
[01:14:37] jottr_: has joined #ruby
[01:16:20] herbmillerjr: has joined #ruby
[01:17:55] arescorpio: has joined #ruby
[01:20:09] abraham: has joined #ruby
[01:20:17] jottr_: has joined #ruby
[01:21:44] abraham: has left #ruby: ()
[01:22:15] Axsuul: has joined #ruby
[01:28:35] agent_white: has joined #ruby
[01:30:33] gary: has joined #ruby
[01:37:00] chengguyun: has joined #ruby
[01:42:49] konsolebox: has joined #ruby
[01:46:59] guardianx: has joined #ruby
[01:59:25] Dykam: has joined #ruby
[02:00:57] guardianx: has joined #ruby
[02:01:28] jottr_: has joined #ruby
[02:02:10] gary_: has joined #ruby
[02:02:16] orbyt_: has joined #ruby
[02:10:35] anjen: has joined #ruby
[02:13:15] pastorinni: has joined #ruby
[02:15:07] Dykam: has joined #ruby
[02:20:20] ramortegui: has joined #ruby
[02:22:23] jottr_: has joined #ruby
[02:23:42] guardianx: has joined #ruby
[02:32:28] gizmore|2: has joined #ruby
[02:40:10] gary: has joined #ruby
[02:44:35] milardovich: has joined #ruby
[02:47:36] beauby: has joined #ruby
[02:52:17] dinfuehr: has joined #ruby
[02:54:26] workmad3: has joined #ruby
[02:56:11] cagmz: has joined #ruby
[03:00:23] cdg: has joined #ruby
[03:05:12] netherwolfe: has joined #ruby
[03:16:11] gary_: has joined #ruby
[03:18:59] c0ncealed: has joined #ruby
[03:19:42] govg: has joined #ruby
[03:22:13] ramfjord: has joined #ruby
[03:23:07] jottr_: has joined #ruby
[03:24:22] kapil___: has joined #ruby
[03:28:31] ramfjord: has joined #ruby
[03:34:51] gary: has joined #ruby
[03:36:36] ramfjord: has joined #ruby
[03:45:14] ramfjord: has joined #ruby
[03:45:33] gary_: has joined #ruby
[03:52:52] Gary_B: has joined #ruby
[03:57:19] shinnya: has joined #ruby
[04:00:13] Gary_B: has joined #ruby
[04:10:07] Gary_B: has joined #ruby
[04:25:16] trautwein: has joined #ruby
[04:26:52] jottr_: has joined #ruby
[04:44:15] Asher: has joined #ruby
[04:46:15] darkhanb: has joined #ruby
[04:47:53] beauby: has joined #ruby
[04:52:13] jenrzzz: has joined #ruby
[04:52:13] jenrzzz: has joined #ruby
[04:54:06] gix-: has joined #ruby
[04:55:12] workmad3: has joined #ruby
[05:01:47] shortdudey123: has joined #ruby
[05:07:32] Asher1: has joined #ruby
[05:11:33] jeffreylevesque: has joined #ruby
[05:21:26] jnollette: has joined #ruby
[05:21:51] mostlybadfly: has joined #ruby
[05:28:46] morenoh149: has joined #ruby
[05:28:55] konsolebox: has joined #ruby
[05:30:06] jottr_: has joined #ruby
[05:32:33] jamesaxl: has joined #ruby
[05:40:50] nadir: has joined #ruby
[05:46:16] AxelAlex: has joined #ruby
[05:47:46] beauby: has joined #ruby
[05:53:27] banisterfiend: has joined #ruby
[05:55:05] wilbert: has joined #ruby
[05:58:12] wilbert_: has joined #ruby
[06:00:29] ramfjord: has joined #ruby
[06:08:05] Asher: has joined #ruby
[06:16:28] d^sh: has joined #ruby
[06:18:26] eckhardt: has joined #ruby
[06:18:36] alex``: has joined #ruby
[06:18:37] alfiemax: has joined #ruby
[06:19:39] alfiemax_: has joined #ruby
[06:20:08] JoshS: has joined #ruby
[06:22:46] morenoh149: has joined #ruby
[06:23:10] alfiemax: has joined #ruby
[06:23:12] orbyt_: has joined #ruby
[06:29:50] jottr_: has joined #ruby
[06:31:44] ayubi: has joined #ruby
[06:37:01] alfiemax: has joined #ruby
[06:46:30] gary: has joined #ruby
[06:51:10] wilbert: has joined #ruby
[06:55:54] workmad3: has joined #ruby
[07:06:40] conta: has joined #ruby
[07:17:50] Asher: has joined #ruby
[07:23:06] mtkd: has joined #ruby
[07:26:03] _aeris_: has joined #ruby
[07:28:08] jottr_: has joined #ruby
[07:29:31] LocaMocha: has joined #ruby
[07:57:10] _whitelogger: has joined #ruby
[08:00:19] Matthew1: has joined #ruby
[08:00:30] reber: has joined #ruby
[08:08:23] someuser: has joined #ruby
[08:08:30] gary: has joined #ruby
[08:10:44] nowhere_man: has joined #ruby
[08:12:41] jamesaxl_05: has joined #ruby
[08:16:06] Asher: has joined #ruby
[08:21:13] jnyw: has joined #ruby
[08:23:13] marr: has joined #ruby
[08:24:47] claudiuinberlin: has joined #ruby
[08:26:14] ldepandis: has joined #ruby
[08:26:20] jottr_: has joined #ruby
[08:27:27] goatish: has joined #ruby
[08:28:45] bigblind: has joined #ruby
[08:32:35] Tempesta: has joined #ruby
[08:32:36] Tempesta: has joined #ruby
[08:39:53] vondruch: has joined #ruby
[08:42:51] jaruga: has joined #ruby
[08:44:26] vondruch: has joined #ruby
[08:45:40] eckhardt: has joined #ruby
[08:53:17] tevio: has joined #ruby
[08:56:37] workmad3: has joined #ruby
[09:01:25] hurricanehrndz: has joined #ruby
[09:04:42] ltem: has joined #ruby
[09:14:27] Terens: has joined #ruby
[09:16:45] alfiemax: has joined #ruby
[09:18:08] alfiemax_: has joined #ruby
[09:19:00] apparition: has joined #ruby
[09:23:17] Terens: Is there a pattern to get progress for a task executing in a thread?
[09:23:28] Terens: i am using concurrent ruby and cant find something
[09:26:43] despai: has joined #ruby
[09:27:54] dminuoso: terens: Totally depends on your specific concurrency pattern
[09:28:08] jottr_: has joined #ruby
[09:28:20] dminuoso: From messaging to simply writing into mutex lock shared variable..
[09:31:20] y2k: has joined #ruby
[09:32:54] gary: has joined #ruby
[09:33:33] biberu: has joined #ruby
[09:35:37] jamesaxl_05: has joined #ruby
[09:37:51] despai: has joined #ruby
[09:41:06] snickers: has joined #ruby
[09:42:24] gary_: has joined #ruby
[09:45:23] clemens3: has joined #ruby
[09:48:59] Terens: has joined #ruby
[09:59:02] jooni: has joined #ruby
[10:00:08] alfiemax: has joined #ruby
[10:02:09] n008f4g_: has joined #ruby
[10:04:20] Gary_B: has joined #ruby
[10:15:15] Gary_B: has joined #ruby
[10:20:58] sleetdrop: has joined #ruby
[10:24:23] n13z: has joined #ruby
[10:27:28] jottr_: has joined #ruby
[10:29:34] sameerynho: has joined #ruby
[10:33:38] dminuoso: fix = ->(f) { f[fix[f]] }
[10:34:31] n13z: has joined #ruby
[10:36:04] phaul: has joined #ruby
[10:37:47] gary: has joined #ruby
[10:38:24] ramfjord: has joined #ruby
[10:39:56] dminuoso: >> fix = -> f { f[fix[f]] }; fac1 = -> f, n { n == 0 ? 1 : n * f[n-1] }; fac = fix[fac1]; puts fac[10]
[10:39:57] ruby[bot]: dminuoso: # => stack level too deep (SystemStackError) ...check link for more (https://eval.in/962368)
[10:40:25] despai: has joined #ruby
[10:40:41] urbanmonk: has joined #ruby
[10:46:41] nowhereman_: has joined #ruby
[10:47:45] milardovich: has joined #ruby
[10:48:35] despai: has joined #ruby
[10:49:15] gary_: has joined #ruby
[10:54:34] kapil___: has joined #ruby
[10:57:18] workmad3: has joined #ruby
[10:58:33] RougeR: has joined #ruby
[10:58:34] RougeR: has joined #ruby
[10:59:55] Mike11: has joined #ruby
[11:07:24] konsolebox: has joined #ruby
[11:15:58] mostlybadfly: has joined #ruby
[11:18:40] cabotto: has joined #ruby
[11:20:03] bigblind: has joined #ruby
[11:28:26] Gary_B: has joined #ruby
[11:29:50] jottr_: has joined #ruby
[11:34:40] quobo: has joined #ruby
[11:35:21] alfiemax: has joined #ruby
[11:40:20] snickers: has joined #ruby
[11:49:45] konsolebox: has joined #ruby
[11:53:36] InfinityFye: has joined #ruby
[11:54:25] AJA4350: has joined #ruby
[11:54:28] mtkd: has joined #ruby
[12:03:41] konsolebox: has joined #ruby
[12:05:07] nowhere_man: has joined #ruby
[12:07:41] gary: has joined #ruby
[12:08:44] mikecmpbll: has joined #ruby
[12:10:14] alfiemax: has joined #ruby
[12:15:03] jottr_: has joined #ruby
[12:22:45] ramfjord: has joined #ruby
[12:25:22] Mon_Ouie: dminuoso: fix = -> f { -> y { y[y] }[->x { f[-> v { x[x][v] }] }] }
[12:27:27] dminuoso: Mon_Ouie: Ah right. Y combinator.
[12:28:13] leitz: has joined #ruby
[12:29:11] dminuoso: >> fix = -> f { -> y { y[y] }[->x { f[-> v { x[x][v] }] }] }; fix[-> f, n { n == 0 ? 1 : n * f[n-1] }.curry][15]
[12:29:12] ruby[bot]: dminuoso: # => 1307674368000 (https://eval.in/962399)
[12:29:19] dminuoso: Mon_Ouie: Neat, thank you for the tip. :)
[12:29:44] Mon_Ouie: I think the usual definition of the Y combinator also doesn't work with strict evaluation though
[12:30:53] dminuoso: Mon_Ouie: Yeah. It tries to force fix before it actually ever calls f.
[12:31:14] konsolebox: has joined #ruby
[12:35:41] willmichael: has joined #ruby
[12:38:40] gary: has joined #ruby
[12:43:45] oleo: has joined #ruby
[12:46:33] willmichael: has joined #ruby
[12:50:19] despai: has joined #ruby
[12:53:55] mtkd: has joined #ruby
[12:58:02] workmad3: has joined #ruby
[13:00:27] \void: has joined #ruby
[13:00:35] ShekharReddy: has joined #ruby
[13:00:43] gary_: has joined #ruby
[13:03:04] kliq: has joined #ruby
[13:04:32] leitz: I'm missing something simple, the attribute is coming up as "nil" even after it should be set. https://gist.github.com/LeamHall/9a418df2766855bb5af11de3428d196e
[13:06:15] jamesaxl_work: has joined #ruby
[13:06:16] leitz: Ah, I need to include "Character" in career.
[13:06:18] konsolebox: has joined #ruby
[13:06:20] leitz: ACTION goes to read.
[13:09:14] RougeR: has joined #ruby
[13:09:14] RougeR: has joined #ruby
[13:10:37] jamesaxl_05: has joined #ruby
[13:11:20] Gary_B: has joined #ruby
[13:13:02] elementaru: has joined #ruby
[13:14:05] karapetyan: has joined #ruby
[13:16:09] leitz: Well... have tired include, require, and load. What's the keyword to add a class in another class when they are both in the same file?
[13:18:04] leitz: I'm back to trying to figure out the Factory pattern.
[13:19:28] dminuoso: leitz: Your mistake lies in the assumption of what gen_char returns.
[13:19:44] dminuoso: leitz: Methods return the value of the last expression (unless explicitly returned).
[13:19:50] bigblind: has joined #ruby
[13:20:10] John_Ivan: has joined #ruby
[13:20:10] John_Ivan: has joined #ruby
[13:20:12] dminuoso: leitz: gen_char uses puts as the last expression, so _its_ return value is returned.
[13:20:24] dminuoso: and puts returns nil. So your @char ends up nil.
[13:23:48] leitz: dminuoso, I thought gen_char would set @char. That's why it had no explicit return.
[13:24:45] dminuoso: leitz: Yes, but then when its done, the result is written back to @char overwriting what you have previously written in there.
[13:25:27] drewmcmillan: has joined #ruby
[13:25:38] mtkd: has joined #ruby
[13:30:04] leitz: dminuoso, not following you. I commented out the puts and get the same error. https://github.com/FreeTradeLeague/tdw_workspace/blob/master/toys/character_factory.rb
[13:31:03] dminuoso: leitz: Pretty sure you are not getting the same error.
[13:31:32] dminuoso: leitz: Im pretty this time it's "No such method `age' for 12:Integer"
[13:31:40] dminuoso: leitz: The problem is not the puts.
[13:31:49] dminuoso: leitz: The problem is that you are reassigning in 7.
[13:31:52] dminuoso: Dont assign to @char.
[13:32:47] dionysus69: has joined #ruby
[13:38:06] drewmcmillan: has joined #ruby
[13:41:25] desperek: has joined #ruby
[13:41:56] leitz: ACTION , back from making breakfast for the dogs, notes that dminuso is correct on the error.
[13:42:35] gary: has joined #ruby
[13:45:10] leitz: dminuso, design question. The goal is to have a Factory that modifies an instance of Character. There will be different Careers in the Factory. Should the Character generation even be in the Factory?
[13:48:04] willmichael: has joined #ruby
[13:48:15] leitz: ACTION needs to learn to spell names, like dminuoso...
[13:53:25] alfiemax: has joined #ruby
[13:55:58] Xiti`: has joined #ruby
[13:56:48] AX31_A13X: has joined #ruby
[13:57:37] shortdudey123: has joined #ruby
[13:58:46] AJA4351: has joined #ruby
[13:59:25] despai: has joined #ruby
[13:59:52] X-Jester_: has joined #ruby
[14:00:52] WhereIsMySpoon: has joined #ruby
[14:00:53] WhereIsMySpoon: has joined #ruby
[14:00:54] flak: has joined #ruby
[14:04:31] cschneid_: has joined #ruby
[14:04:32] bl4ckn1nj4: has joined #ruby
[14:04:47] Greasy-Gappers_: has joined #ruby
[14:04:58] ghormoon_: has joined #ruby
[14:05:04] jpterry_: has joined #ruby
[14:05:20] hinbody_: has joined #ruby
[14:05:35] raddazong: has joined #ruby
[14:05:36] reaVer_: has joined #ruby
[14:05:42] r3m_: has joined #ruby
[14:06:21] konsolebox_: has joined #ruby
[14:06:47] `derpy: has joined #ruby
[14:07:05] eam_: has joined #ruby
[14:08:49] JoshL-: has joined #ruby
[14:09:29] nielsk_: has joined #ruby
[14:09:36] _musl_: has joined #ruby
[14:09:37] MochaLoca: has joined #ruby
[14:09:47] kn1ght: has joined #ruby
[14:10:10] garyserj: has joined #ruby
[14:10:35] fumk: has joined #ruby
[14:10:49] qyliss_: has joined #ruby
[14:11:31] jamesaxl: has joined #ruby
[14:12:57] S007: has joined #ruby
[14:13:19] Eldritch: has joined #ruby
[14:14:39] someuser: has joined #ruby
[14:15:09] dinfuehr: has joined #ruby
[14:20:22] mikecmpbll: has joined #ruby
[14:21:42] gary_: has joined #ruby
[14:22:09] eldritch2: has joined #ruby
[14:25:15] n008f4g_: has joined #ruby
[14:26:05] Guest40768: has joined #ruby
[14:26:06] Guest40768: has joined #ruby
[14:27:38] agit0: has joined #ruby
[14:30:16] jaruga: has joined #ruby
[14:30:58] fumck: has joined #ruby
[14:31:36] ^mtkd: has joined #ruby
[14:32:13] mikecmpbll: has joined #ruby
[14:33:19] alfiemax: has joined #ruby
[14:36:22] za1b1tsu: has joined #ruby
[14:47:09] gary: has joined #ruby
[14:47:45] mtkd: has joined #ruby
[14:47:52] harmaahylje: has joined #ruby
[14:57:12] nowhereman_: has joined #ruby
[14:58:20] drewmcmillan: has joined #ruby
[14:59:16] harmaahylje: has joined #ruby
[15:00:52] gary_: has joined #ruby
[15:02:54] schneide_: has joined #ruby
[15:03:15] despai: has joined #ruby
[15:03:20] mikecmpbll: has joined #ruby
[15:04:10] snickers: has joined #ruby
[15:04:22] rrutkowski: has joined #ruby
[15:05:05] safetypin: has joined #ruby
[15:09:07] rrutkowski: has joined #ruby
[15:15:39] harmaahylje: has joined #ruby
[15:16:08] rrutkowski: has joined #ruby
[15:16:40] safetypin: has joined #ruby
[15:18:10] schneide1: has joined #ruby
[15:20:55] rrutkowski: has joined #ruby
[15:21:19] kapil___: has joined #ruby
[15:22:34] urbanmonk: has joined #ruby
[15:26:51] InfinityFye: has joined #ruby
[15:32:12] harmaahylje: has joined #ruby
[15:33:24] schneide1: has joined #ruby
[15:33:32] Gary_B: has joined #ruby
[15:34:12] goatish: has joined #ruby
[15:34:32] schneide_: has left #ruby: ()
[15:36:17] InfinityFye: has left #ruby: ("Leaving")
[15:39:32] alfiemax: has joined #ruby
[15:40:08] dionysus69: has joined #ruby
[15:41:16] harmaahylje: has joined #ruby
[15:41:51] gary: has joined #ruby
[15:44:33] laekur: has joined #ruby
[15:51:05] cabotto: has joined #ruby
[15:52:05] bl4ckn1nj4: has joined #ruby
[15:52:17] herbmillerjr: has joined #ruby
[15:53:15] bl4ckn1nj4: has joined #ruby
[15:53:41] harmaahylje: has joined #ruby
[15:54:39] bl4ckn1nj4: has joined #ruby
[16:05:54] harmaahylje: has joined #ruby
[16:09:37] gary_: has joined #ruby
[16:09:57] stormpack: has joined #ruby
[16:10:04] quobo: has joined #ruby
[16:10:05] alfiemax: has joined #ruby
[16:15:52] SeepingN: has joined #ruby
[16:19:55] bl4ckn1nj4: has joined #ruby
[16:20:58] bl4ckn1nj4: has joined #ruby
[16:22:16] bl4ckn1nj4: has joined #ruby
[16:22:33] cabotto: has joined #ruby
[16:38:13] gary: has joined #ruby
[16:39:24] nowhere_man: has joined #ruby
[16:43:41] Mike11: has joined #ruby
[16:45:16] Dimik: has joined #ruby
[16:45:29] alfiemax: has joined #ruby
[16:46:07] tvw: has joined #ruby
[16:49:42] gary_: has joined #ruby
[16:51:14] oleo: has joined #ruby
[16:59:28] workmad3: has joined #ruby
[17:00:33] Mike11: Hello all :)
[17:00:34] Mike11: I am using text = File.read('textfile', mode: 'rb') to read a text file into a string
[17:01:35] Mike11: the text file's line break type is CRLF
[17:02:13] mtkd: has joined #ruby
[17:02:21] Mike11: However, I can't find any "\r" chars in the string text
[17:02:38] Mike11: I am searching for "\r" using something like this:
[17:03:10] Mike11: (0..(text.length - 1)).select { |i| text[i] == "\r" }
[17:03:22] Mike11: the result array is empty
[17:05:05] osvico: has joined #ruby
[17:07:47] harmaahylje: has joined #ruby
[17:07:59] dionysus69: has joined #ruby
[17:08:46] anisha_: has joined #ruby
[17:10:46] John_Ivan: has joined #ruby
[17:10:47] John_Ivan: has joined #ruby
[17:11:31] cabotto: has joined #ruby
[17:12:33] Gary_B: has joined #ruby
[17:15:21] dviola: has joined #ruby
[17:16:06] havenwood: Mike11: File.binread(filename).count("\r")
[17:18:24] harmaahylje: has joined #ruby
[17:20:20] alfiemax: has joined #ruby
[17:20:58] ricer2: has joined #ruby
[17:22:54] devil_tux: has joined #ruby
[17:23:58] alfiemax_: has joined #ruby
[17:25:17] Mike11: havenwood: thanks for your suggestion. Not sure what am I doing wrong, it works well in irb, but outputs 0 when I run the whole project...
[17:27:04] Mike11: does ruby have any kind of global flags that can affect file opening especially regarding line break
[17:28:01] Gary_B: has joined #ruby
[17:28:57] harmaahylje: has joined #ruby
[17:29:48] havenwood: zenspider: just a heads-up, the quickref is 404ing
[17:30:43] havenwood: Mike11: There's a global variable `$/` for the input record separator.
[17:32:43] havenwood: >> require 'English'; $INPUT_RECORD_SEPARATOR
[17:32:45] ruby[bot]: havenwood: # => "\n" (https://eval.in/962467)
[17:32:51] ruby[bot]: havenwood: # => "\n" (https://eval.in/962469)
[17:32:54] cabotto: has joined #ruby
[17:35:51] bigblind: has joined #ruby
[17:37:34] mtkd: has joined #ruby
[17:37:48] cabotto: has joined #ruby
[17:38:57] rrutkowski: has joined #ruby
[17:39:49] harmaahylje: has joined #ruby
[17:40:13] Mike11: havenwood: thank you very much :)
[17:40:36] havenwood: Mike11: you're welcome
[17:40:39] dmitriy_: has joined #ruby
[17:45:16] rikkipitt: has joined #ruby
[17:46:06] cabotto: has joined #ruby
[17:48:39] willmichael: has joined #ruby
[17:50:09] harmaahylje: has joined #ruby
[17:50:21] bigblind: has joined #ruby
[17:51:59] c0dec_: has joined #ruby
[17:54:29] cabotto: has joined #ruby
[17:57:30] Emmanuel_Chanel: has joined #ruby
[18:02:25] harmaahylje: has joined #ruby
[18:04:30] gary: has joined #ruby
[18:10:49] MyMind: has joined #ruby
[18:11:26] cabotto: has joined #ruby
[18:15:27] harmaahylje: has joined #ruby
[18:16:10] cabotto: has joined #ruby
[18:17:44] gary_: has joined #ruby
[18:22:08] amelliaa: has joined #ruby
[18:23:35] jerikl: has joined #ruby
[18:23:47] darkhanb: has joined #ruby
[18:24:29] cabotto: has joined #ruby
[18:25:57] minimalism: has joined #ruby
[18:27:04] Gary_B: has joined #ruby
[18:28:28] Emmanuel_Chanel: has joined #ruby
[18:29:36] shortdudey123: has joined #ruby
[18:30:11] Emmanuel_Chanel: has joined #ruby
[18:30:50] harmaahylje: has joined #ruby
[18:32:02] Gary_B: has joined #ruby
[18:34:27] orbyt_: has joined #ruby
[18:36:00] karapetyan: has joined #ruby
[18:38:25] cabotto: has joined #ruby
[18:38:30] willmichael: has joined #ruby
[18:41:13] gary: has joined #ruby
[18:45:49] anisha_: has joined #ruby
[18:49:16] harmaahylje: has joined #ruby
[18:51:11] cabotto: has joined #ruby
[18:52:42] Xiti: has joined #ruby
[18:54:37] gary_: has joined #ruby
[18:59:49] harmaahylje: has joined #ruby
[19:00:08] workmad3: has joined #ruby
[19:02:02] milardovich: has joined #ruby
[19:02:58] someuser: has joined #ruby
[19:03:21] funnel: has joined #ruby
[19:05:09] raynold: has joined #ruby
[19:05:33] dinfuehr: has joined #ruby
[19:07:42] Gary_B: has joined #ruby
[19:11:39] harmaahylje: has joined #ruby
[19:12:36] cabotto: has joined #ruby
[19:12:41] schneide1: has joined #ruby
[19:16:12] Gary_B: has joined #ruby
[19:20:30] claudiuinberlin: has joined #ruby
[19:21:34] gothicsouth: has joined #ruby
[19:21:59] sammi`: has joined #ruby
[19:22:03] cabotto: has joined #ruby
[19:22:53] despai: has joined #ruby
[19:23:27] DoubleMalt: has joined #ruby
[19:23:41] gothicsouth: has joined #ruby
[19:26:21] jerikl: has joined #ruby
[19:27:28] clemens3: has joined #ruby
[19:28:08] shinnya: has joined #ruby
[19:29:29] harmaahylje: has joined #ruby
[19:33:02] harmaahylje: has joined #ruby
[19:34:35] cabotto: has joined #ruby
[19:37:40] karapetyan: has joined #ruby
[19:39:26] cabotto: has joined #ruby
[19:41:46] Gary_B: has joined #ruby
[19:48:13] gary: has joined #ruby
[19:49:33] DoubleMalt: has joined #ruby
[19:49:48] schneide1: has joined #ruby
[19:54:12] Mike11: I have a large sorted array of numbers (in ascending order). How can I find the last element in that array that is smaller than a given number x?
[19:54:30] tcopeland: has joined #ruby
[19:54:55] Mike11: I am currently doing something like this:
[19:54:55] Mike11: sorted_array.select { |i| i < x } .last
[19:55:50] Mike11: it works, but it doesn't seem that it is best way to me, as it doesn't take advantage of the fact that the array is sorted
[19:56:04] Mike11: s/it is best/it is the best/
[19:57:06] jerikl: has joined #ruby
[20:01:36] devil_tux: has joined #ruby
[20:02:41] baweaver: binary search.
[20:02:42] mozzarella: Mike11: I would use Array.bsearch
[20:02:48] baweaver: aha, ninja'd
[20:02:57] mozzarella: (  ;____;)
[20:03:16] baweaver: mozzarella has the right of it
[20:03:46] baweaver: &ri Array#bsearch
[20:03:46] `derpy: http://ruby-doc.org/core-2.4.1/Array.html#method-i-bsearch
[20:04:11] baweaver: I'd use find though as it breaks early when it finds something
[20:04:13] baweaver: select selects all
[20:04:27] baweaver: well, if you were using reverse_each.find
[20:04:46] baweaver: then again bsearch will narrow that down quickly enough
[20:04:51] Mike11: thanks all :D , and what if I am interested in the index of that item?
[20:05:02] baweaver: .each_with_index
[20:05:36] Mike11: aha, thanks again, reading. . .
[20:05:38] mozzarella: there's bsearch_index
[20:05:41] roshanavand: has joined #ruby
[20:05:45] baweaver: [1,2,3].each_with_index.find { |n, i| n.even? }
[20:05:47] baweaver: >> [1,2,3].each_with_index.find { |n, i| n.even? }
[20:05:48] ruby[bot]: baweaver: # => [2, 1] (https://eval.in/962512)
[20:09:11] cabotto: has joined #ruby
[20:10:17] darkhanb: has joined #ruby
[20:12:22] gary_: has joined #ruby
[20:14:46] MyMind: has joined #ruby
[20:18:25] cabotto: has joined #ruby
[20:21:40] karapetyan: has joined #ruby
[20:23:15] cabotto: has joined #ruby
[20:28:33] tomphp: has joined #ruby
[20:31:29] karapetyan: has joined #ruby
[20:31:47] cabotto: has joined #ruby
[20:32:59] Mike11: so, in a sorted array (in ascending order), I wanted to find the last element that is smaller than a given number. bsearch was really helpful, but applying it directly gives the first element that is larger than a given number (i.e. I am seeking the preceding element to that)
[20:33:29] karapetyan: has joined #ruby
[20:33:50] Mike11: I ended up doing something like this:
[20:33:50] Mike11: sorted_array.each_with_index.to_a.reverse.bsearch { |n, i| n < some_number }
[20:33:51] bigblind: has joined #ruby
[20:34:13] tomphp: has joined #ruby
[20:35:11] Mike11: this seems to give me what I want. but I am worried again about efficiency, since I am creating another array by reversing this array. is there a better way, or is this solution okay?
[20:39:51] Gary_B: has joined #ruby
[20:40:06] cabotto: has joined #ruby
[20:41:55] alfiemax: has joined #ruby
[20:42:44] rrutkowski: has joined #ruby
[20:44:02] darkhanb_: has joined #ruby
[20:46:06] phaul: has joined #ruby
[20:46:31] jordanm: has joined #ruby
[20:48:36] guardianx: has joined #ruby
[20:49:01] cabotto: has joined #ruby
[20:50:09] kromm: has joined #ruby
[20:50:22] kromm: has left #ruby: ()
[20:52:07] gary: has joined #ruby
[20:52:07] alfiemax: has joined #ruby
[20:56:06] MyMind: has joined #ruby
[20:56:45] dmitriy_: has joined #ruby
[20:56:47] weaksauce: for small arrays that's fine
[20:58:57] Mike11: weaksauce: my array might have 10k elements, is that considered fine or not?
[20:59:31] weaksauce: Mike11 what's your definition of performant? how often are you doing this? how large are the objects?
[20:59:45] weaksauce: how much ram does your server have?
[21:00:04] Mike11: well, basically, I just want to get it as fast as possible
[21:00:56] cabotto: has joined #ruby
[21:01:06] Mike11: it works for me that way it is now, but I just wanted to make sure I am not missing an obvious optimization technique
[21:02:39] weaksauce: though bsearch doesn't actually work the way you are using it
[21:03:02] weaksauce: try some_number - n instead of n < somenumber
[21:03:46] IanMalcolm: has joined #ruby
[21:04:29] Mike11: weaksauce: bsearch has two modes https://ruby-doc.org/core-2.5.0/Array.html#method-i-bsearch
[21:04:37] al2o3-cr: Mike11: yeah if you want Array#find use weaksauce's answer
[21:05:45] al2o3-cr: *equivilant of*
[21:06:16] Mike11: I am using the find-any mode, aren't I?
[21:06:31] Mike11: why would I have to return an integer, weaksauce ^^
[21:07:03] weaksauce: so binary search knows which way to go
[21:07:15] weaksauce: but perhaps it works for you
[21:07:23] weaksauce: >> (0...1000).bsearch {|x| x <= 10 }
[21:07:24] ruby[bot]: weaksauce: # => nil (https://eval.in/962533)
[21:07:30] weaksauce: >> (0...1000).bsearch {|x| 10 - x }
[21:07:31] ruby[bot]: weaksauce: # => 10 (https://eval.in/962534)
[21:07:44] weaksauce: >> (0...1000).bsearch_index {|x| 10 - x }
[21:07:45] ruby[bot]: weaksauce: # => undefined method `bsearch_index' for 0...1000:Range ...check link for more (https://eval.in/962535)
[21:08:02] weaksauce: >> (0...1000).to_a.bsearch_index {|x| 10 - x }
[21:08:36] Mike11: weaksauce: I get your idea, thanks :D
[21:08:42] al2o3-cr: weaksauce: bot is using 2.3
[21:08:58] weaksauce: ah i am using an older variant
[21:12:20] c0dec: has joined #ruby
[21:12:51] bigblind: has joined #ruby
[21:13:42] nowhere_man: has joined #ruby
[21:14:31] tomphp: has joined #ruby
[21:15:42] Asher: has joined #ruby
[21:18:23] cabotto: has joined #ruby
[21:18:39] despai: has joined #ruby
[21:19:52] cagmz: has joined #ruby
[21:20:55] mroutis: has joined #ruby
[21:22:52] mroutis: hi, rubyists! have someone managed to use Nix package manager for ruby development?
[21:24:13] mroutis: dealing with different ruby installations and gems per project
[21:24:18] schneider-: has joined #ruby
[21:25:50] bigblind: has joined #ruby
[21:26:54] cabotto: has joined #ruby
[21:26:58] n13z: mroutis: I use rbenv to manage severals versions as needed.
[21:27:27] despai: has joined #ruby
[21:29:06] jerikl: has joined #ruby
[21:29:35] gary_: has joined #ruby
[21:31:36] cabotto: has joined #ruby
[21:35:15] jerikl: has joined #ruby
[21:39:07] amatas: has joined #ruby
[21:39:18] pastorinni: has joined #ruby
[21:40:12] cabotto: has joined #ruby
[21:41:42] jerikl: has joined #ruby
[21:41:43] darkhanb: has joined #ruby
[21:42:16] cschneid: has joined #ruby
[21:42:20] mroutis: n13z: thanks
[21:42:33] mroutis: has left #ruby: ()
[21:48:08] cschneid: has joined #ruby
[21:48:13] Stan: has joined #ruby
[21:57:20] cabotto: has joined #ruby
[21:58:29] white_lilies: has joined #ruby
[22:00:10] gary: has joined #ruby
[22:01:25] quobo: has joined #ruby
[22:05:51] cabotto: has joined #ruby
[22:08:55] _cabotto: has joined #ruby
[22:11:58] c0dec: has joined #ruby
[22:21:25] cabotto: has joined #ruby
[22:21:41] bigblind: has joined #ruby
[22:24:42] jerikl: has joined #ruby
[22:32:46] PaulePanter: has joined #ruby
[22:37:46] gary_: has joined #ruby
[22:38:51] cabotto: has joined #ruby
[22:45:28] cschneid: has joined #ruby
[22:47:21] schneider-: has joined #ruby
[22:49:08] schneider-: has joined #ruby
[22:51:53] cabotto: has joined #ruby
[22:55:47] schneider-: has joined #ruby
[22:58:07] jerikl: has joined #ruby
[23:04:28] schneider-: has joined #ruby
[23:13:03] cabotto: has joined #ruby
[23:14:07] mikecmpbll: has joined #ruby
[23:16:35] gary: has joined #ruby
[23:18:28] bigblind: has joined #ruby
[23:19:43] szulak: has joined #ruby
[23:24:01] cabotto: has joined #ruby
[23:24:19] Vapez: has joined #ruby
[23:24:26] bl4ckn1nj4: has joined #ruby
[23:39:25] cabotto: has joined #ruby
[23:50:39] cabotto: has joined #ruby
[23:54:16] Asher: has joined #ruby
[23:54:41] gary: has joined #ruby
[23:55:27] cschneid: has joined #ruby
[23:55:36] willmichael: has joined #ruby
[23:55:56] cabotto: has joined #ruby
[23:58:43] SeepingN: has joined #ruby