00:00
al2o3-cr has joined #ruby
00:01
laaron- has joined #ruby
00:01
ellcs has quit [Ping timeout: 264 seconds]
00:01
comet23 has joined #ruby
00:01
<
comet23 >
where can we submit new language features ideas?
00:02
cschneid has joined #ruby
00:02
laaron has quit [Remote host closed the connection]
00:04
garyserj_ has joined #ruby
00:04
<
comet23 >
thank you :D
00:04
<
comet23 >
we need an unshift operator!
00:07
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
00:08
<
phaul >
what would it do and how would it look like?
00:10
tdy has quit [Read error: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac]
00:10
<
al2o3-cr >
&>> class Array; def >>(val) unshift val end end; [1,2,3] >> :foo
00:10
<
al2o3-cr >
i like that.
00:12
nchambers has quit [Quit: WeeChat 2.2]
00:12
<
phaul >
hi al2o3-cr
00:13
<
al2o3-cr >
hi phaul ;)
00:13
<
phaul >
check this out:
00:14
<
phaul >
though the eval is still on 2.5, I need carc.in to be updated first
00:15
cschneid has quit [Ping timeout: 268 seconds]
00:15
<
phaul >
also I
*think* it will require actual changes even if small ones, as dissass, ast APIs have changed
00:16
<
al2o3-cr >
phaul: yes, minor changes i think.
00:16
NightMonkey has quit [Ping timeout: 246 seconds]
00:16
<
al2o3-cr >
&ri Proc#>>
00:18
NightMonkey has joined #ruby
00:18
<
al2o3-cr >
i'm sure jhass will update asap.
00:19
<
catphish >
is the behaviour of modifying an array while iterating over it defined?
00:22
<
catphish >
looks like i should probably use Array#delete_if to iterate and allow me to delete items at the same time
00:23
hutch has joined #ruby
00:24
connermcd has quit [Quit: WeeChat 2.3]
00:24
venmx has quit [Ping timeout: 244 seconds]
00:24
dviola has quit [Quit: WeeChat 2.3]
00:25
houhoulis has quit [Remote host closed the connection]
00:26
<
comet23 >
yeah the unshift operator will look like >>
00:26
<
comet23 >
because the shift operator looks like <<
00:26
<
phaul >
well, the language has an unshift operator then.
00:27
<
phaul >
even though here they claim it's binary shift, really many types implement >> in a way that has nothing to do with bit shifting
00:32
bmurt has joined #ruby
00:32
hutch has quit [Ping timeout: 250 seconds]
00:33
spacesuitdiver has joined #ruby
00:33
nowhere_man has quit [Ping timeout: 252 seconds]
00:33
bmurt has quit [Client Quit]
00:37
d10n-work has joined #ruby
00:39
blackmesa1 has joined #ruby
00:42
GodFather has quit [Ping timeout: 244 seconds]
00:42
sameerynho has quit [Ping timeout: 240 seconds]
00:43
tag has quit [Quit: Connection closed for inactivity]
00:44
blackmesa1 has quit [Ping timeout: 252 seconds]
00:59
blackmesa1 has joined #ruby
00:59
garyserj_ has quit [Quit: garyserj_]
01:01
laaron has joined #ruby
01:03
laaron- has quit [Remote host closed the connection]
01:08
blackmesa1 has quit [Ping timeout: 252 seconds]
01:24
Averna has joined #ruby
01:30
segy has quit [Ping timeout: 272 seconds]
01:32
blackmesa1 has joined #ruby
01:32
segy has joined #ruby
01:34
cd has quit [Remote host closed the connection]
01:38
ellcs has joined #ruby
01:38
blackmesa1 has quit [Ping timeout: 260 seconds]
01:38
blackmesa1 has joined #ruby
01:44
Nicmavr has quit [Read error: Connection reset by peer]
01:45
RougeR has quit [Ping timeout: 245 seconds]
01:45
ellcs has quit [Ping timeout: 260 seconds]
01:46
Nicmavr has joined #ruby
01:46
jordanm has quit [Ping timeout: 240 seconds]
01:47
jordanm has joined #ruby
01:48
s3nd1v0g1us has quit [Quit: WeeChat 2.2]
01:55
cschneid has joined #ruby
01:55
blackmesa1 has quit [Ping timeout: 252 seconds]
01:57
tdy has joined #ruby
01:58
garyserj_ has joined #ruby
02:01
laaron- has joined #ruby
02:02
laaron has quit [Remote host closed the connection]
02:03
code_zombie has joined #ruby
02:15
tdy has quit [Ping timeout: 245 seconds]
02:19
nchambers has joined #ruby
02:19
nchambers is now known as uplime
02:20
BTRE has quit [Remote host closed the connection]
02:21
BTRE has joined #ruby
02:22
<
comet23 >
So if it has it then why is it not able to be implemented for arrays?
02:27
cschneid has quit [Ping timeout: 245 seconds]
02:52
patteh has quit [Ping timeout: 250 seconds]
02:54
nowhere_man has joined #ruby
02:58
patteh has joined #ruby
03:00
jottr has quit [Ping timeout: 244 seconds]
03:01
laaron has joined #ruby
03:02
laaron- has quit [Remote host closed the connection]
03:05
tdy has joined #ruby
03:05
Swyper has joined #ruby
03:06
patteh has quit [Ping timeout: 268 seconds]
03:06
<
Swyper >
Can someone help me figure out why my tests are failing ?
03:11
patteh has joined #ruby
03:22
patteh has quit [Ping timeout: 268 seconds]
03:24
<
comet23 >
Swyper: what exercises are you doing?
03:25
cschneid has joined #ruby
03:27
uplime has quit [Ping timeout: 250 seconds]
03:29
Swyper has quit [Ping timeout: 256 seconds]
03:31
jottr has joined #ruby
03:31
hutch has joined #ruby
03:36
jottr has quit [Ping timeout: 240 seconds]
03:41
<
leftylink >
too bad
03:41
<
leftylink >
I guess I can still help by commenting on the gist, but apparently that requires a github acct
03:45
Swyper has joined #ruby
03:46
hiroaki has quit [Ping timeout: 246 seconds]
03:46
<
Swyper >
hi, not sure who was talking to me before but I'm doing practice questions from App Academy
03:47
<
Swyper >
comet23 and leftylink , just looked through logs and it was you two :)
03:48
<
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:50
<
Swyper >
1) Yeah you are right.. I have to think of a way to check for all combinations of vowels in order I guess I could do this with a bunch of OR statements
03:50
<
Swyper >
2) oh, so it should be AEIOU ?
03:51
<
Swyper >
for 1) I'm thinking there has to be a more efficient way to do this then to pile up a a few OR statements
03:53
<
Swyper >
is there a way to check if a string is a subset of another string ?
03:53
<
Swyper >
way = method in ruby :P
03:55
<
leftylink >
&>> p ["asdf".include?("a"), "asdf".include?("b")]
03:56
<
leftylink >
but I think I have misunderstood your question
03:56
<
leftylink >
&>> p ["asdf".include?("as"), "asdf".include?("ad")]
03:58
cschneid has quit [Ping timeout: 246 seconds]
03:59
uplime has joined #ruby
03:59
<
Swyper >
ignore the first one it pasted way to much ;x
04:00
<
Swyper >
expected: ["word", "pale", "word", "random", "pry"] got: ["word", "pale", "word", "pry"], why should random even be returned it skips e and i o-o
04:00
<
leftylink >
because: of the vowels that appear (a, o), they are in order.
04:00
<
leftylink >
there is no requirement that any particular vowel must appear
04:01
<
leftylink >
only a requirement on the vowels that do appear
04:01
laaron- has joined #ruby
04:01
<
Swyper >
# Define a method that accepts an array of words and returns an array of those # words whose vowels appear in order. You may wish to write a helper method: # ordered_vowel_word?
04:01
<
Swyper >
it does say in order in the comments they gave o-o
04:01
<
leftylink >
random's vowels (a, o) appear in order
04:02
<
leftylink >
okra's vowels (o, a) don't
04:02
laaron has quit [Remote host closed the connection]
04:03
<
Swyper >
So where my confusion is that to me in order would mean a, e, i ,o, u and a word that skips one of those is not in order, and I'm obviously understanding it wrong but what does in order even mean, then ?
04:05
<
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
braincrash has quit [Quit: bye bye]
04:05
<
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:06
<
Swyper >
okay that makes sense
04:06
<
Swyper >
so my include statement at the moment is not good enough, any ideas on how to improve it to pass the test cases?
04:07
<
Swyper >
or function as it should instead of just pass test cases xD
04:08
* baweaver
wanders in
04:08
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
04:08
braincrash has joined #ruby
04:09
<
Swyper >
feel free to give me any suggestions :P
04:10
<
Swyper >
I could be lame and just pass the test causes by adding ao to the end of the string but that would lame
04:10
<
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:14
<
Swyper >
I guess broke the vowels up into an array, find the index of the array where the first element of the string we are evaluating (the vowels we parsed from the string) appears, discard all elements in the array of vowels prior to where the index was and return false if there is ever a vowel that cannot be found in the array
04:15
<
Swyper >
though I wrote pretty messy so what I wrote above might be hard to follow ^
04:17
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
04:18
<
al2o3-cr >
&>> "random".scan(/[aeiou]/)
04:18
<
Swyper >
"random".scan(/[aeiou]/), /[aeiou]/ is regex ?
04:19
<
al2o3-cr >
Swyper: yes.
04:20
<
al2o3-cr >
&>> "random".scan(/[aeiou]/).tap { |vowels| break vowels == vowels.sort }
04:21
<
Swyper >
interesting
04:22
masterasia has joined #ruby
04:22
jottr has joined #ruby
04:22
<
Swyper >
is there an answer that does not involve regex ? one approach could be to have a bunch of messy if statements nested inside one another
04:25
hutch has quit [Ping timeout: 240 seconds]
04:27
jottr has quit [Ping timeout: 250 seconds]
04:28
<
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
<
leftylink >
or, you can come up with your own way to do part 2 if you want
04:29
<
leftylink >
in which case, we ask "how do we figure out whether a list of things is in order?"
04:31
<
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:33
kapil____ has joined #ruby
04:34
r29v has joined #ruby
04:40
r29v has quit [Ping timeout: 240 seconds]
04:41
Swyper has quit [Quit: Page closed]
04:42
hutch has joined #ruby
04:47
<
havenwood >
Swyper: A nit, but it's a bit nicer to use `%w[a e i o u]` instead of `"a i e o u".split` for the same result faster with less memory. In your case it doesn't matter but just mentioning.
04:47
<
havenwood >
Ah, they left. Was gunna suggest they take a look at #each_cons.
04:49
<
leftylink >
(the leaving, I mean)
04:50
AJA4350 has quit [Quit: AJA4350]
04:52
ogres has joined #ruby
04:55
ur5us has quit [Remote host closed the connection]
04:56
hutch has quit [Ping timeout: 268 seconds]
04:56
d10n-work has quit [Quit: Connection closed for inactivity]
04:56
lytol has joined #ruby
05:00
laaron has joined #ruby
05:02
laaron- has quit [Remote host closed the connection]
05:09
davidw_ has quit [Ping timeout: 244 seconds]
05:14
<
comet23 >
what is ruby 3 going to be like?
05:15
* al2o3-cr
gets out his crystal ball...
05:20
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
05:28
davidw_ has joined #ruby
05:30
rawrg has joined #ruby
05:33
davidw_ has quit [Ping timeout: 246 seconds]
05:33
patteh has joined #ruby
05:33
<
al2o3-cr >
for Swyper's next one: Array#reverse, Array#combination, Integer#pred, Enumerable#map and Enumerable#inject
05:38
patteh has quit [Ping timeout: 250 seconds]
05:44
Swyper has joined #ruby
05:44
<
Swyper >
def array_product(array, i) counter = 0 array.map = { |int| counter *= int } end
05:45
<
Swyper >
array.map = { |int| int *= counter }is causing me a syntax error any idea why ?
05:45
<
havenwood >
Swyper: get rid of the equal sign in `.map = {`
05:46
<
havenwood >
Swyper: `.map { |int|` instead of `.map = { |int|`
05:48
<
Swyper >
its returning [0,0,0,0] atm >_>
05:49
<
baweaver >
What happens when you multiply a number by 0?
05:49
<
baweaver >
Also map is the wrong function for this.
05:51
<
havenwood >
&>> require 'prime'; (0..).lazy.select { |n| n.prime? && (n * 9 + 4).prime? }.map { |n| (n + 94).chr }.first 5
05:51
<
havenwood >
oh, right - no 2.6 yet :)
05:51
<
havenwood >
&>> require 'prime'; 1.step.lazy.select { |n| n.prime? && (n * 9 + 4).prime? }.map { |n| (n + 94).chr }.first 5
05:52
<
baweaver >
How did you find that one?
05:52
<
havenwood >
baweaver: an earlier question was about vowels, and I thought there
*must* be a good way to find vowels. >.>
05:52
<
baweaver >
....how did you figure that out?
05:52
<
baweaver >
They're just conveniently spaced?
05:52
<
Swyper >
return (order_of_vowels.sort.join == order_of_vowels.join)
05:53
<
Swyper >
just compared the sorted vowels with the actual vowels, I can post the whole solution if your curious
05:53
<
baweaver >
duplicates
05:53
Menteb has joined #ruby
05:54
<
havenwood >
baweaver: i found an OEIS sequence that matched an offset of the bytes >.>
05:54
<
baweaver >
Interesting.
05:54
<
Swyper >
sort removes duplicates ?
05:54
<
Swyper >
^ solution
05:55
rawrg has quit [Ping timeout: 240 seconds]
05:55
<
havenwood >
baweaver: this is actually the one I wanted to implement, since it aligns with the position of the vowels in the alphabet - but I couldn't figure out what the heck the `a(n)-a(n-1)` part is meant to be.
05:56
laaron- has joined #ruby
05:56
<
havenwood >
It's not the previous binary palindrome or the previous index, so... what is it?
05:57
laaron has quit [Remote host closed the connection]
05:58
<
Swyper >
Also sorry I left midway, I use webchat to connect since everything else for mac costs money (textual) or is outdated or to technical for me to use :P
06:00
<
Swyper >
oh thank you
06:01
laaron has joined #ruby
06:02
laaron- has quit [Remote host closed the connection]
06:02
spacesuitdiver has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
06:02
<
havenwood >
Swyper: Many of us use a bouncer like ZNC to replay history to our IRC client for what we missed.
06:04
Swyper has quit [Quit: Page closed]
06:04
spacesuitdiver has joined #ruby
06:06
Swyper has joined #ruby
06:06
<
Swyper >
yay I'm on through limechat now, thanks
06:06
<
havenwood >
nice, you're welcome
06:07
<
havenwood >
Swyper: Just showing you that ^ for the #each_cons bit on line 6. (Ignore the silly way to find the vowels.)
06:07
<
Swyper >
neat thank you
06:08
<
havenwood >
Swyper: It's a handy way to compare each element to the next.
06:15
Menteb has quit [Quit: Menteb]
06:15
Swyper has quit [Remote host closed the connection]
06:18
Swyper has joined #ruby
06:22
<
leftylink >
Swyper: sort does not remove duplicates
06:22
rippa has joined #ruby
06:22
<
leftylink >
&>> [1, 1].sort
06:22
akosednar has quit [Ping timeout: 268 seconds]
06:24
akosednar has joined #ruby
06:26
cschneid has joined #ruby
06:33
<
al2o3-cr >
so a(n) = smallest integer > a(n-1) that is an odd palindome when written in base 2
06:34
<
al2o3-cr >
i'm struggling with this, i'll tell thee.
06:38
aupadhye has joined #ruby
06:41
hutch has joined #ruby
06:44
<
al2o3-cr >
i think i've got it.
06:45
armyriad has quit [Ping timeout: 250 seconds]
06:47
Averna has quit [Ping timeout: 250 seconds]
06:57
_whitelogger has joined #ruby
06:57
m0w has quit [Ping timeout: 268 seconds]
06:58
cschneid has quit [Ping timeout: 245 seconds]
07:01
laaron- has joined #ruby
07:02
laaron has quit [Remote host closed the connection]
07:05
Menteb has joined #ruby
07:07
<
uplime >
if i have a function (foo(**opts)), is there a way to pass another hash (ie foo **bar), but have it retain the changes afterwards?
07:08
<
uplime >
i could return the updated one, but i'm already returning an array so i thought i'd check
07:10
tdy has quit [Ping timeout: 240 seconds]
07:21
Swyper has quit [Remote host closed the connection]
07:22
hutch has quit [Ping timeout: 272 seconds]
07:23
Swyper has joined #ruby
07:25
tiff has joined #ruby
07:27
Swyper has quit [Ping timeout: 250 seconds]
07:45
_whitelogger has joined #ruby
07:51
ogres has quit [Quit: Connection closed for inactivity]
07:54
Zarthus is now known as updime
07:54
updime is now known as uprime
07:54
uprime is now known as upmime
07:55
Menteb has quit [Quit: Menteb]
07:55
upmime is now known as up|ime
08:01
Menteb has joined #ruby
08:02
raulp has quit [Read error: Connection reset by peer]
08:02
raulp has joined #ruby
08:03
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
08:15
patteh has joined #ruby
08:19
DTZUZO has quit [Ping timeout: 240 seconds]
08:22
reber has joined #ruby
08:22
Menteb has quit [Remote host closed the connection]
08:29
patteh has quit [Ping timeout: 272 seconds]
08:31
gitness has left #ruby [#ruby]
08:45
_whitelogger has joined #ruby
08:45
jottr has joined #ruby
08:54
dellavg_ has joined #ruby
08:56
cschneid has joined #ruby
09:00
_whitelogger has joined #ruby
09:01
laaron has joined #ruby
09:02
laaron- has quit [Remote host closed the connection]
09:04
gix has joined #ruby
09:09
hiroaki has joined #ruby
09:11
cnsvc has joined #ruby
09:15
cnsvc has quit [Ping timeout: 256 seconds]
09:21
idiocrash has joined #ruby
09:30
cschneid has quit [Ping timeout: 240 seconds]
09:47
masterasia has joined #ruby
09:49
jottr has quit [Ping timeout: 245 seconds]
09:57
DTZUZO has joined #ruby
10:01
laaron- has joined #ruby
10:02
exchgr has quit [Ping timeout: 252 seconds]
10:02
laaron has quit [Remote host closed the connection]
10:02
exchgr` has joined #ruby
10:15
lxsameer has joined #ruby
10:28
sandelius has joined #ruby
10:29
comet23 has quit [Quit: Connection closed for inactivity]
10:39
towo has joined #ruby
10:47
blackmesa1 has joined #ruby
10:56
za1b1tsu has joined #ruby
10:56
cpallares has quit [Ping timeout: 246 seconds]
10:57
<
towo >
Hey, I'm trying to use Net::SSH::Authentication::Agent to sign something, but when passing the key (for the public key) argument, it apparently expects an OpenSSL::PKey::RSA or similar object. I'm not seeing any way of actually saying "read this string as a public key" anywhere in the whole module. Any hints on how to generate that without reimplementing half the module?
10:58
havenwood has joined #ruby
10:59
cpallares has joined #ruby
11:01
laaron has joined #ruby
11:02
laaron- has quit [Remote host closed the connection]
11:04
conta has joined #ruby
11:06
roshanavand has joined #ruby
11:09
za1b1tsu has quit [Remote host closed the connection]
11:20
code_zombie has quit [Quit: Leaving]
11:27
cschneid has joined #ruby
11:31
sidepocket has joined #ruby
11:35
thinkpad has quit [Ping timeout: 246 seconds]
11:37
thinkpad has joined #ruby
11:37
roshanavand has quit [Quit: Gone planting!]
11:41
vutral1 has joined #ruby
11:45
blackmesa1 has quit [Ping timeout: 250 seconds]
11:52
dviola has joined #ruby
11:53
reber has quit [Remote host closed the connection]
11:59
cschneid has quit [Ping timeout: 250 seconds]
12:01
laaron- has joined #ruby
12:02
laaron has quit [Remote host closed the connection]
12:15
m0w has joined #ruby
12:19
AJA4350 has joined #ruby
12:23
Nicmavr has quit [Read error: Connection reset by peer]
12:25
Nicmavr has joined #ruby
12:32
patteh has joined #ruby
12:45
clemens3 has quit [Ping timeout: 245 seconds]
12:45
sandelius has joined #ruby
12:46
jottr has joined #ruby
12:46
<
sandelius >
Happy New Year's Eve everyone
13:05
szulak_ has joined #ruby
13:09
exchgr has joined #ruby
13:09
exchgr` has quit [Ping timeout: 252 seconds]
13:11
cschneid has joined #ruby
13:14
cschneid has quit [Remote host closed the connection]
13:14
cschneid has joined #ruby
13:20
cschneid has quit [Ping timeout: 250 seconds]
13:24
_whitelogger has joined #ruby
13:26
garyserj_ has quit [Ping timeout: 272 seconds]
13:27
cschneid has joined #ruby
13:32
cschneid has quit [Remote host closed the connection]
13:34
despai has joined #ruby
13:40
dviola has quit [Ping timeout: 245 seconds]
13:43
Azure has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
13:45
GodFather has joined #ruby
13:47
catphish has left #ruby ["Leaving"]
13:48
agent_white has joined #ruby
13:56
n01 has joined #ruby
13:58
m0w has quit [Ping timeout: 246 seconds]
14:02
laaron- has quit [Remote host closed the connection]
14:03
szulak_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
14:04
mostlybadfly has joined #ruby
14:04
laaron has joined #ruby
14:12
jgpawletko has quit [Ping timeout: 245 seconds]
14:19
jgpawletko has joined #ruby
14:33
MyMind has joined #ruby
14:33
Sembei has quit [Ping timeout: 246 seconds]
14:35
vutral1 has quit [Ping timeout: 252 seconds]
14:43
polishdub has joined #ruby
14:44
n01 has quit [Read error: Connection reset by peer]
14:45
m0w has joined #ruby
14:50
ellcs has joined #ruby
14:51
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
15:02
laaron has quit [Remote host closed the connection]
15:03
blackmesa1 has joined #ruby
15:04
laaron has joined #ruby
15:06
uplime has quit [Ping timeout: 272 seconds]
15:08
aupadhye has quit [Quit: Leaving]
15:09
blackmesa1 has quit [Quit: WeeChat 2.3]
15:14
d^sh has quit [Ping timeout: 244 seconds]
15:17
d^sh has joined #ruby
15:21
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
15:23
Rapture has joined #ruby
15:25
DTZUZO has quit [Ping timeout: 245 seconds]
15:40
GodFather has quit [Ping timeout: 268 seconds]
15:45
mikecmpbll has joined #ruby
15:46
despai has quit [Quit: ...]
15:49
d10n-work has joined #ruby
15:51
szulak_ has joined #ruby
15:52
GodFather has joined #ruby
15:52
jthomas1 has joined #ruby
15:55
davidw_ has joined #ruby
16:02
Renich has joined #ruby
16:04
DTZUZO has joined #ruby
16:04
jthomas2 has joined #ruby
16:06
jthomas1 has quit [Ping timeout: 268 seconds]
16:13
mostlybadfly has quit [Quit: Connection closed for inactivity]
16:15
armyriad has joined #ruby
16:16
donofrio has joined #ruby
16:18
Aqo has joined #ruby
16:19
GodFather has quit [Ping timeout: 244 seconds]
16:23
donofrio has quit [Ping timeout: 240 seconds]
16:24
armyriad has quit [Ping timeout: 250 seconds]
16:26
Dbugger has joined #ruby
16:26
GodFather has joined #ruby
16:29
armyriad has joined #ruby
16:32
Dbugger has quit [Remote host closed the connection]
16:33
mostlybadfly has joined #ruby
16:49
Mike11 has joined #ruby
16:50
idiocrash has quit [Read error: Connection reset by peer]
16:51
dviola has joined #ruby
16:53
donofrio has joined #ruby
16:58
masterasia has joined #ruby
17:00
masterasia has quit [Client Quit]
17:01
laaron- has joined #ruby
17:02
laaron has quit [Remote host closed the connection]
17:06
kapil____ has quit [Quit: Connection closed for inactivity]
17:06
donofrio has quit [Ping timeout: 246 seconds]
17:07
despai has joined #ruby
17:07
masterasia has joined #ruby
17:13
ellcs has quit [Ping timeout: 250 seconds]
17:15
Swyper has joined #ruby
17:15
<
Swyper >
expected: [24, 12, 8, 6]
17:15
<
Swyper >
got: [24, 288, 27648, 191102976]
17:16
<
baweaver >
Swyper: lead with the problem description
17:16
cthulchu has joined #ruby
17:16
<
Swyper >
baweaver ?
17:16
<
Swyper >
on the gist it leads with the description :P
17:17
GodFather has quit [Ping timeout: 245 seconds]
17:17
<
baweaver >
line 6 doesn't actually make a new list.
17:17
<
Swyper >
oh it just points to the old one? >_>
17:17
<
Swyper >
how do I make a deep copy of that list then ?
17:18
<
baweaver >
You don't need one.
17:18
<
baweaver >
numbers.map instead
17:18
masterasia has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
17:19
<
baweaver >
Though you could use map.with_index to get the index, which you probably need for this anyways.
17:19
despai has quit [Quit: ...]
17:20
<
leftylink >
doable w/o index, but I guess it depends on how one wants to think about it
17:20
hiroaki has quit [Ping timeout: 250 seconds]
17:20
<
baweaver >
One could just invert that singular number considering how multiplication works.
17:21
<
baweaver >
Commutative property wasn't it?
17:21
sameerynho has joined #ruby
17:21
<
baweaver >
a * b * c == c * b * a
17:21
<
baweaver >
which could be done in any order.
17:22
hutch has joined #ruby
17:22
<
baweaver >
Swyper: If I add one to a number, how would I undo that?
17:23
<
Swyper >
that's what I'm doing, using commutative property multiplying everything out and then dividing it by whatever number was not supposed to be included in the multiplication
17:23
<
baweaver >
True, but that's not the business of the array_product function
17:23
<
baweaver >
the name becomes a lie by doing that.
17:24
<
baweaver >
That, and you want to likely use sum or reduce instead for getting a product.
17:24
lxsameer has quit [Ping timeout: 246 seconds]
17:25
GodFather has joined #ruby
17:25
<
baweaver >
well, reduce.
17:26
<
Swyper >
True, do you want to show me how it would work using reduce instead of what I'm using now ?
17:26
<
baweaver >
&>> [1, 2, 3].reduce(1) { |accumulator, v| accumulator * v }
17:26
<
baweaver >
&>> [1, 2, 3].reduce(1) { |a, v| a * v }
17:26
<
baweaver >
&>> [1, 2, 3].reduce(1, :*)
17:27
conta has quit [Quit: conta]
17:27
<
Swyper >
one thing that sort of bugs me is I don't know the difference between map and each
17:27
<
Swyper >
and when to use each one
17:27
<
baweaver >
each only iterates a list
17:27
<
baweaver >
map is used to transform a list and return a new list
17:31
<
baweaver >
Hrm, maybe I should go through a tutorial of basics on how Enumerable works overall and going through usecases of each of the methods.
17:31
<
baweaver >
s/go through/write/
17:32
<
Swyper >
sure I'd love to read that
17:34
tdy has joined #ruby
17:35
Mike11 has quit [Quit: Leaving.]
17:41
armyriad has quit [Quit: Leaving]
17:45
<
livcd >
interesting atm r/elixir has many more readers than r/ruby + r/rails
17:47
KeyJoo has joined #ruby
17:49
<
Swyper >
jeez, FP is a beast I will go through another day
17:50
<
Swyper >
so I'm trying to create a method that just checks to see if a certain character repeats or not, I know uniq exists - but afaik it modifies the list and uniq? will modify the list aswell or return nil
17:50
<
Swyper >
is there a better approach to accomplishing what I am trying to do ?
17:53
orbyt_ has joined #ruby
17:54
<
Swyper >
the find method looks promising.
17:54
<
leftylink >
regardless of that, to answer the question "does it repeat", consider phrasing it as "have I seen it before?"
17:54
sanscoeur has joined #ruby
17:54
<
baweaver >
uniq doesn't modify the list.
17:54
<
baweaver >
uniq! will
17:55
KeyJoo has quit [Quit: KeyJoo]
17:59
idiocrash has joined #ruby
17:59
ua has quit [Quit: Leaving]
18:00
ua has joined #ruby
18:01
laaron has joined #ruby
18:01
tdy has quit [Remote host closed the connection]
18:02
laaron- has quit [Remote host closed the connection]
18:04
sanscoeur has quit [Remote host closed the connection]
18:06
tiff has joined #ruby
18:11
catbusters has joined #ruby
18:14
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
18:15
tdy has joined #ruby
18:15
<
Swyper >
does compact remove all nil and '' elements from an array aswell? The docs only show it removing nil, I think
18:17
tiff has joined #ruby
18:19
<
Swyper >
my failing test, has one nil at the front I can't seem to get rid of, not sure why
18:22
<
baweaver >
&>> 'aabbcccdef'.chars.group_by(&:itself).select { |ch, count| count == 1 }.keys
18:22
<
baweaver >
ah, right
18:22
<
baweaver >
&>> 'aabbcccdef'.chars.group_by(&:itself).select { |ch, chs| chs.size == 1 }.keys
18:23
<
baweaver >
&>> 'aabbcccdef'.chars.group_by(&:itself)
18:23
m0w has quit [Ping timeout: 246 seconds]
18:24
* baweaver
really wants a count_by function
18:24
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
18:28
nowhere_man has quit [Ping timeout: 252 seconds]
18:33
<
Swyper >
repeated_char = string.each_char.select { |c| (string.count(c) > 1) && !(c.empty?)}
18:33
<
Swyper >
I'm just confused as to how select is still allowing "" as a repeating character
18:33
<
Swyper >
&& !(c.empty?) should have taken care of that no?
18:34
<
Swyper >
though I see what you did with .size but I am still curious as to why what I am doing is incorrect
18:35
Rapture has joined #ruby
18:36
davidw_ has quit [Ping timeout: 246 seconds]
18:38
tdy has quit [Ping timeout: 268 seconds]
18:38
<
leftylink >
because " " isn't empty
18:38
<
leftylink >
&>> " ".empty?
18:39
<
leftylink >
only "" is empty.
18:39
<
leftylink >
&>> "".empty?
18:41
kapil____ has joined #ruby
18:42
<
Swyper >
repeated_char = string.each_char.select { |c| (string.count(c) > 1) && !(c.empty?) && c != " "} works =D
18:43
mostlybadfly has quit [Quit: Connection closed for inactivity]
18:45
<
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:46
<
Swyper >
&>> "xyz!".count(a..z)
18:47
<
Swyper >
&>> "xyz!".count("a..z")
18:47
<
Swyper >
anyway to use count with a range?
18:47
<
Swyper >
in this case I want all letters from a-z
18:52
<
leftylink >
as the docs will say, no... but see the docs for Enumerable#count with a block.
18:56
<
Swyper >
ary.count{ |x| x%2==0 } #=> 3, so I count string.count { |x| ("a..z").include?(x) } or something like this?
18:58
yokel has quit [Remote host closed the connection]
18:59
hutch has quit [Ping timeout: 246 seconds]
19:00
yokel has joined #ruby
19:02
laaron has quit [Remote host closed the connection]
19:03
laaron has joined #ruby
19:05
Dbugger has joined #ruby
19:05
tiff has joined #ruby
19:07
cthulchu has quit [Read error: Connection reset by peer]
19:11
cthulchu has joined #ruby
19:12
<
phaul >
For strings the count can count a string range, but not a normal range. 'a-z' would count chars from a to z
19:13
<
phaul >
&ri String#count
19:14
<
phaul >
&>> "xyz!".count("a-z")
19:14
<
leftylink >
that is cool
19:17
jottr has quit [Ping timeout: 268 seconds]
19:17
<
Swyper >
&>> "xyzZZ!".count("a-z")
19:18
<
Swyper >
&>> "xyzZZ!".count("a-z" || "A-Z")
19:18
<
Swyper >
phaul: anyway to make it inclusive for uppercase character aswell?
19:18
<
phaul >
&>> "xyz!".count("a-zA-Z")
19:18
<
phaul >
&>> "xyz!".downcase.count("a-z")
19:18
<
phaul >
im an idiot
19:19
<
phaul >
&>> "xyzZZ!".count("a-zA-Z")
19:19
<
phaul >
that's what I meant
19:19
<
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
<
Swyper >
leftylink: I'm just trying to figure out the logic with which it works
19:19
<
leftylink >
so the attempt of `"xyzZZ!".count("a-z" || "A-Z")` is exactly equal to `"xyzZZ!".count("a-z")`
19:20
<
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
<
leftylink >
`"a-z" || "A-Z"` is evaluated just as it would be in any other context
19:21
<
phaul >
also worth noting that 'a-z' or 'a-zA-Z' are just strings and String#count implements some special behaviour for them if the argument matches a certain pattern
19:25
Mike11 has joined #ruby
19:31
KazeFX has joined #ruby
19:33
<
phaul >
&>> %w(a A).map(&:ord)
19:35
<
phaul >
so it would seem that string.count(A-z) would also work, but it would count chars in in between the lower alpha and upper alpha ranges
19:35
hutch has joined #ruby
19:38
<
Iambchop >
&>> (?Z..?a).to_a.join
19:42
tdy has joined #ruby
19:48
tdy has quit [Remote host closed the connection]
19:48
donofrio has joined #ruby
19:49
dviola has quit [Quit: WeeChat 2.3]
19:55
jottr has joined #ruby
19:57
<
Swyper >
copy_of_string = string.map.with_index { |word, i| word.count("a-zA-Z") }
19:57
<
Swyper >
I need to get the two longest strings without accounting for anything thats not a letter
19:57
<
Swyper >
if I do .sort then I end up just the counts in numerical order
19:57
<
Swyper >
any ideas for how I can get the top 2 longest alphabetical strings?
19:57
<
Swyper >
using what i have now, ideally
19:59
<
leftylink >
&ri Enumerable#max_by
19:59
<
leftylink >
is my suggestion
19:59
dinfuehr has quit [Ping timeout: 245 seconds]
20:00
jottr has quit [Ping timeout: 246 seconds]
20:01
laaron- has joined #ruby
20:02
dinfuehr has joined #ruby
20:02
<
leftylink >
or, if you insist on keeping the separate array of # of letters of each string, then you want Array#zip
20:03
agent_white has quit [Quit: bbl]
20:04
laaron has quit [Ping timeout: 256 seconds]
20:05
<
Swyper >
I suppose I need the words sorted in order by word.count("a-zA-Z")
20:05
<
Swyper >
this map would just give me a count of each element in the array with the parameters given in Count
20:05
<
Swyper >
but I need to output the original elements
20:06
<
Swyper >
the top 2 longest alphabetical elements
20:06
<
leftylink >
my suggestion stnads.
20:06
<
leftylink >
or I guess you can use Enumerable#sort_by if you want
20:09
uplime has joined #ruby
20:15
sidepocket has quit [Ping timeout: 256 seconds]
20:15
<
Swyper >
I'm finding this one to be
*very* confusing
20:16
<
Swyper >
tests + current code
20:18
<
phaul >
Swyper: what are the two things passed to the block of sort_by?
20:19
<
phaul >
&ri Enumerable#sort_by
20:19
<
Swyper >
sorry that should not be there
20:19
<
Swyper >
but the errors are still the same
20:20
<
Swyper >
copy_of_string = string.split.sort_by { |word| word.count("a-zA-Z") }
20:20
<
Swyper >
return copy_of_string[copy_of_string.length-1] + copy_of_string[copy_of_string.length-2]
20:20
<
phaul >
which part of the error confuses you? we can explain
20:21
raulp has quit [Ping timeout: 272 seconds]
20:23
raulp has joined #ruby
20:24
<
phaul >
first is really just coomplaining that 2 != 14. The test is not the best that's why it's outputting that small novel about oobjects not being the same. If you change it to expect(longest_two_words(string).length).to eq 2 it would output something more sane
20:27
polishdub has quit [Quit: leaving]
20:28
<
Swyper >
ah phaul thanks I'll update the test and report back
20:41
garyserj has joined #ruby
20:43
<
Swyper >
gives me an error xD
20:46
<
leftylink >
you forgot to say what error.
20:50
Aqo has quit [Quit: ChatZilla 0.9.92-rdmsoft [XULRunner 35.0.1/20150122214805]]
20:50
<
Swyper >
undefined local variable or method `actual' for #<RSpec::ExampleGroups::EnumerablesPart2::LongestTwoWords:0x00007f804c99fec0>
20:50
<
leftylink >
then you should define it
20:50
<
leftylink >
if you expect the test to work
20:51
venmx has joined #ruby
20:53
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
20:54
tiff has joined #ruby
20:54
tiff has quit [Client Quit]
20:54
tiff has joined #ruby
20:54
tiff has quit [Client Quit]
21:00
laaron has joined #ruby
21:02
laaron- has quit [Remote host closed the connection]
21:04
SeepingN has joined #ruby
21:05
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
21:05
BTRE has quit [Ping timeout: 250 seconds]
21:05
donofrio has quit [Read error: Connection reset by peer]
21:06
BTRE has joined #ruby
21:07
Swyper has quit [Remote host closed the connection]
21:08
sandelius has joined #ruby
21:09
tiff has joined #ruby
21:09
dellavg_ has quit [Ping timeout: 244 seconds]
21:16
<
phaul >
they are gone ... they were trying to fix the eq, but followed the rspec recommendation which just used generic terms like expected , actual.
21:20
connermcd has joined #ruby
21:23
hutch has quit [Ping timeout: 244 seconds]
21:29
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
21:31
kapil____ has quit [Quit: Connection closed for inactivity]
21:31
hutch has joined #ruby
21:41
tiff has joined #ruby
21:41
nowhere_man has joined #ruby
21:44
irdr has quit [Remote host closed the connection]
21:47
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
21:51
m0w has joined #ruby
22:02
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
22:04
hutch has quit [Ping timeout: 250 seconds]
22:06
hutch has joined #ruby
22:07
ruby[bot] has quit [Remote host closed the connection]
22:07
ruby[bot] has joined #ruby
22:12
cd has joined #ruby
22:12
Mike11 has quit [Quit: Leaving.]
22:13
uplime has quit [Ping timeout: 250 seconds]
22:18
hutch has quit [Ping timeout: 246 seconds]
22:20
kapil____ has joined #ruby
22:20
masterasia has joined #ruby
22:21
Swyper has joined #ruby
22:22
<
Swyper >
object identity in this example.
22:22
<
Swyper >
why are the objects not the same? is it because string is immutable ?
22:22
<
leftylink >
because 2 != 14
22:22
<
phaul >
Swyper: sorry I was away from keyboard I coulnt respond
22:22
<
Swyper >
no problem
22:23
<
leftylink >
or, well, 2.equal?(14) was false, to be more precise
22:23
irdr has joined #ruby
22:23
<
leftylink >
but I was imprecise and just said !=
22:23
<
Swyper >
so how do I fix the error can you give me some hints
22:24
masterasia has quit [Client Quit]
22:25
<
phaul >
first of just insert the .to eq(2) instead of .to be(2) , don't replace the whole thing
22:25
<
phaul >
that should get rid of some of the confusing parts.
22:26
<
phaul >
Then you will have to figure out why your algorithm is returning 14 instead of 2
22:27
<
phaul >
the actual and expected are just generic terms in the rspec message, and if you take them literarly they are not defined
22:27
<
baweaver >
&>> [1,2,3,4,5].last(2)
22:27
<
baweaver >
`return` isn't really needed in ruby either.
22:28
<
baweaver >
Also you're quite literally returning both of the strings as one string
22:28
<
baweaver >
instead of as an array, which is probably what you intended.
22:30
<
baweaver >
&>> 'some words are longer than other words, who would have thought?'.split.max_by(2) { |w| w.count('a-zA-Z') }
22:30
<
baweaver >
Interesting part is that that
_includes_ punctuation
22:30
<
baweaver >
not in the count, but in the return.
22:33
tdy has joined #ruby
22:34
<
Swyper >
I made that so much harder then it needed to be
22:34
<
baweaver >
That phrase gets far more common the more programming one does.
22:36
tiff has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
22:40
memofun has joined #ruby
22:45
memofun has quit [Ping timeout: 240 seconds]
22:46
hiroaki has joined #ruby
22:48
dviola has joined #ruby
22:52
sandelius has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
22:54
davidw_ has joined #ruby
22:55
orbyt_ has joined #ruby
23:00
laaron- has joined #ruby
23:02
laaron has quit [Remote host closed the connection]
23:05
Swyper has quit [Remote host closed the connection]
23:15
uplime has joined #ruby
23:18
hutch has joined #ruby
23:21
m0w has quit [Ping timeout: 244 seconds]
23:21
catbusters has quit [Quit: Connection closed for inactivity]
23:26
khanred has joined #ruby
23:28
venmx has quit [Ping timeout: 244 seconds]
23:30
rkazak has joined #ruby
23:32
lytol has quit [Remote host closed the connection]
23:32
khanred has left #ruby ["Leaving"]
23:32
umjisus has joined #ruby
23:42
jthomas2 has quit [Ping timeout: 245 seconds]
23:47
nowhere_man has quit [Ping timeout: 252 seconds]
23:50
nowhere_man has joined #ruby
23:52
masterasia has joined #ruby
23:57
SeepingN has joined #ruby
23:58
connermcd has quit [Quit: WeeChat 2.3]
23:58
hutch has quit [Ping timeout: 244 seconds]