New primitives and combinators #568
Replies: 4 comments 8 replies
-
How would you write a |
Beta Was this translation helpful? Give feedback.
-
How would you write a |
Beta Was this translation helpful? Give feedback.
-
How would you make a |
Beta Was this translation helpful? Give feedback.
-
I've spent some time thinking about how to create a In theory it sounds like it should be possible to do it, but with the interface we have to work with arrays, I've only been able to do it if I can create a default value of type makeA :: forall a n . (KnownNat n) => a -> Array n (Stream a) -> Stream (Array n a)
makeA def xs = foldl updatePos initialArray indexedElems
where
updatePos :: Stream (Array n a) -> (Int, Stream a) -> Stream (Array n a)
updatePos s (i, x) = s !! i = : x
indexedElems :: [(Int, Stream a)]
indexedElems = zip [0..] (arrayElems xs)
initialArray :: Stream (Array n a)
initialArray = array (replicate n def) I'd welcome clever ideas I have not thought of. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This space is for combinators that are not immediate/trivial, to see if others are able to come up with the solution. I consider it more of a fun space to see who comes up with the cleverest solution.
Beta Was this translation helpful? Give feedback.
All reactions