For those who like Lisp and/or Haskell check out the “Land of Lisp” comic strip by Conrad Barski. A good bit of humour for you ;-)

Just a note to say that if you are in the Oxford area on the 6th February (2008) then please, please come to the Oxford Geek Night 5. Its at the Jericho Tavern Pub in Oxford and starts at 7:30pm. It features a bit of socialising, a bit of watching presentations and some fun.

If you do come then please come and say hello :-)

Many thanks,

Daniel

Links:

  • Oxford Geek Night 5

Technorati Tags: oxford, geek, night, oxfordgeeknight, ogn5, jerichotavern, jericho

[programming language talk:]

Sun Microsystems are the guys behind Java, and the Microsoft team developed C#.
Java and C# have always been in battle for users, the two languages look very similar and act very similar, they do have their differences but they are targeted at the same kinds of developers.

Now they are at it again!

For a few years now Sun Microsystems have been developing something called Fortress, which is an object oriented high performance functional programming language that is partly based on Fortran but has more in common with Scheme and Haskell. It can run on the Java Virtual Machine. More details here: https://fortress.sunsource.net/

Now, all of a sudden Microsoft have release F#, which is an object oriented high performance functional programming language that is partly based on Fortran and MATLAB, but has more in common with Scheme and OCaml. It can run on the .Net virtual machine. More details here: https://research.microsoft.com/fsharp/fsharp.aspx

You’ll find that the Fortress system is actually Free and Open Source Software, and will be able to run on Windows, Mac, Linux or Unix. F# seems like its just a windows thing, especially as it only runs on .net, I suppose us on the other systems would have to wait until its on mono. F# is also closed source.

Microsoft really do get on my nerves, they really know how to irritate people. I bet Sun aren’t happy with Fortran being basically copied by Microsoft to make this F# language. Sorry everybody, I am on Sun Microsystems side at the moment.

So the battles continue:

  • Java Versus C#
  • Fortress Versus F#

Technorati Tags: fortress, F#, sun, microsoft, functional, fortran

This post is a bit of an update of this one

The Ruby can stay the same:
search_engines = %w[Google Yahoo MSN].map do |engine| "https://www." + engine.downcase + ".com"
end

But we can refine the Haskell even further than I originally posted, by saying the following:

search_engines = map (\engine -> "https://www." ++ downcase engine ++ ".com") ["Google","Yahoo","MSN"] where downcase = map toLower

The above uses a lambda expression (\) to state that engine comes in later… its quite hard to explain lambda expressions unless you have done functional programming. Basically you can state that a function takes in something without actually saying that it takes in something. Graham Huttons book and Simon Thompsons books are good references to check it out for Lambda Calculus. In both the Ruby and Haskell implementations we are using lambda expressions, in this example engine is our term (key).

(Thanks to Ian Bayley for providing me with some hints about this)

(p.s. in the Haskell implementation, toLower is a character function… which if you are using some newer versions of Hugs you will need to add “import Char” to the top of your hs/lhs program if you want to use it)

Technorati Tags: haskell, ruby, functional, programming

Ruby

(taken from https://www.ruby-lang.org/en/about/ )

#This turns an array of names into an array of URLs (but keeps it all string)
search_engines =
%w[Google Yahoo MSN].map do |engine|
"https://www." + engine.downcase + ".com"
end

The bit between do and end in the above is called a block in the Ruby Programming Language.

Haskell

So lets do the same thing in Haskell (this is written by me!)

-- this returns a URL for a given string (also makes it lowercase)
search_engine_URL :: [String] -> [String]
search_engine_URL engine = concat("https://www.", (map (toLower) engine), ".com")

and then at the Hugs/Helium prompt we ask:

map search_engine_URL ["Google", "Yahoo", "MSN"]

The two systems…

… aren’t two dissimilar really. The main point of interest is the keyword map, which is a function in both languages (well, in Ruby its technically a method on the array class), in Haskell this is a higher order function - can we call it a higher order function in Ruby???. The other point of interest is that Ruby has blocks/closures which can also be found in functional programming languages.
Ruby takes a lot of its ideas from LISP, so no wonder we can do the same sorts of things in Ruby and other Functional Programming Languages.

Let me know if you can think of an even easier/shorter way of doing it in either language.

Daniel

Technorati Tags: Haskell, Ruby, functional, programming