Newest at the top
2024-05-16 18:30:11 +0200 | <Guest13> | im trying to count the ways of doing something |
2024-05-16 18:29:25 +0200 | <Guest13> | I think I get how to do it |
2024-05-16 18:29:20 +0200 | euphores | (~SASL_euph@user/euphores) (Quit: Leaving.) |
2024-05-16 18:28:58 +0200 | <Guest13> | so I can do a \(x,y,z) -> f x y-1 z + f x-1 y z |
2024-05-16 18:28:54 +0200 | <ski> | oh, you said "yes, but I am probably framing it badly" just after i asked "are you sure dynamic programming would make sense, for your problem, then ?", so i was taking that for granted |
2024-05-16 18:28:06 +0200 | <ski> | you can use `listArray' (or `array'), or the `tabulate' i defined above, to (lazily) populate the array with elements, based on their indices |
2024-05-16 18:28:03 +0200 | <Guest13> | im not really doing dp |
2024-05-16 18:27:57 +0200 | <Guest13> | I understand the map f [1..] for fib, and even the tabulate version you showed me but I don't understand this one |
2024-05-16 18:27:45 +0200 | manwithluck | (~manwithlu@149.102.244.20) |
2024-05-16 18:27:35 +0200 | tomboy64 | (~tomboy64@user/tomboy64) |
2024-05-16 18:27:31 +0200 | <Guest13> | ok, how can I use this to cache |
2024-05-16 18:27:21 +0200 | <ski> | so, maybe try `Array (Int,Int,Int) Result' ? |
2024-05-16 18:27:20 +0200 | <Guest13> | at most like 20 |
2024-05-16 18:27:00 +0200 | <Guest13> | the ranges aren't large |
2024-05-16 18:26:32 +0200 | <ski> | but if your ranges (?) of `Int's are large, the array would contain a lot of elements, take a lot of space (the array itself would be allocated eagerly, only the array elements would be lazily evaluated) |
2024-05-16 18:26:10 +0200 | pavonia | (~user@user/siracusa) (Quit: Bye!) |
2024-05-16 18:25:27 +0200 | <ski> | if you're okay with a dense caching space, you could try caching with an array |
2024-05-16 18:25:20 +0200 | <Guest13> | I don't know upfront which triples are needed |
2024-05-16 18:24:55 +0200 | <Guest13> | can be sparse or dense depending on input |
2024-05-16 18:24:49 +0200 | <ski> | (or `Map Int (Map Int (Map Int Result))', i guess ..) |
2024-05-16 18:24:35 +0200 | raehik | (~raehik@rdng-25-b2-v4wan-169990-cust1344.vm39.cable.virginm.net) (Ping timeout: 268 seconds) |
2024-05-16 18:24:25 +0200 | <ski> | ok, maybe it would make sense to cache in a three-dimensional array, or (if you only need sparse inputs) maybe use a `Map (Int,Int,Int) Result' or something like that (that'd still require you to know upfront which triples would be needed, which might not be ideal) |
2024-05-16 18:22:53 +0200 | <ski> | (for each new toplevel call, you'd generate a fresh/new cache, from scratch, whose results would only be reused for recursive calls stemming from that particular toplevel call) |
2024-05-16 18:22:38 +0200 | <Guest13> | I can formulate it as Int Int Int, with constant [Int] and String |
2024-05-16 18:22:35 +0200 | cfricke | (~cfricke@user/cfricke) (Ping timeout: 256 seconds) |
2024-05-16 18:22:24 +0200 | <Guest13> | this would be ideal |
2024-05-16 18:22:10 +0200 | <ski> | if only some of the parameters changed in recursive calls, then you could, within a single toplevel call, only cache for the changing parameters, thereby simplifying the datastructure needed to cache results |
2024-05-16 18:21:26 +0200 | <Guest13> | I could frame it as Int Int Int and have [Int] and String as references |
2024-05-16 18:20:53 +0200 | <Guest13> | the recursive call changes all of the above, and the top call I believe will start at 0 0 [Int] String |
2024-05-16 18:20:07 +0200 | <Guest13> | can you explain what is the difference? |
2024-05-16 18:19:47 +0200 | <ski> | oh, and when i asked "which of those are actually changing ?", i specifically had *recursive* calls in mind (not initial/top calls from other places) |
2024-05-16 18:18:35 +0200 | <Guest13> | yes |
2024-05-16 18:18:33 +0200 | <Guest13> | to make it easy I just wanted to cache results of calls |
2024-05-16 18:18:29 +0200 | <ski> | .. or are you just looking for caching results of calls, to avoid recomputing later ? |
2024-05-16 18:18:21 +0200 | <Guest13> | yes, but I am probably framing it badly |
2024-05-16 18:18:06 +0200 | <ski> | are you sure dynamic programming would make sense, for your problem, then ? |
2024-05-16 18:18:02 +0200 | <Guest13> | I can simplify it to Int Int [Int] String |
2024-05-16 18:17:19 +0200 | <Guest13> | all of them |
2024-05-16 18:17:11 +0200 | <ski> | Guest13 : and which of those are actually changing ? |
2024-05-16 18:17:10 +0200 | manwithluck | (~manwithlu@149.102.244.20) (Read error: Connection reset by peer) |
2024-05-16 18:16:57 +0200 | <ski> | i guess that's the connection, then |
2024-05-16 18:16:40 +0200 | <dolio> | Lists in the case of old lisp. |
2024-05-16 18:16:30 +0200 | <dolio> | And that's what 'map' does on all elements of some container. |
2024-05-16 18:16:20 +0200 | <Guest13> | or at least what I had in the recursive call |
2024-05-16 18:16:11 +0200 | machinedgod | (~machinedg@d173-183-246-216.abhsia.telus.net) (Ping timeout: 264 seconds) |
2024-05-16 18:15:58 +0200 | <Guest13> | yes, [Int] [Int] int String are the parameters |
2024-05-16 18:15:27 +0200 | <dolio> | Anyhow, 'map' doesn't just mean 'function' it's also the act of associating or carrying an input to an output by a function. |
2024-05-16 18:15:15 +0200 | <Guest13> | sorry ski I had to pick my mum up from station |
2024-05-16 18:14:58 +0200 | Guest13 | (~Guest13@cpc93370-hers8-2-0-cust590.6-3.cable.virginm.net) |
2024-05-16 18:14:46 +0200 | <c_wraith> | wow, good sentence construction there. |