@kosmikus
Your solution is much better than mine.
It dose not need to construct tree (nodes) and it does not reorder the nodes if doing something like this:
"
rlisttree :: Tree a -> [a]
rlisttree = redtree (:) (++) []
"
@kosmikus
I didn't know there where different versions of the paper. Cool, yes this way the types of the functiobs are uniquely defined Thanks.
There was a post pointing to the beautiful more than 30 years old #functionalprogramming paper "Why Functional Programming Matters" John Hughes. I could not find the post again to reply,
The paper gives a definition of "foldtree" on page 7:
"
foldtree f g a (Node label subtrees) =
f label (foldtree f g a subtrees)
foldtree f g a (Cons subtree rest) =
g (foldtree f g a subtree) (foldtree f g a rest)
foldtree f g a Nil = a
"
I wonder what the type of "foldtree" could be. Since the last argument
is "treeof ∗" in the first declaration but "(listof (treeof ∗)" in the second.
In #haskell I would implement it as:
data Tree a = Node a [Tree a]
foldtree :: (a -> b -> b) -> (b -> b -> b) -> b -> Tree a -> b
foldtree f g a (Node x []) = f x a
foldtree f g a (Node x (t:ts)) =
g (foldtree f g a t) (foldtree f g a (Node x ts))
But probably I'm miss something here, since it takes only two declarations.
A new approach has allowed first-ever observation of quantum interference between dissimilar particles.
Scientists @brookhavenlab@twitter were able to actually see inside nuclei.
#science #fediscience #physics #quantummechanics #particlephysics #scicomm
@apodoxus @philosophy
I like the idea about time split at the big bang. I wonder how this relates to the interpretation in QFT of anti particles as particles traveling backwards in time?
It is probably a bad idea in #Haskell,
but still surprising: #ghc does not
complain about using "do" to define (>>=) itself.
It seams to cause and endless loop.
newtype BadIdea a = B a
deriving Show
instance Functor BadIdea where
fmap f (B a) = B (f a)
instance Applicative BadIdea where
pure x = B x
(B f) <*> B x = B (f x)
instance Monad BadIdea where
return x = B x
ma >>= f = do
a <- ma
f a
-- instead of
-- (B a) >>= f = f a
main = print
(B 5 >>= (\x -> B (2*x)))
@wactbprot
Yes great lecture about #lambda calculus and #functionalprogramming.
When I tried to program the AND combinator in #haskell I failed. Maybe because of the static type system but more likely because of my inability?
Is there a simple solution for AND: (\p q -> p q p ) in #haskell?
This is as far as I got:
tr :: a -> b -> a
tr = \p q -> p
fs :: a -> b -> b
fs = \p q -> q
and' = \p q -> p q fs
or' = \p q -> p tr q
-- ghci> or' tr fs True False
-- True
-- ghci> and' tr fs True False
-- False
-- and'' = \p q -> p q p -- does not work
-- or'' = \p q -> p p q -- does not work
@wactbprot
Yes excellent, thanks.
When I tried to programm the and combinator in haskell I failed. Maybe because of the static type system but more likely because of my inability?
Any simple solution for and (\p q -> p q p ) in haskell?
Not new but still the best 2 minutes , well, sketch of the
Brout-Englert-Higgs
#Higgs mechanism I know. #Particles #CERN #Physics
https://m.youtube.com/watch?v=qIXpTIVFF7I
In my spare time I learned a bit about #Haskell and implemented an algorithm concerning multiplet combination, used in high energy #physics .
https://github.com/mdrslmr/Multiplet-Combining
It is a bit in between the fields of #Haskell #functionalprogramming , #physics and #grouptheory .
Interested in physics, science, software e.g. haskell, ...