Logs: freenode/#haskell
| 2020-10-21 10:18:25 | <merijn> | It is, tbh, a rather inefficient way of doing things, but hey |
| 2020-10-21 10:18:42 | <ski> | then, checking whether such a tail starts with the needle, amounts to checking whether they hay stack contains the needle somewhere |
| 2020-10-21 10:19:55 | × | nineonin_ quits (~textual@216-19-190-182.dyn.novuscom.net) (Client Quit) |
| 2020-10-21 10:22:25 | <Echosolace> | I need to play around some more. |
| 2020-10-21 10:24:44 | × | michalrus quits (m@michalrus.com) (Ping timeout: 265 seconds) |
| 2020-10-21 10:25:33 | <Echosolace> | If I have fruitlist = ["strawberry","green apple","red apple","apple granny"] |
| 2020-10-21 10:25:45 | <Echosolace> | and I search for ["apple"] |
| 2020-10-21 10:25:52 | <Echosolace> | I get False. |
| 2020-10-21 10:26:13 | <Echosolace> | I think this is because: |
| 2020-10-21 10:26:17 | <Echosolace> | take nlen x == needle |
| 2020-10-21 10:26:37 | <Echosolace> | We are taking the length of needle's worth of element x... |
| 2020-10-21 10:26:50 | <Echosolace> | But... I'm kinda surprised. |
| 2020-10-21 10:27:07 | <Echosolace> | nlen of apple is 5. |
| 2020-10-21 10:27:09 | <merijn> | Echosolace: That does a different thing |
| 2020-10-21 10:27:13 | <merijn> | Echosolace: no |
| 2020-10-21 10:27:16 | <Echosolace> | Oh... |
| 2020-10-21 10:27:22 | <merijn> | Echosolace: Or rather, yes, but that's not what you're doing |
| 2020-10-21 10:27:33 | <merijn> | You're taking the length of ["apple"], which is 1 |
| 2020-10-21 10:27:42 | <Echosolace> | Ah. |
| 2020-10-21 10:27:48 | <merijn> | It's a list containing one string |
| 2020-10-21 10:27:48 | × | stefan-__ quits (~cri@42dots.de) (Read error: Connection reset by peer) |
| 2020-10-21 10:27:56 | <Echosolace> | Ok I need to go back and rethink a lot one sec. |
| 2020-10-21 10:28:08 | <merijn> | and then you're checking if any of the strings in your other list match "apple" (to which the answer is "no") |
| 2020-10-21 10:28:11 | → | stefan-__ joins (~cri@42dots.de) |
| 2020-10-21 10:28:19 | × | jol quits (~jol@jol.dev) (Ping timeout: 246 seconds) |
| 2020-10-21 10:28:25 | <merijn> | Echosolace: Consider the type of search |
| 2020-10-21 10:28:37 | <merijn> | "Eq a => [a] -> [a] -> Bool" |
| 2020-10-21 10:28:50 | <ski> | @let search :: Eq a => [a] -> [a] -> Bool; search needle haystack = foldl (\acc x -> if take nlen x == needle then True else acc) False (tails haystack) where nlen = length needle |
| 2020-10-21 10:28:50 | <merijn> | it's checking whether the first list appears inside the second one |
| 2020-10-21 10:28:51 | <lambdabot> | Defined. |
| 2020-10-21 10:28:53 | × | cristi_ quits (~cristi@82.76.158.82) (Quit: cristi_) |
| 2020-10-21 10:28:58 | × | bartemius quits (~bartemius@109.252.19.142) (Remote host closed the connection) |
| 2020-10-21 10:29:03 | <merijn> | Does the list ["apple"] occur inside your second list? No |
| 2020-10-21 10:29:11 | <ski> | > search ["apple"] ["strawberry","green apple","red apple","apple granny"] |
| 2020-10-21 10:29:12 | × | cyberlard quits (~cyberlard@unaffiliated/jludwig) (Ping timeout: 256 seconds) |
| 2020-10-21 10:29:13 | <lambdabot> | False |
| 2020-10-21 10:29:23 | <ski> | > search ["green apple"] ["strawberry","green apple","red apple","apple granny"] |
| 2020-10-21 10:29:24 | <Echosolace> | I see that. Thanks. |
| 2020-10-21 10:29:26 | <lambdabot> | True |
| 2020-10-21 10:29:27 | <merijn> | Echosolace: 'search "apple" "apple granny"' otoh should work |
| 2020-10-21 10:29:34 | → | michalrus joins (m@michalrus.com) |
| 2020-10-21 10:29:36 | <ski> | > search ["green apple","red apple"] ["strawberry","green apple","red apple","apple granny"] |
| 2020-10-21 10:29:37 | <lambdabot> | True |
| 2020-10-21 10:29:57 | <ski> | > search "apple" "apple granny" |
| 2020-10-21 10:30:00 | <lambdabot> | True |
| 2020-10-21 10:30:29 | → | cyberlard joins (~cyberlard@unaffiliated/jludwig) |
| 2020-10-21 10:30:43 | <lortabac> | idnar: if your purpose is running multiple actions concurrently you can use the Applicative instance of Concurrently |
| 2020-10-21 10:30:58 | → | m0rphism joins (~m0rphism@HSI-KBW-046-005-177-122.hsi8.kabel-badenwuerttemberg.de) |
| 2020-10-21 10:31:44 | → | nicknick joins (75d746c7@117.215.70.199) |
| 2020-10-21 10:34:40 | → | worc3131 joins (~quassel@2a02:c7f:c026:9500:a0d2:b9d1:42a4:69b4) |
| 2020-10-21 10:34:49 | → | jol joins (~jol@jol.dev) |
| 2020-10-21 10:34:52 | <Echosolace> | Ok I've got that main function body figured out, but in the case of fruitlist = ["strawberry","apple","orange","banana"], I wonder if I search for apple why it wouldn't eventually return false, because after iterating to orange or banana, the accumulator would turn False. |
| 2020-10-21 10:35:21 | <Echosolace> | Right? |
| 2020-10-21 10:35:53 | <Echosolace> | Or wait... |
| 2020-10-21 10:36:01 | <Echosolace> | Once it turns true it's always true. |
| 2020-10-21 10:37:06 | <Echosolace> | I still don't see where tails haystack is called. |
| 2020-10-21 10:37:12 | <Echosolace> | in foldl (\acc x -> if take nlen x == needle then True else acc) False (tails haystack) |
| 2020-10-21 10:37:28 | → | heatsink joins (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) |
| 2020-10-21 10:37:38 | → | acidjnk_new2 joins (~acidjnk@p200300d0c7237831d40d0866fc0488e0.dip0.t-ipconnect.de) |
| 2020-10-21 10:38:30 | × | acidjnk_new2 quits (~acidjnk@p200300d0c7237831d40d0866fc0488e0.dip0.t-ipconnect.de) (Remote host closed the connection) |
| 2020-10-21 10:38:51 | × | Lord_of_Life quits (~Lord@46.217.218.115) (Read error: Connection reset by peer) |
| 2020-10-21 10:39:03 | → | acidjnk_new2 joins (~acidjnk@p200300d0c7237831d40d0866fc0488e0.dip0.t-ipconnect.de) |
| 2020-10-21 10:39:18 | → | Lord_of_Life joins (~Lord@46.217.218.115) |
| 2020-10-21 10:39:18 | × | Lord_of_Life quits (~Lord@46.217.218.115) (Changing host) |
| 2020-10-21 10:39:18 | → | Lord_of_Life joins (~Lord@unaffiliated/lord-of-life/x-0885362) |
| 2020-10-21 10:40:31 | × | acidjnk_new2 quits (~acidjnk@p200300d0c7237831d40d0866fc0488e0.dip0.t-ipconnect.de) (Remote host closed the connection) |
| 2020-10-21 10:40:52 | × | bliminse quits (~bliminse@host109-158-54-87.range109-158.btcentralplus.com) (Ping timeout: 272 seconds) |
| 2020-10-21 10:40:52 | <nicknick> | Is there any bot here who can solve this? |
| 2020-10-21 10:40:54 | <nicknick> | f :: Num a => a -> a -> a |
| 2020-10-21 10:41:01 | → | acidjnk_new2 joins (~acidjnk@p200300d0c7237831d40d0866fc0488e0.dip0.t-ipconnect.de) |
| 2020-10-21 10:41:11 | <nicknick> | I need to convert f :: Num a => a -> a -> a to function. |
| 2020-10-21 10:41:23 | × | alp quits (~alp@2a01:e0a:58b:4920:785c:23a0:93c6:f784) (Ping timeout: 272 seconds) |
| 2020-10-21 10:41:36 | <ski> | f x y = x |
| 2020-10-21 10:41:39 | <ski> | how about that ? |
| 2020-10-21 10:42:06 | <nicknick> | What if it is more complex? |
| 2020-10-21 10:42:07 | <nicknick> | f :: Num a => (a -> a -> a) -> a -> [a] -> [a] |
| 2020-10-21 10:42:18 | × | heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 256 seconds) |
| 2020-10-21 10:42:25 | <ski> | f _ _ _ = [] |
| 2020-10-21 10:42:52 | <nicknick> | Ikea rocks :) |
| 2020-10-21 10:42:58 | <nicknick> | Are you God or a bot? |
| 2020-10-21 10:43:05 | <Echosolace> | That's exactly what I was thinking. |
| 2020-10-21 10:43:10 | <ski> | Echosolace : `tails haystack' is called in the last actual parameter of that `foldl' call |
| 2020-10-21 10:43:26 | <Echosolace> | Right, I got that from my most recent error after deleting that segment. |
| 2020-10-21 10:43:36 | <Echosolace> | Thanks. |
| 2020-10-21 10:43:39 | × | babygnu quits (~robert@gateway/tor-sasl/babygnu) (Quit: Leaving) |
| 2020-10-21 10:43:42 | <ski> | (it literally says `tails haystack', there) |
| 2020-10-21 10:43:46 | <Echosolace> | >:t foldl |
| 2020-10-21 10:43:52 | <ski> | @type foldl |
| 2020-10-21 10:43:53 | <lambdabot> | Foldable t => (b -> a -> b) -> b -> t a -> b |
| 2020-10-21 10:44:13 | <Echosolace> | Ok that I have major trouble understanding. |
| 2020-10-21 10:44:14 | <ski> | @type foldl :: (s -> a -> s) -> s -> [a] -> s |
| 2020-10-21 10:44:15 | <lambdabot> | (s -> a -> s) -> s -> [a] -> s |
| 2020-10-21 10:44:34 | <ski> | `s' is the type of the accumulator state. `a' is the element type of the list |
| 2020-10-21 10:45:00 | <ski> | (the version with `Foldable' is more general, in that it can also work over other ordered collections than lists) |
| 2020-10-21 10:45:23 | × | sleepingisfun quits (~sleepingi@168.235.93.188) (Quit: hewwo) |
| 2020-10-21 10:45:47 | <nicknick> | How can I use lambdabot to solve this? f :: Num a => (a -> a -> a) -> a -> [a] -> [a] |
| 2020-10-21 10:46:31 | <ski> | no |
| 2020-10-21 10:46:42 | → | bliminse joins (~bliminse@host109-158-26-29.range109-158.btcentralplus.com) |
| 2020-10-21 10:46:49 | <nicknick> | Sad :( |
| 2020-10-21 10:47:00 | <ski> | @djinn (a -> (b,c)) -> (a -> b,a -> c) |
All times are in UTC.