Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→
Page 1 .. 769 770 771 772 773 774 775 776 777 778 779 .. 5022
502,152 events total
2020-10-21 09:21:42 bergsans joins (~bergsans@c80-217-8-29.bredband.comhem.se)
2020-10-21 09:21:43 tlockney joins (~tlockney@185.204.1.185)
2020-10-21 09:22:13 × alp quits (~alp@2a01:e0a:58b:4920:214e:c6f7:dc70:92ac) (Ping timeout: 272 seconds)
2020-10-21 09:23:36 × heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 272 seconds)
2020-10-21 09:24:22 geowiesnot joins (~user@i15-les02-ix2-87-89-181-157.sfr.lns.abo.bbox.fr)
2020-10-21 09:25:01 jmtd is now known as Jon
2020-10-21 09:27:07 × GyroW quits (~GyroW@unaffiliated/gyrow) (Quit: Someone ate my pie)
2020-10-21 09:27:17 GyroW joins (~GyroW@d54C03E98.access.telenet.be)
2020-10-21 09:27:17 × GyroW quits (~GyroW@d54C03E98.access.telenet.be) (Changing host)
2020-10-21 09:27:17 GyroW joins (~GyroW@unaffiliated/gyrow)
2020-10-21 09:27:31 ubert joins (~Thunderbi@2a02:8109:9880:303c:ca5b:76ff:fe29:f233)
2020-10-21 09:28:26 Chi1thangoo joins (~Chi1thang@87.112.60.168)
2020-10-21 09:28:29 heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net)
2020-10-21 09:32:01 <Echosolace> I can't get this code to (compile? Is that even the right word?) compile. From LYAH:
2020-10-21 09:32:02 <Echosolace> search :: (Eq a) => [a] -> [a] -> Bool
2020-10-21 09:32:03 <Echosolace> search needle haystack =
2020-10-21 09:32:03 <Echosolace> let nlen = length needle
2020-10-21 09:32:03 <Echosolace> in foldl (\acc x -> if take nlen x == needle then True else acc) False (tails haystack)
2020-10-21 09:32:05 arw joins (~arw@impulse.informatik.uni-erlangen.de)
2020-10-21 09:32:18 <Echosolace> First error suggesting that I change tails to tail...
2020-10-21 09:32:25 <Echosolace> When I do that, more errors.
2020-10-21 09:32:43 <Echosolace> Just wanting to play with that function so I can try to get a better understanding of how it works.
2020-10-21 09:33:30 <Echosolace> Anybody have a suggestion?
2020-10-21 09:33:44 × heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 272 seconds)
2020-10-21 09:34:27 <ski> @type let search :: Eq a => [a] -> [a] -> Bool; search needle haystack = let nlen = length needle in foldl (\acc x -> if take nlen x == needle then True else acc) False (tails haystack) in search
2020-10-21 09:34:28 <lambdabot> Eq a => [a] -> [a] -> Bool
2020-10-21 09:34:41 <ski> what's the (first) error you get ?
2020-10-21 09:34:58 <Echosolace> <interactive>:7:78: error:
2020-10-21 09:34:58 <Echosolace> * Variable not in scope: tails :: [a] -> t0 [a]
2020-10-21 09:34:58 <Echosolace> * Perhaps you meant `tail' (imported from Prelude)
2020-10-21 09:35:04 <ski> @index tails
2020-10-21 09:35:05 <lambdabot> GHC.OldList, Data.List, Data.ByteString.Lazy, Data.ByteString.Lazy.Char8, Data.ByteString, Data.ByteString.Char8, Data.Sequence
2020-10-21 09:35:09 <Echosolace> After fixing this is the second error:
2020-10-21 09:35:12 <ski> use
2020-10-21 09:35:15 <int-e> import Data.List
2020-10-21 09:35:15 <ski> import Data.List
2020-10-21 09:35:23 <Echosolace> Oohhhhhh
2020-10-21 09:35:27 <Echosolace> Yeah that makes sense...
2020-10-21 09:35:30 __monty__ joins (~toonn@unaffiliated/toonn)
2020-10-21 09:35:38 <int-e> Don't follow ghc's suggestions blindly, it has almost no clue.
2020-10-21 09:36:16 <int-e> > tails "abc"
2020-10-21 09:36:18 <lambdabot> ["abc","bc","c",""]
2020-10-21 09:36:23 <int-e> > tail "abc"
2020-10-21 09:36:25 <lambdabot> "bc"
2020-10-21 09:36:56 <int-e> (that's a huge difference)
2020-10-21 09:36:58 <Echosolace> Domo
2020-10-21 09:38:07 <Echosolace> I'm attempting this...
2020-10-21 09:38:08 <Echosolace> Prelude> :{
2020-10-21 09:38:08 <Echosolace> Prelude| import Data.list
2020-10-21 09:38:08 <Echosolace> Prelude| search :: (Eq a) => [a] -> [a] -> Bool
2020-10-21 09:38:08 <Echosolace> Prelude| search needle haystack =
2020-10-21 09:38:08 <Echosolace> Prelude| let nlen = length needle
2020-10-21 09:38:09 <Echosolace> Prelude| in foldl (\acc x -> if take nlen x == needle then True else acc) False (tails haystack)
2020-10-21 09:38:11 <Echosolace> Prelude| :}
2020-10-21 09:38:22 <ski> Echosolace : anyway, you should use a logical operator, instead of an `if'-`then'-`else' with `True' or `False' as one (or both) branches
2020-10-21 09:38:48 heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net)
2020-10-21 09:39:04 <Echosolace> Just trying to still wrap my head around this stuff. I'm still working on understanding the in part of that function.
2020-10-21 09:39:16 <Echosolace> But I still can't run it. Getting a parse error on input 'Data.list'
2020-10-21 09:39:20 <Echosolace> Did I import wrong?
2020-10-21 09:39:29 <ski> Echosolace : it might also be nice to put definitions in a source file (using your favorite text editor), and then (after saving) (re)load that file into the interactor
2020-10-21 09:39:33 <ski> should be `Data.List'
2020-10-21 09:39:43 <Echosolace> Ok thanks.
2020-10-21 09:39:43 <merijn> Echosolace: tbh, I would recommend not trying to write large definitions in ghci, just write it in a file and ":load" it
2020-10-21 09:40:01 <Echosolace> Ok, I'll do that.
2020-10-21 09:41:52 × st8less quits (~st8less@2603:a060:11fd:0:149e:8518:62e1:ca1b) (Quit: WeeChat 2.7.1)
2020-10-21 09:42:38 nlhowell joins (~nlhowell@89.20.140.186)
2020-10-21 09:42:39 × lemmih quits (~lemmih@2406:3003:2072:44:508f:7862:5b0d:296) (Read error: Connection reset by peer)
2020-10-21 09:42:47 <ski> > "abc" `isPrefixOf` "abdef"
2020-10-21 09:42:49 <lambdabot> False
2020-10-21 09:42:59 lemmih joins (~lemmih@2406:3003:2072:44:b4a2:1d9:b4d8:a595)
2020-10-21 09:43:01 <Echosolace> Ok, now that I've got the search function loaded in my new sandbox.hs file into GHCI, I figure I could run search of "apple" over a list of fruits.
2020-10-21 09:43:03 × heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 258 seconds)
2020-10-21 09:43:26 <ski> > "abc" `isPrefixOf` "abcdef"
2020-10-21 09:43:28 <lambdabot> True
2020-10-21 09:44:22 <Echosolace> The meat of this function is:
2020-10-21 09:44:23 <Echosolace> foldl (\acc x -> if take nlen x == needle then True else acc) False (tails haystack)
2020-10-21 09:45:12 <Echosolace> nlen is the length of the word apple, which is why I wonder if this search function could apply...
2020-10-21 09:45:28 × CourtneyNZ quits (~CourtneyN@ec2-52-63-156-37.ap-southeast-2.compute.amazonaws.com) (Quit: Leaving)
2020-10-21 09:45:35 × shatriff quits (~vitaliish@176.52.219.10) (Ping timeout: 265 seconds)
2020-10-21 09:45:49 <ski> if `take nlen x == needle' is true, then we give `True', else we give `acc'
2020-10-21 09:46:14 <int-e> any (needle `isPrefixOf`) (tails haystack) <-- what I might write if I didn't know about `isInfixOf`.
2020-10-21 09:46:22 shatriff joins (~vitaliish@176.52.219.10)
2020-10-21 09:46:28 <ski> so `if take nlen x == needle then True else acc' is true if (and only if) ... ? (something about `take nlen x == needle' and `acc')
2020-10-21 09:46:37 <ski> Echosolace : can you fill in the "..." ?
2020-10-21 09:47:03 <Echosolace> ... to the search function.
2020-10-21 09:47:12 <Echosolace> Err wait... disregard
2020-10-21 09:47:42 <Echosolace> nlen of apple is 5.
2020-10-21 09:48:50 heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net)
2020-10-21 09:48:58 × justanotheruser quits (~justanoth@unaffiliated/justanotheruser) (Ping timeout: 260 seconds)
2020-10-21 09:49:08 <Echosolace> Oh man, I need some more time... Nevermind.
2020-10-21 09:49:56 alp joins (~alp@2a01:e0a:58b:4920:785c:23a0:93c6:f784)
2020-10-21 09:53:09 × ffviewer quits (3dded63f@61-222-214-63.HINET-IP.hinet.net) (Remote host closed the connection)
2020-10-21 09:53:34 × heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 256 seconds)
2020-10-21 09:56:46 × scav quits (sid309693@gateway/web/irccloud.com/x-thdromwvanysldso) ()
2020-10-21 09:57:07 scav joins (sid309693@gateway/web/irccloud.com/x-zlttbvsvkfeaapza)
2020-10-21 09:57:11 × Tario quits (~Tario@201.192.165.173) (Ping timeout: 265 seconds)
2020-10-21 09:57:21 <Echosolace> My search of my fruit over my fruitlist was successful, but my understanding about how the meat of the function progresses is where I am confused... For reference again:
2020-10-21 09:57:23 <Echosolace> in foldl (\acc x -> if take nlen x == needle then True else acc) False (tails haystack)
2020-10-21 09:57:37 <Echosolace> So, foldl is a binomial function.
2020-10-21 09:58:03 Tario joins (~Tario@201.192.165.173)

All times are in UTC.