Pattern matching in Haskell and F#

After I had to deal with the fizzbuzz programmer test, I became interested how pattern matching works in Haskell and F#. I found the following solution for Haskell on the web. {- - Fizzbuzz, https://wiki.haskell.org/index.php?title=Fizzbuzz&oldid=33893 (last visited January 19, 2020). -} fizz n | […]

Associative Arrays

When working with associative arrays in Python, I wonder how these work in other languages. Especially functional programming languages. For example, one would create a dictionary, as associative arrays are called in Python, as follows. >>> dic = {'foo': 42, 'bar': 43}>>> dic{'foo': 42, […]

Lambda Expressions

In Python you can use lambda expressions to avoid the creation of temporary, one-time use functions. Look at the following example. def power(x): return x**2 l1 = map(power, range(4)) If you don’t need the power() function in another place, it’s a bit annoying to […]

On list comprehensions II

In my previous blog entry, I shared some findings on creating lists with list comprehensions. I had a further look on this and how to use map and filter functions for list creation with list comprehensions. For example, in Python you can map a […]

On list comprehensions

I first read about list comprehensions when I started with Python. One application of list comprehensions is to avoid loops. A very simple example in Python would be as follows. l1 = [] for i in range(5): l1.append(i) print(l1) l2 = [x for x in […]

Arrays and lists in F#

Recently, while exploring the capabilities of the F# programming language, I stumbled over the syntax for array creation and accessing elements of arrays. It looks like this. let array = [|"foo"; "bar"; "baz"|] printfn "%A" (array.[0]) Two things I find remarkable here. First, the […]