Learn You Scala for Great Good! Part 6

Learn You Scala for Great Good! Part 6

Learn You Scala for Great Good! Part 6

Today I want to finish this long talk about Haskell and Scala.  The only thing that  stays in my to-do list is  “A knight’s quest”. Please look at my previous posts: Learn You Scala for Great Good! Learn You Scala for Great Good! Part 2 Learn You Scala for Great Good! Part 3 Learn You Scala for Great Good! Part 4 Learn You Scala for Great Good! Part 5   A knight’s quest Here’s a problem that really lends itself to being solved with non-determinism. Say you have a chess board and only one knight piece on it. We want

Continue Reading

Learn You Scala for Great Good! Part 5

Scala and Haskell are both good for functional programming. And in some cases their approaches for problems solving are very similar. This is my fifth post of this theme. The idea of writing this series appeared when I was looking for a book about functional programming in Scala. It happened that I found Learn You Haskell for Great Good – the great book about Haskell. I started reading it. Today I want to take some examples from the Higher order functions Chapter of this book Please look at my previous posts: Learn You Scala for Great Good! Learn You Scala

Continue Reading

Learn You Scala for Great Good! Part 4

It’s my fourth post of the series where I told how I started studying Haskell in order to get knowledge in functional programming in Scala. You may see previous posts on this theme: Learn You Scala for Great Good! Learn You Scala for Great Good! Part 2 Learn You Scala for Great Good! Part 3 Today I want to take the three last examples from the Recursion Chapter.   zip function It takes two lists and zips them together. zip [1,2,3] [2,3] returns [(1,2),(2,3)], because it truncates the longer list to match the length of the shorter one. Haskell zip

Continue Reading

String calculation effect in JavaScript

In one of my posts I wrote about the Strong-Password Plugin. The secret of its attractiveness lays in usage of interesting effect: a new password is being calculated on the eyes of the visitor. Let’s discuss how to create such an effect. We need a function that will generate our effect of “string calculation”.  I named it generate. var generate = function(str, result, from, delay) { // Our code will be here…. } Our function takes four parameters, the first two are required. str – it’s a string that  will be shown at the end (the result of calculations) result

Continue Reading

Learn You Scala for Great Good! Part 3

In my previous posts Learn You Scala for Great Good! and Learn You Scala for Great Good! Part 2 I told how I started studying Haskell in order to get knowledge in functional programming in Scala. While I was reading Learn You a Haskell for Great Good! I started to “translate” some examples from Haskell into Scala. Today I shall take some interesting examples from the Recursion chapter of this book. replicate function The replicate function takes an Int and some element and returns a list that has several repetitions of the same element.   Haskell replicate :: (Num i,

Continue Reading

Strong Password Generator

Today I want to tell about the jQuery plugin which I wrote this March: strong-password.js If you need to give a hint for your new visitor of your site how to create a good password: memorable and strong, you can take an opportunity of using this simple plugin. And it’s available for download on GitHub under the MIT License. The plugin can be plugged to a form password field, and when a new visitor clicks on this field an animated popover will appear with a generated password. The password consists of a combination of vowels and consonants, so it is

Continue Reading

Learn You Scala for Great Good! Part 2

Last time I wrote about my experience in learning of functional programming basics using Learn You a Haskell for Great Good! with accent on Scala. Today I’m going to use an example from the Recursion chapter. Maximum awesome In Haskell example the maximum function takes a list of things that can be ordered (e.g. instances of the Ord typeclass) and returns the biggest of them. maximum :: (Ord a) => [a] -> a maximum [] = error “maximum of empty list” maximum [x] = x maximum (x:xs) | x > maxTail = x | otherwise = maxTail where maxTail =

Continue Reading

Learn You Scala for Great Good!

I came to Scala from Java. So when I wanted to learn Scalaz, I didn’t know what to start with. I decided that the best way would be to start with functional programming. It’s strange but the best manual was Learn You a Haskell for Great Good! Yes, I chose my way: I started learning Haskell in order to know Scala better! For better understanding I started to “translate” Haskell examples into Scala. Now I have decided to publish these examples. Guards, guards! We’re going to make a simple function that berates you differently depending on your BMI (body mass

Continue Reading