Newest at the top
2024-05-16 18:09:12 +0200 | <dolio> | The lisp 1.6 manual has it. |
2024-05-16 18:06:07 +0200 | <dolio> | I think it goes pretty far back in lisp. |
2024-05-16 18:05:31 +0200 | econo_ | (uid147250@id-147250.tinside.irccloud.com) |
2024-05-16 18:05:21 +0200 | <ski> | did LISP 1.5 have `MAPCAR' ? |
2024-05-16 18:04:59 +0200 | <ski> | i wonder about the etymology of the `map' function |
2024-05-16 18:04:57 +0200 | danse-nr3 | (~danse-nr3@151.43.160.43) (Read error: Connection reset by peer) |
2024-05-16 18:03:26 +0200 | <dolio> | I can't recall it ever being confusing. |
2024-05-16 18:02:46 +0200 | <EvanR> | in not just haskell |
2024-05-16 18:02:32 +0200 | <EvanR> | it's been a while since I didn't know jargon but I have to wonder if noobs are confused by the collision of map function and map data structure |
2024-05-16 18:00:24 +0200 | <ski> | hm ? |
2024-05-16 17:59:12 +0200 | <EvanR> | map vs map |
2024-05-16 17:58:59 +0200 | <EvanR> | at least other functionalish languages are being consistent in this jargon xD |
2024-05-16 17:58:17 +0200 | jrm | (~jrm@user/jrm) |
2024-05-16 17:57:58 +0200 | <EvanR> | both could be used for memoizing |
2024-05-16 17:57:43 +0200 | <ski> | hm, i guess |
2024-05-16 17:57:41 +0200 | <EvanR> | the function map, the Data.Map container |
2024-05-16 17:57:22 +0200 | <EvanR> | "use a map" could be ambiguous |
2024-05-16 17:56:46 +0200 | jrm | (~jrm@user/jrm) (Quit: ciao) |
2024-05-16 17:54:59 +0200 | Guest13 | (~Guest13@cpc93370-hers8-2-0-cust590.6-3.cable.virginm.net) (Ping timeout: 250 seconds) |
2024-05-16 17:53:19 +0200 | lortabac | (~lortabac@2a01:e0a:541:b8f0:55ab:e185:7f81:54a4) (Quit: WeeChat 4.2.1) |
2024-05-16 17:52:17 +0200 | danse-nr3 | (~danse-nr3@151.43.160.43) |
2024-05-16 17:51:53 +0200 | danse-nr3 | (~danse-nr3@151.43.160.43) (Remote host closed the connection) |
2024-05-16 17:51:48 +0200 | <ski> | explaining it may help, possibly |
2024-05-16 17:51:25 +0200 | <ski> | when you call recursively, which parameters (may) change ? |
2024-05-16 17:50:57 +0200 | <ski> | are you sure you have two arrays, and not two lists ? |
2024-05-16 17:50:34 +0200 | <ski> | are `[Int]',`Int',`[Int]' your parameter types ? |
2024-05-16 17:50:00 +0200 | <Guest13> | if it helps, I can explain the problem |
2024-05-16 17:49:36 +0200 | <Guest13> | im not sure I can, the state I have is 2 arrays which im comparing to each other and an integer to denote a counter and a string |
2024-05-16 17:49:30 +0200 | <lambdabot> | 144 |
2024-05-16 17:49:28 +0200 | <ski> | > let memoFib n | n >= 0 = fibs ! n where fibs = L.tabulate (0,n) (\n -> case n of 0 -> 0; 1 -> 1; n -> fibs ! (n - 1) + fibs ! (n - 2)) in memoFib 12 -- array `fibs' is (lazily) recursively defined in terms of itself |
2024-05-16 17:48:44 +0200 | <ski> | the array `fibs' and the function `fib' are mutually recursively defined. you can inline one into the other as |
2024-05-16 17:48:12 +0200 | <ski> | Guest13 : can you follow that ^ example ? given a (non-negative) integer `n', it builds an array (`fibs') with `n+1' elements (indexed from `0' to `1'), with elements set by the fibonacci function (`fib') where recursive calls look up results in the array, and so will be cached (the array elements are lazily computed) |
2024-05-16 17:48:01 +0200 | <Guest13> | the problem I have is that each recursive call is defined by [Int], Int, [Int] |
2024-05-16 17:46:33 +0200 | <lambdabot> | 144 |
2024-05-16 17:46:32 +0200 | <ski> | > let memoFib n | n >= 0 = fibs ! n where fibs = L.tabulate (0,n) fib; fib 0 = 0; fib 1 = 1; fib n = fibs ! (n - 1) + fibs ! (n - 2) in memoFib 12 |
2024-05-16 17:43:51 +0200 | <lambdabot> | array (-2,3) [(-2,4),(-1,1),(0,0),(1,1),(2,4),(3,9)] |
2024-05-16 17:43:49 +0200 | <ski> | > L.tabulate (-2,3) (\i -> i^2) -- construct an array, with each element based on its index |
2024-05-16 17:42:22 +0200 | <lambdabot> | Defined. |
2024-05-16 17:42:21 +0200 | <ski> | @let tabulate :: Ix i => (i,i) -> (i -> e) -> Array i e; tabulate ix f = listArray ix [f i | i <- range ix] |
2024-05-16 17:41:02 +0200 | <ski> | `rec' is for something else (recursive bindings in `do') |
2024-05-16 17:40:41 +0200 | <ski> | there is no state, adding to the map, unless you express this with state in some fashion .. and it's probably better to avoid that, if you can |
2024-05-16 17:38:50 +0200 | <Guest13> | I've seen the rec keyword but this is also something I am unsure about |
2024-05-16 17:38:24 +0200 | <Guest13> | ie adds to the map, or checks the map |
2024-05-16 17:38:01 +0200 | <Guest13> | I can't think about it functionally very well, I am thinking that each time it does a call it updates an internal "state" |
2024-05-16 17:37:26 +0200 | <Guest13> | I understand to use a map but I don't know how I would implement it |
2024-05-16 17:36:42 +0200 | zzz | (~yin@user/zero) |
2024-05-16 17:33:37 +0200 | <ski> | .. but if your domain is large, the map would also be large. sometimes you can allocate the association structure itself, lazily, incrementally (like the infinite linked list above) |
2024-05-16 17:32:32 +0200 | <ski> | anyway, if you already know from the start (perhaps from the initial parameters) how large domain you need for the recursive calls corresponding to subproblems of that initial problem, you can allocate a map (recursively defined) that has an association mapping each element of your domain to the corresponding result value (lazily computed) |
2024-05-16 17:30:46 +0200 | <ski> | (oh, and jfyi, that `memo_fib' still uses `fib' (but not `memo_fib') for each individual call, so not reusing the list resulting from the `map' as a cache) |
2024-05-16 17:29:08 +0200 | <ski> | .. or how large is your domain ? |