Newest at the top
| 2025-12-19 17:40:21 +0100 | <milan2> | merijn: I started from begining. |
| 2025-12-19 17:40:18 +0100 | <lambdabot> | Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b) |
| 2025-12-19 17:40:17 +0100 | <merijn> | :t mapAccumL |
| 2025-12-19 17:40:14 +0100 | <merijn> | Avoiding spoilers, my implementation relied on mapAccumL |
| 2025-12-19 17:39:48 +0100 | <milan2> | sprout: So scan hmmm... or maybe custom self recursive function. |
| 2025-12-19 17:39:31 +0100 | <yin> | sprout: scanr, which is foldr in disguise |
| 2025-12-19 17:39:20 +0100 | <merijn> | 2025 you mean? :p |
| 2025-12-19 17:38:46 +0100 | <sprout> | scan will give you a list of numbers, and you can terminate when you hit -1 |
| 2025-12-19 17:38:36 +0100 | <yin> | fun to see that i can press ctrl-c to halt `foldl const 0 (repeat ())` in ghci but not foldl' |
| 2025-12-19 17:37:02 +0100 | <sprout> | use scan |
| 2025-12-19 17:36:45 +0100 | <yin> | ironically, because it wouldn't terminate |
| 2025-12-19 17:36:24 +0100 | <lambdabot> | Terminated |
| 2025-12-19 17:36:07 +0100 | <yin> | > foldl' const 0 (repeat ()) |
| 2025-12-19 17:35:57 +0100 | <lambdabot> | 0 |
| 2025-12-19 17:35:55 +0100 | <yin> | > foldl' const 0 [undefined] |
| 2025-12-19 17:35:10 +0100 | <milan2> | Like we need definitelly left fold, and we need to stop counting as soon as we count -1. |
| 2025-12-19 17:34:16 +0100 | <milan2> | Advent of Code 2015 day 1 part 2 broke me :( |
| 2025-12-19 17:33:46 +0100 | <merijn> | What are you actually trying to do? |
| 2025-12-19 17:33:25 +0100 | <milan2> | I probably can't so this will not work on infinite lists. |
| 2025-12-19 17:33:15 +0100 | <merijn> | So you can short-circuit in skipping some evaluation of `f`, but you *have* to walk the list |
| 2025-12-19 17:32:37 +0100 | <merijn> | Right, but how do you do that without traversing the entire list? ;) |
| 2025-12-19 17:31:40 +0100 | chele | (~chele@user/chele) (Remote host closed the connection) |
| 2025-12-19 17:31:33 +0100 | <milan2> | Thus no need for evaluating first argument? |
| 2025-12-19 17:31:10 +0100 | <milan2> | If we look only on c we might be able to short-circuit? |
| 2025-12-19 17:29:52 +0100 | <lambdabot> | f (f (f z a) b) c |
| 2025-12-19 17:29:51 +0100 | <merijn> | > foldl f z [a,b,c] |
| 2025-12-19 17:29:45 +0100 | <merijn> | milan2: Look at my example above :) |
| 2025-12-19 17:29:26 +0100 | <milan2> | I was reading web and I understood it that it can? I might be able to find link. |
| 2025-12-19 17:28:34 +0100 | lucabtz | (~lucabtz@user/lucabtz) (Quit: Lost terminal) |
| 2025-12-19 17:28:31 +0100 | <yin> | milan2: how do you figure? |
| 2025-12-19 17:27:31 +0100 | <milan2> | Yeah got it.. but foldl should be able to short-circuit. I just have to write "correct" folding function for it. |
| 2025-12-19 17:26:31 +0100 | <yin> | s/whnk/whnf |
| 2025-12-19 17:26:05 +0100 | <yin> | milan2: foldl' evaluates the accumulator to whnk, foldl doesn't. but both necessarily traverse the complete list |
| 2025-12-19 17:25:38 +0100 | <merijn> | brainfart :) |
| 2025-12-19 17:25:35 +0100 | <merijn> | oh, wait, no, it's foldl' |
| 2025-12-19 17:25:13 +0100 | <merijn> | You can certainly short-circuit, but not without walking the entire list |
| 2025-12-19 17:25:00 +0100 | <merijn> | Define short-circuit |
| 2025-12-19 17:24:51 +0100 | <geekosaur> | foldr's function is given a thunk representing the rest of the list, which it can choose to not evaluate and thereby short circuit. foldl/foldl' isn't |
| 2025-12-19 17:24:47 +0100 | <lambdabot> | f (f (f z a) b) c |
| 2025-12-19 17:24:45 +0100 | <merijn> | > foldl' f z [a,b,c] |
| 2025-12-19 17:24:13 +0100 | <geekosaur> | "as I understand it" |
| 2025-12-19 17:23:20 +0100 | <milan2> | geekosaur: Sorry, if you replied to me I don't know what AIUI means. |
| 2025-12-19 17:21:46 +0100 | <geekosaur> | it's not AIUI |
| 2025-12-19 17:20:30 +0100 | <milan2> | Hello, sorry to interupt you guyz. :) Do you know if short-circuit foldl' is possible? |
| 2025-12-19 17:19:35 +0100 | machinedgod | (~machinedg@d75-159-126-101.abhsia.telus.net) machinedgod |
| 2025-12-19 17:17:31 +0100 | spew | (~spew@user/spew) spew |
| 2025-12-19 17:16:58 +0100 | <merijn> | You can if you're an ultra-finitist |
| 2025-12-19 17:16:24 +0100 | <lucabtz> | we just found names for a few significant ones |
| 2025-12-19 17:16:14 +0100 | <lucabtz> | though it is a practical problem, generally we have words for numbers, but clearly we can't name all the real ones |
| 2025-12-19 17:15:54 +0100 | <yin> | ;) |