Newest at the top
| 2025-12-03 16:12:22 +0100 | califax_ | (~califax@user/califx) califx |
| 2025-12-03 16:11:00 +0100 | <lambdabot> | [2,4,6,8,5,6,7,8,9,10] |
| 2025-12-03 16:11:00 +0100 | <__monty__> | But the idea works. |
| 2025-12-03 16:10:56 +0100 | <kuribas`> | > foldr (\(x:xs) cont s -> if (s > 7) then (x:xs) else (x*2) : cont (s+x)) (const []) (tails [1..10]) 0 |
| 2025-12-03 16:10:56 +0100 | spew | (~spew@user/spew) spew |
| 2025-12-03 16:10:44 +0100 | <__monty__> | This is the missing case analysis I was referring to. |
| 2025-12-03 16:10:39 +0100 | spew | (~spew@user/spew) (Quit: nyaa~) |
| 2025-12-03 16:10:30 +0100 | <lambdabot> | [2,4,6,8,10,12,14,16,18,20*Exception: <interactive>:3:8-59: Non-exhaustive p... |
| 2025-12-03 16:10:27 +0100 | <__monty__> | > foldr (\(x:xs) xs2 -> if False then (x:xs) else (x*2) : xs2) [] (tails [1..10]) |
| 2025-12-03 16:10:08 +0100 | gawen | (~gawen@user/gawen) gawen |
| 2025-12-03 16:09:40 +0100 | wbooze | (~inline@cgn-195-14-221-120.nc.de) (Quit: Leaving) |
| 2025-12-03 16:09:08 +0100 | <kuribas`> | You can use the continuation if you need to pass some state. |
| 2025-12-03 16:08:44 +0100 | <lambdabot> | [2,4,6,8,10,6,7,8,9,10] |
| 2025-12-03 16:08:41 +0100 | <kuribas`> | > foldr (\(x:xs) xs2 -> if (x > 5) then (x:xs) else (x*2) : xs2) [] (tails [1..10]) |
| 2025-12-03 16:08:38 +0100 | <kuribas`> | Actually, this doesn't use the continuation ... |
| 2025-12-03 16:07:41 +0100 | <__monty__> | Hmm, no the span/break would need to carry state forward. |
| 2025-12-03 16:07:06 +0100 | <__monty__> | Feels a lot like span/break and folding the fst. |
| 2025-12-03 16:05:52 +0100 | <__monty__> | Only shortcoming is if the condition is never fulfilled, needs more case analysis. |
| 2025-12-03 16:05:29 +0100 | lucabtz | (~lucabtz@user/lucabtz) lucabtz |
| 2025-12-03 16:04:45 +0100 | amadaluzia | (~amadaluzi@user/amadaluzia) amadaluzia |
| 2025-12-03 16:04:39 +0100 | <kuribas`> | --proof that it doesn't visit the tail :) |
| 2025-12-03 16:04:26 +0100 | <lambdabot> | [2,4,6,8,10,6,7,8,9,10] |
| 2025-12-03 16:04:23 +0100 | <kuribas`> | > take 10 $ foldr (\(x:xs) cont -> \xs2 -> if (x > 5) then (x:xs) else (x*2) : cont xs) id (tails [1..]) [] |
| 2025-12-03 16:03:03 +0100 | spew | (~spew@user/spew) spew |
| 2025-12-03 16:02:40 +0100 | lucabtz | (~lucabtz@user/lucabtz) (Remote host closed the connection) |
| 2025-12-03 16:01:59 +0100 | ttybitnik | (~ttybitnik@user/wolper) (Quit: Fading out...) |
| 2025-12-03 16:01:28 +0100 | divlamir | (~divlamir@user/divlamir) (Ping timeout: 244 seconds) |
| 2025-12-03 16:00:45 +0100 | spew | (~spew@user/spew) (Ping timeout: 245 seconds) |
| 2025-12-03 16:00:00 +0100 | <kuribas`> | obviously needs some lambdacase. |
| 2025-12-03 15:59:41 +0100 | <kuribas`> | ^ __monty__ |
| 2025-12-03 15:59:36 +0100 | <lambdabot> | [2,4,6,8,10,6,7,8,9,10] |
| 2025-12-03 15:59:30 +0100 | <kuribas`> | > foldr (\(x:xs) cont -> \xs2 -> if (x > 5) then (x:xs) else (x*2) : cont xs) id (tails [1..10]) [] |
| 2025-12-03 15:51:23 +0100 | wbooze | (~inline@cgn-195-14-221-120.nc.de) Inline |
| 2025-12-03 15:47:39 +0100 | Guest6657 | (~inline@cgn-195-14-221-120.nc.de) (Quit: Leaving) |
| 2025-12-03 15:45:27 +0100 | gawen | (~gawen@user/gawen) (Quit: cya) |
| 2025-12-03 15:40:33 +0100 | <sprout> | yah |
| 2025-12-03 15:40:24 +0100 | <tomsmeding> | then you just punt the problem to the implementation of that monad |
| 2025-12-03 15:39:45 +0100 | <sprout> | put it in a monad? I feel like parser combinators will often return the unprocessed tokens on an error, so you should be able to reuse the idiom |
| 2025-12-03 15:37:58 +0100 | Pozyomka | (~pyon@user/pyon) pyon |
| 2025-12-03 15:37:57 +0100 | <sprout> | hmyah |
| 2025-12-03 15:37:55 +0100 | akegalj | (~akegalj@141-138-27-206.dsl.iskon.hr) |
| 2025-12-03 15:37:53 +0100 | <__monty__> | sprout: Again, that leaves me with only part of the input, no? |
| 2025-12-03 15:37:48 +0100 | <tomsmeding> | sprout: scan doesn't give you access to the actual original tail |
| 2025-12-03 15:37:26 +0100 | <__monty__> | But that's not the "shortcutting" I'm looking for. I want to recurse up to a point and at that point return the tail unprocessed. The latter is just for efficiency rather than correctness. |
| 2025-12-03 15:37:20 +0100 | <sprout> | you can do a scan instead of a fold and lazily stop evaluating when you hit something |
| 2025-12-03 15:36:23 +0100 | <tomsmeding> | yes I think so |
| 2025-12-03 15:35:58 +0100 | <__monty__> | Yeah, with foldr you can either process every element, or drop whatever's left. |
| 2025-12-03 15:35:01 +0100 | <__monty__> | kuribas`: Show me a foldr that doesn't drop any values and also doesn't visit a tail of several values. |
| 2025-12-03 15:34:46 +0100 | <tomsmeding> | but while that construction is cute, I don't think you get access to the unadulterated tail |
| 2025-12-03 15:34:29 +0100 | <tomsmeding> | base's foldl is implemented using foldr |