python,packages,python-module,side-effects,purely-functional
So I ended up writing a few methods which can list everything from a source file, without importing the source file. The ast module doesn't seem particularly well documented, so this was a bit of a PITA trying to figure out how to extract everything of interest. Still, after ~6...
haskell,design,functional-programming,immutability,purely-functional
You might find the Updatable type from mvc-updates useful. The basic idea is that you build an Updatable value by supplying a concurrent input (i.e. a Controller) and a Fold over that input: on :: Fold e a -> Managed (Controller e) -> Updatable a Here are two example inputs:...
f#,functional-programming,purely-functional
You write your functions under the assumption, that all went well as you have done. Then you unwrap the happy case and continue with the happy case. And in the end, you can use the builder to make the syntax pretty. type Result<'TSuccess, 'TError> = | Success of 'TSuccess |...
php,immutability,purely-functional
read here: http://php.net/manual/en/language.oop5.cloning.php you really shouldn't pass by value, as that would require a deep copy aka. deep clone, or an insane amount allocated for for parameters.. if you really want to, the answer is: first deep copy, then pass a reference to the copy....
haskell,types,functional-programming,lazy-evaluation,purely-functional
You need to match on r e.g. laserPaths' = map (\(p,r) -> if isLaserCollision r then doSomethingWith p else p) $ zip laserPaths laserCollisionResults where isLaserCollision (LaserToLaserCollision _) = True isLaserCollision _ = False or you can match inline: laserPaths' = map (\(p, r) -> case r of { (LaserToLaserCollision...
c#,custom-attributes,code-contracts,purely-functional
The static analyser assumes that calling the same pure function with the same arguments twice in a row produces the same result. Given [Pure] public delegate int F(int i); public class A { public void f(F f) { var i = f(1); Contract.Assert(i == f(1)); } } a warning is...
haskell,functional-programming,monads,purely-functional
You would, in fact, use a variant of the state monad to pass the random generator around behind the scenes. The Rand type in Control.Monad.Random helps with this. The API is a bit confusing, but more because it's polymorphic over the type of random generator you use than because it...
haskell,dictionary,io,functional-programming,purely-functional
Your lambda, \(x,y) c -> drawMirror c (Position x y), takes two arguments. However, it is called with a single argument of the form (key, value) (in your case ((x, y), c). (\((x,y), c) -> drawMirror c (Position x y)) Moreover, mapM_ (which I believe in your case is from...