Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,803,481 events total
2021-07-26 01:36:20 <Axman6> =)
2021-07-26 01:36:38 <euouae> Nice wow
2021-07-26 01:36:44 <euouae> Came a long way from https://mail.haskell.org/pipermail/haskell-cafe/2010-October/084952.html which I just found
2021-07-26 01:36:57 <Axman6> understanding how that works is pretty fun
2021-07-26 01:37:11 <Axman6> > replicateM 10 [0,1]
2021-07-26 01:37:13 <euouae> I think it's sort of coming back to me. You're using ++ as a monad
2021-07-26 01:37:13 <lambdabot> [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0,1,0],[0,0,0,0,...
2021-07-26 01:37:22 <euouae> I mean, List as a monad, with ++
2021-07-26 01:37:48 <Axman6> well, list _is_ a monad
2021-07-26 01:38:03 bitmapper joins (uid464869@id-464869.tooting.irccloud.com)
2021-07-26 01:39:16 <Axman6> but the summary is that replicateM n m is equivalent to do { a <- m; b <- m; ... x <-; m return [a,b,...x] }
2021-07-26 01:41:12 <euouae> Right, I can't remember why a <- m goes over all elements of a list
2021-07-26 01:41:56 <janus> if it only requires applicative, why isn't there a synonym called replicateA?
2021-07-26 01:42:29 <Axman6> concatMap (\a -> ...) m
2021-07-26 01:43:46 × curiousgay quits (~curiousga@77-120-186-48.kha.volia.net) (Ping timeout: 240 seconds)
2021-07-26 01:44:05 <Axman6> @src concatMap
2021-07-26 01:44:05 <lambdabot> concatMap f = foldr ((++) . f) []
2021-07-26 01:44:10 <Axman6> clear as mud
2021-07-26 01:45:08 <euouae> What do you do with camelCase if the first word is a name?
2021-07-26 01:45:12 <euouae> I guess it is what it is?
2021-07-26 01:46:21 <Axman6> yes
2021-07-26 01:46:29 <Axman6> lower case only for variable names
2021-07-26 01:48:53 <janus> hmm interesting how there is sequence/sequenceA but only one replicateM. i wonder if it is because of performance reasons?
2021-07-26 01:54:50 × Guest57 quits (~Guest57@50.47.115.102) (Quit: Client closed)
2021-07-26 01:55:45 curiousgay joins (~curiousga@77-120-186-48.kha.volia.net)
2021-07-26 01:56:17 × nate3 quits (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 258 seconds)
2021-07-26 01:58:04 agua joins (~agua@2804:14c:8793:8e2f:39e9:c5a8:c532:7498)
2021-07-26 01:58:41 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 255 seconds)
2021-07-26 02:01:05 × pesada quits (~agua@2804:18:4f:4b5e:1:0:5480:48f9) (Ping timeout: 252 seconds)
2021-07-26 02:03:21 <euouae> How would you write a function that does the following : [Bool] -> [Int] and f [True, False, True] = +1/2 - 1/2^2 + 1/2^3 ?
2021-07-26 02:04:01 <euouae> The type should be [Bool] -> Int. I'm trying to write one using a map and zip with [1..] to keep track of the position in the list. I think there might be a better way, not sure
2021-07-26 02:05:06 × td_ quits (~td@muedsl-82-207-238-027.citykom.de) (Ping timeout: 240 seconds)
2021-07-26 02:07:01 td_ joins (~td@muedsl-82-207-238-113.citykom.de)
2021-07-26 02:08:10 × curiousgay quits (~curiousga@77-120-186-48.kha.volia.net) (Ping timeout: 258 seconds)
2021-07-26 02:12:49 <dsal> euouae: Your definition demonstrates boolean blindness.
2021-07-26 02:13:09 <euouae> I have this code, including the error: https://paste.tomsmeding.com/W9kwWzbT I don't understand it
2021-07-26 02:13:17 <euouae> deal: What do you mean?
2021-07-26 02:13:34 <dsal> What does true mean here?
2021-07-26 02:13:53 <euouae> It's a way to encode the +-
2021-07-26 02:14:32 <dsal> Why not just just + and -?
2021-07-26 02:14:33 <euouae> Are you saying that I should've written it so that +1, -1 are directly in the combinations instead of True/False?
2021-07-26 02:14:43 <janus> no need for map: f inputsbools = sum [x | (y, positive) <- zip [1..] inputbools; let x = (if positive then 1 else (-1)) * (1/2^y)]
2021-07-26 02:14:53 <dsal> Or succ/pred
2021-07-26 02:15:00 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-07-26 02:15:12 <euouae> succ/pred doesn't sound right, I plan to use it multiplicatively
2021-07-26 02:16:09 <euouae> I'll change it to +-1
2021-07-26 02:17:25 <euouae> I think I found my issue, I can't multiply Int with Ratio
2021-07-26 02:17:55 nate3 joins (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net)
2021-07-26 02:18:14 <dsal> > cycle [1, -1]
2021-07-26 02:18:16 <lambdabot> [1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,...
2021-07-26 02:19:16 <janus> i don't understand why cycle is useful since i thought it only cycles between - and + because of that specific example, but not in general
2021-07-26 02:19:17 × jao quits (~jao@cpc103048-sgyl39-2-0-cust502.18-2.cable.virginm.net) (Ping timeout: 258 seconds)
2021-07-26 02:20:03 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 258 seconds)
2021-07-26 02:20:08 <Axman6> > zipWith (*) (cycle [1,-1]) (iterate (/2) 1)
2021-07-26 02:20:10 <lambdabot> [1.0,-0.5,0.25,-0.125,6.25e-2,-3.125e-2,1.5625e-2,-7.8125e-3,3.90625e-3,-1.9...
2021-07-26 02:20:28 <Axman6> > scanl (+) 0 $ zipWith (*) (cycle [1,-1]) (iterate (*0.5) 1)
2021-07-26 02:20:29 <lambdabot> [0.0,1.0,0.5,0.75,0.625,0.6875,0.65625,0.671875,0.6640625,0.66796875,0.66601...
2021-07-26 02:21:13 <euouae> That doesn't seem right
2021-07-26 02:21:22 <euouae> I want 0, 1, 0.5, 0.75, 0.25, ...
2021-07-26 02:21:27 × derelict quits (~derelict@user/derelict) (Ping timeout: 276 seconds)
2021-07-26 02:21:41 <euouae> I'm using the replicateM solution above
2021-07-26 02:22:14 <janus> the second exampe does give that sequence...
2021-07-26 02:22:43 <Axman6> > zipWith (*) (cycle [1,-1]) (iterate (/2) 1)
2021-07-26 02:22:44 × aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net)
2021-07-26 02:22:45 <lambdabot> [1.0,-0.5,0.25,-0.125,6.25e-2,-3.125e-2,1.5625e-2,-7.8125e-3,3.90625e-3,-1.9...
2021-07-26 02:23:01 aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net)
2021-07-26 02:23:02 × nate3 quits (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 265 seconds)
2021-07-26 02:23:04 <janus> oh, no, the fourth is 0.75 and not 0.25
2021-07-26 02:23:29 × aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Client Quit)
2021-07-26 02:23:44 <euouae> binaryToCenter ratio xs = map (\j b -> ratio^j) (zip [1..] xs) -- even this fails
2021-07-26 02:24:36 <janus> euouae: do you know about fromRational?
2021-07-26 02:24:53 <janus> or maybe toRational is better here..
2021-07-26 02:25:01 aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net)
2021-07-26 02:25:17 <euouae> Where is the conflict? I can't tell
2021-07-26 02:25:43 × aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Client Quit)
2021-07-26 02:25:59 <euouae> `(3 % 4) ^ (3 :: Int) -- seems to work fine`
2021-07-26 02:26:12 <pavonia> euouae: What is the math behind your series?
2021-07-26 02:26:31 <euouae> pavonia: centers of cantor set n-th level construction
2021-07-26 02:27:39 justsomeguy joins (~justsomeg@user/justsomeguy)
2021-07-26 02:27:59 <janus> % (3 % 4) ^ (3::Int)
2021-07-26 02:28:00 <yahb> janus: 27 % 64
2021-07-26 02:30:08 <euouae> Oh I also have an issue with how I unpack the arguments with the lambda, it's a tuple ...
2021-07-26 02:30:21 <justsomeguy> /c/c
2021-07-26 02:30:56 finn_elija joins (~finn_elij@user/finn-elija/x-0085643)
2021-07-26 02:30:56 FinnElija is now known as Guest7424
2021-07-26 02:30:56 × Guest7424 quits (~finn_elij@user/finn-elija/x-0085643) (Killed (iridium.libera.chat (Nickname regained by services)))
2021-07-26 02:30:56 finn_elija is now known as FinnElija
2021-07-26 02:33:36 aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net)
2021-07-26 02:34:17 × aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Client Quit)
2021-07-26 02:34:17 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Read error: Connection reset by peer)
2021-07-26 02:34:44 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-07-26 02:34:47 MQ-17J joins (~MQ-17J@8.6.144.192)
2021-07-26 02:35:33 aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net)
2021-07-26 02:35:44 × geekosaur quits (~geekosaur@xmonad/geekosaur) (Ping timeout: 272 seconds)
2021-07-26 02:36:08 × aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Client Quit)
2021-07-26 02:36:26 aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net)
2021-07-26 02:36:27 <Axman6> > scanl (+) 0 $ zipWith (*) (cycle [1,-1]) (iterate (*0.5) 0.5)
2021-07-26 02:36:28 <lambdabot> [0.0,0.5,0.25,0.375,0.3125,0.34375,0.328125,0.3359375,0.33203125,0.333984375...
2021-07-26 02:37:33 × aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Client Quit)
2021-07-26 02:38:04 aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net)

All times are in UTC.