jaror
All the side effects were never mentioned to me
I am innocent of uncontrolled abuse
- 24 Posts
- 6 Comments
Admittedly it gets more complicated when summing two things at the same time:
let Pair dnormMean dnormNormMean = fold (Pair <$> dimap (\(Pair _ dnormI) -> dnormI) (/ fromIntegral cc) sum <*> dimap (\(Pair normBti dnormI) -> normBti * dnormI) (/ fromIntegral cc) sum) $ map (\i -> Pair (((inp ! (off + i)) - meanBt) * rstdBt) ((weight ! i) * (dout ! (off + i)))) [0 .. cc - 1]
float dnorm_mean = 0.0f; float dnorm_norm_mean = 0.0f; for (int i = 0; i < C; i++) { float norm_bti = (inp_bt[i] - mean_bt) * rstd_bt; float dnorm_i = weight[i] * dout_bt[i]; dnorm_mean += dnorm_i; dnorm_norm_mean += dnorm_i * norm_bti; } dnorm_mean = dnorm_mean / C; dnorm_norm_mean = dnorm_norm_mean / C;
The machine itself can generally only do very simple things
I disagree. Assembly languages for modern architectures are a complexity hell. You need books with thousands of pages to explain how they work. In comparison the lambda calculus is much simpler.
AP probably stands for ActivityPub
jaror@kbin.socialto Programming Languages@programming.dev•The Pure Programming Language (2022)1·1 year agoThe symbolic rewriting is interesting.
I do wonder what “modern-style” functional programming means.
Also their FAQ says:
But considering other FPLs like Haskell and ML, Pure’s library support isn’t bad
Clicking that link reveals a list of about 34 libraries. In comparison, Haskell’s current curated Stackage snapshot has 3340 packages in it (the total number of packages is probably more than 10x that). So, I think it is odd to claim its ecosystem is anywhere near Haskell’s.
The reason I want to follow that account is actually because I’m not seeing their posts, even though they use #haskell and I’m subscribed to that hashtag (and my magazine https://kbin.social/m/haskell is “subscribed” to that hashtag). Is there any way to get their posts to show up in the microblog?
Stream fusion does work:
data Stream a = forall s. Stream !(s -> Step s a) !s data Step s a = Yield a !s | Skip !s | Done data Tup a b = Tup !a !b cartesianProduct :: Stream a -> Stream b -> Stream (a, b) cartesianProduct (Stream step1 s01) (Stream step2 s02) = Stream step' s' where s' = Tup s01 s02 step' (Tup s1 s2) = case step1 s1 of Yield x s1' -> case step2 s2 of Yield y s2' -> Yield (x, y) (Tup s1 s2') Skip s2' -> Skip (Tup s1 s2') Done -> Skip (Tup s1' s02) Skip s1' -> Skip (Tup s1' s2) Done -> Done eft :: Int -> Int -> Stream Int eft x y = Stream step x where step s | s > y = Done | otherwise = Yield s (s + 1) fooS :: Stream (Int, Int) fooS = cartesianProduct (eft 0 10) (eft 0 10) toList :: Stream a -> [a] toList (Stream step s0) = go s0 where go !s = case step s of Yield x s' -> x : go s' Skip s' -> go s' Done -> [] foo :: [(Int,Int)] foo = toList fooS