2024/09/02

Newest at the top

2024-09-02 04:27:33 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl)
2024-09-02 04:22:42 +0200 <geekosaur> this is the same thing, lambdabot uses a `takeWhile` to limit the output size, so only 28 values are demanded from the technically-"infinite" [1..]
2024-09-02 04:21:54 +0200 <lambdabot> [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,...
2024-09-02 04:21:52 +0200 <geekosaur> > [1..]
2024-09-02 04:21:30 +0200 <geekosaur> so you generally don't need to explicitly "break" out of a loop, you can let laziness do it for you
2024-09-02 04:20:36 +0200 <geekosaur> the `undefined` is never reached because `takeWhile` stops demanding values from the list when `map` produces a 5
2024-09-02 04:19:39 +0200 <lambdabot> [3,2]
2024-09-02 04:19:37 +0200 <geekosaur> > takeWhile (<5) (map (+1) [2,1,4,undefined])
2024-09-02 04:17:39 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl) (Ping timeout: 260 seconds)
2024-09-02 04:12:37 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl)
2024-09-02 04:09:24 +0200 <geekosaur> also, the actual data structure matters a lot here: lists are inherently lazy, Sets and Maps are inherently spine and key strict (Maps can be value-lazy though)
2024-09-02 03:56:05 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl) (Ping timeout: 248 seconds)
2024-09-02 03:51:31 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl)
2024-09-02 03:42:14 +0200 <weary-traveler> yeah, perhaps the lack of explicitly mentioning laziness was the missing piece
2024-09-02 03:41:06 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl) (Ping timeout: 276 seconds)
2024-09-02 03:40:51 +0200 <geekosaur> (lists are lazy)
2024-09-02 03:40:42 +0200 <geekosaur> you can do it in multiple steps, you know. if you `takeWhile whatever (fmap …)` the fmap will stop automatically when takeWhile does
2024-09-02 03:37:06 +0200 <albet70> athan , reduce the list to something is already filter
2024-09-02 03:36:25 +0200gabiruh(~gabiruh@vps19177.publiccloud.com.br)
2024-09-02 03:36:13 +0200 <weary-traveler> heh
2024-09-02 03:36:06 +0200 <geekosaur> rip your sanity
2024-09-02 03:35:23 +0200 <yahb2> 2 ; 4 ; 6 ; 8 ; 10 ; 12 ; 14 ; 16 ; 18 ; 20 ; 22 ; 24 ; 26 ; 28 ; 30 ; 32 ; 34 ; 36 ; 38 ; 40 ; 42
2024-09-02 03:35:23 +0200 <probie> % (`runContT` pure) $ callCC $ \break -> forM_ [1..100] $ \i -> do { when (even i) $ lift $ print i; when (i == 42) $ break() }
2024-09-02 03:35:07 +0200L29Ah(~L29Ah@wikipedia/L29Ah)
2024-09-02 03:32:45 +0200 <athan> I forgot about takeWhile, that's a better choice
2024-09-02 03:32:09 +0200 <athan> albet70 this is usually done with a fold rather than a uniform mapping or something that's guarateed to affect all cases. If you're "looking" for something, maybe `findIndex` would work. But if you're trying to "do something to everything until a condition is met", I'd reduce the list to something that represents the data you want to manage, then apply your map or what have you.
2024-09-02 03:31:55 +0200 <albet70> lets assum filter on a list, filter (> 0) [1..22] when the matching item is above five, stop filter the rest, return immediatly
2024-09-02 03:31:30 +0200L29Ah(~L29Ah@wikipedia/L29Ah) (Excess Flood)
2024-09-02 03:31:29 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl)
2024-09-02 03:30:33 +0200 <lambdabot> [0,2,4]
2024-09-02 03:30:31 +0200 <weary-traveler> > takeWhile even [0,2,4,5,6,8,10]
2024-09-02 03:30:28 +0200 <weary-traveler> albet70: something like takeWhile ?
2024-09-02 03:27:43 +0200 <probie> What does it mean to `break` in a functional language?
2024-09-02 03:27:39 +0200 <probie> <bad joke>just call `error` and thiings will break</bad joke>
2024-09-02 03:26:08 +0200athan(~athan@syn-098-153-145-140.biz.spectrum.com)
2024-09-02 03:25:44 +0200athan(~athan@syn-098-153-145-140.biz.spectrum.com) (Ping timeout: 272 seconds)
2024-09-02 03:22:25 +0200tt123109783243(~tt1231@2603:6010:8700:4a81:219f:50d3:618a:a6ee)
2024-09-02 03:21:53 +0200tt123109783243(~tt1231@2603:6010:8700:4a81:219f:50d3:618a:a6ee) (Quit: The Lounge - https://thelounge.chat)
2024-09-02 03:21:18 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl) (Ping timeout: 272 seconds)
2024-09-02 03:19:58 +0200Unicorn_Princess(~Unicorn_P@user/Unicorn-Princess/x-3540542)
2024-09-02 03:16:02 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl)
2024-09-02 03:15:38 +0200 <albet70> break can break the for loop in python, is there something can break in fmap or filter?
2024-09-02 03:07:15 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl) (Ping timeout: 244 seconds)
2024-09-02 03:02:40 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl)
2024-09-02 02:52:10 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl) (Ping timeout: 272 seconds)
2024-09-02 02:47:14 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl)
2024-09-02 02:42:28 +0200JuanDaugherty(~juan@user/JuanDaugherty) (Quit: JuanDaugherty)
2024-09-02 02:38:17 +0200Mateon2Mateon1
2024-09-02 02:36:44 +0200merijn(~merijn@204-220-045-062.dynamic.caiway.nl) (Ping timeout: 260 seconds)
2024-09-02 02:35:59 +0200Mateon2(~Thunderbi@user/meow/Mateon1)