Raumstation „ISS“: Kapsel von SpaceX dockt erfolgreich an – Welt.de
SpaceX-Kapsel erreicht ISS – Spiegel.de
Crew Dragon: Puppe in SpaceX-Raumschiff erreicht Internationale Raumstation – Zeit.de
Musks Raumfrachter angedockt – FAZ.net
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, 'bar': 43}
Now how does that work in, let’s say Haskell? Well, it’s not that difficult.
Prelude> let dic = [("foo", 42), ("bar", 43)]
Prelude> dic
[("foo",42),("bar",43)]
Looks pretty similar, huh? I had expected something more complicated. Well, this is the most simple case, of course. However, good to know that the simple case can be written in a simple way. Now how does the creation of associative arrays look in F#? First, they are called maps here. And one creates them as follows.
> let dic = [ "foo", 42; "bar", 43 ] |> Map.ofList;;
val dic : Map = map [("bar", 43); ("foo", 42)]
> printfn "%A" dic;;
map [("bar", 43); ("foo", 42)]
val it : unit = ()
Well, looks a bit strange at first. Let’s ignore the additional output for now. What bothers me is the “|> Map.ofList”. I bet that I will forget to write this most of the time. 🙂
For an overview of working with associative arrays in different programming languages, there is a nice article in Wikipedia.
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 write it just to use it in the call to the map() function. However, you can use a lambda expression instead as follows.
>>> map((lambda x: x**2), range(5)) [0, 1, 4, 9, 16] >>>
Now how does this look in functional programming languages. Let’s have a look at lambdas in Haskell.
Prelude> map (\x -> x^2) [0..4] [0,1,4,9,16] Prelude>
Hint: Haskell professionals would use (^2) instead the lambda here. I’m just trying to illustrate the use of lambdas here. What about F#? It looks as follows.
List.map (fun x -> x**2.0) [0.0; 1.0; 2.0; 3.0; 4.0]
Well, this looks a bit different than the examples because, as the documentation for F# says: “The exponentiation operator works only with floating-point types.” Hhm, really?
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 function to list entries to generate more specific lists as follows.
l1 = [x * x for x in range(5)] l2 = [hex(x) for x in range(5)]
l3 = [x * x for x in range(5) if (x * x) % 2 == 0]
l1 = [x*x | x <- [0..4]] l3 = [x*x | x <- [0..4], even (x*x)]
let l1 = [for x in 0..4 do yield x * x] let l3 = [for x in 0..4 do if (x*x) % 2 = 0 then yield x*x]
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 range(5)] print(l2)
List comprehensions can do much more, like mapping functions to list entries or filtering lists. However, I was curious if functional programming languages support list comprehensions as well. As it turned out, they do. For example, in F#, you can write this.
let l1 = [for a in 0 .. 4 -> a] printfn "%A" l1
You will find more examples in WikiBooks. And in Haskell, you can do this.
l1 = [x | x <- [0..4]] print l1
You can find more examples in Learn You a Haskell for Great Good! It looks like I should have a deeper look into this.
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 array creation. Please note that you have a bar (or pipe) after the opening and before the closing square bracket. Second, you access elements of the array using dot notation plus brackets. Its the same for lists.
let list = ["foo"; "bar"; "baz"] printfn "%A" (list.[0])
Note that you do not need the bars for creating lists. I find this dot notation for accessing elements of arrays and lists a bit annoying. For lists, you have the option of using a property to access elements like this.
printfn "%A" (list.Item(0))
However, I wonder why they do not support the plain bracket notation: array[0], list[0].
Interessant. Aber was bedeutet das jetzt? Das Verschlüsselung nicht mehr sicher ist?
Interesting thoughts on Ranking Programming Languages by Ben Frederickson.
Ranking Programming Languages by GitHub Users
https://www.benfrederickson.com/ranking-programming-languages-by-github-users/
Will everything be JavaScript in the future? Oh my! Let’s hope TypeScript will make it.
https://www.heise.de/newsticker/meldung/Hackathons-sind-Selbstausbeutung-4141848.html
Interessante Bewertung dieser modernen Form der LAN-Parties. Ich weiß nicht was ich von Hackathons halten soll. Ist wahrscheinlich eher nervig.
Jonathan Edwards thinks he knows what the problem with programming is and what can be done about this problem.
The problem with programming and how to fix it
https://alarmingdevelopment.org/?p=1173
I think industrial software development will always be a problem. You might want to read the following article to find out why.
Programming Sucks
https://www.stilldrinking.org/programming-sucks
Maybe creative coding is the solution.
Marianne Bellotti writes about mainframes.
Hello World on z/OS
https://medium.com/@bellmar/hello-world-on-z-os-a0ef31c1e87f
I completely agree that ISPF is weird. 🙂
“Ein mathematisches Resultat zeigt: Selbst ein unendlich schneller klassischer Computer kann dem Quantenrechner nicht das Wasser reichen.”
https://www.spektrum.de/news/quantencomputer-sind-grundsaetzlich-anders/1574062
Wann kann man die Dinger endlich kaufen?
Amazon im Weltraum? Lieber nicht. Kann ich mir ohnehin nicht leisten.
Ab ins Weltall – Jeff Bezos bietet Flüge zum Discount-Preis
http://www.manager-magazin.de/unternehmen/industrie/weltraumflug-jeff-bezos-blue-origin-soll-2019-starten-um-200000-usd-person-a-1218323.html
Bergbau im Weltraum? Warum nicht. Mal schauen, ob wir’s diesmal schaffen, dabei keine Sauerei zu machen.
Deutschland verschläft die Chancen der kosmischen Ausbeutung
https://www.welt.de/wirtschaft/article178203590/Rohstoffe-im-Weltraum-Deutschland-verliert-Zeit.html
Fortpflanzung im Weltraum? Jetzt wird’s interessant. Bzw. theoretisch.
Raumfahrt nach Proxima Centauri: Besatzung aus mindestens 49 Paaren notwendig
https://www.heise.de/newsticker/meldung/Besatzung-fuer-Reise-zu-Proxima-Centauri-muesste-aus-mindestens-49-Paaren-bestehen-4109669.html