FP Daily Algorithm (@DailyAlgorithm) header
FP Daily Algorithm (@DailyAlgorithm) profile picture

A transparent algorithm a day keeps bugs away. Daily feed with algorithms written in functional Scala.

Community of Madrid, Spain
Joined October 2016
Compilation time prime numbers generation: Have you ever embedded/seen a list of prime integer literals in your source code to use them out of the box? What if #Scala macros helped to remove that monstrosity from your codebase? github.com/pfcoperez/algorit…
4
8
Red-Black trees, second step: Left & right rotations, in DL trees parents can become children and children parents! github.com/pfcoperez/algorit… And yet, rotations result in same in-order traverses but in different pre-orders: github.com/pfcoperez/algorit… This only works in lazy universes.
3
5
Did you ever tie the knot in multiple dimensions:Red-Black trees,step-by-step. First: @typelevel 's Cats to define lazy structures via Eval monad: github.com/pfcoperez/algorit… And how to create nodes with parents: github.com/pfcoperez/algorit… In the next episode: Rotations & insert fix-up!
Double linked lists, with cats or how adopting @typelevel's Cats halves your lazy code thanks to its monadic representation of evaluation github.com/pfcoperez/algorit… Thank you @meta_Lloyd for the idea!
1
9
Tying the knots... again, this time in both directions of a single dimension: pure Double Linked Lists: github.com/pfcoperez/algorit… github.com/pfcoperez/algorit… #functionalprogramming
2
1
Detecting loops in Linked Lists: O(n) github.com/pfcoperez/algorit… github.com/pfcoperez/algorit… As easy as making a fast and a slow pointers race against each other. Trust me, Math doesn't lie 😉 stackoverflow.com/questions/…
Immutable data loops strike back!Tying the not: A more traditional approach to get loops in your linked structures's that used in #Haskell for ages (wiki.haskell.org/Tying_the_K…) but it's lazy by default whereas @scala_lang isn't & require some boiler plate... github.com/pfcoperez/algorit…
3
3
@DailyAlgorithm is Back! In Oct 2016 a challenge was posted here: How to make a loop in an immutable linked data structure?nitter.cf/DailyAlgorithm/status/… What about passing `this` to a function building the tail in a node constructor? github.com/pfcoperez/algorit…
A weekend challenge: How do we make a cycle in an immutable linked structure? e.g: Linked list (github.com/pfcoperez/algorit…)
2
3
This feed'll be a bit stalled this month as the,so far,solo contributor's landing into a new job.New stuff directly from academic papers'll be here soon!Meanwhile,please,open PRs! They'll reviewed,welcomed and rewarded (yes, with stickers!) goo.gl/WqiscK
Matrix convolution is cool but erosive. Padding is one way to preserve the original size. O(1) github.com/pfcoperez/algorit…
3
5
We had matrix multiplication but a leg was missing to perform #DeepLearning: Matrix Convolutions! O(n*m*f^2) github.com/pfcoperez/algorit…
4
4
Convoluting polygons, Minkowski addition of convex polygons: O(n+m) No excuses for your vacuum robot cleaner to get stuck at your home's corners! github.com/pfcoperez/algorit…
1
2
Be tail recursive: Best graphical representation of the difference between a tail-recursive optimized function and other that isn't. Found at @yworks 's yEd gallery: yworks.com/products/yed/gall… Btw, yEd is the tool used to build the diagrams published in this feed.