Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-04 Thread Kyle Murphy
Alright, here's my attempt to add comments, although once again it seems like the choice of algorithm in this example is a little wierd. By checking the output I was able to determine that it results in True for values of n*n-1, but why exactly that is I can't really figure out at the moment. If I

Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-04 Thread Samuel Williams
Thanks Roel and Kyle for your contributions! On 4/05/2010, at 10:35 PM, Roel van Dijk wrote: Here is my attempt. I tried to avoid higher concepts like folds and things like the ($) operator. Most recursions are written explicitly. { BEGIN CODE } module Main where -- Data type

[Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-03 Thread Samuel Williams
Also, one more thing - if someone could write some comments to go along with the source code that explain what it is doing, that would be really helpful. I can see the general structure, but I don't know the ins and outs of Haskell. If someone could augment the example with comments explaining

Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-03 Thread Rafael Gustavo da Cunha Pereira Pinto
If you are running from GHCi, just type run 100 at the prompt.. If you intend to compile it, you have to add main = print $ run 100 The compiler adds a call to main::IO (), which is intended to be the main entry point of your code. We need to add print, as run has type run::Int-[Door] so run

Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-03 Thread Kyle Murphy
Reasons to learn Haskell include: Lazy evaluation can make some kinds of algorithms possible to implement that aren't possible to implement in other languages (without modification to the algorithm). Strict type system allows for a maximum number of programming errors to be caught at compile time.

Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-03 Thread Luke Palmer
On Mon, May 3, 2010 at 9:17 AM, Kyle Murphy orc...@gmail.com wrote: Reasons to learn Haskell include: Lazy evaluation can make some kinds of algorithms possible to implement that aren't possible to implement in other languages (without modification to the algorithm). One could say the reverse

Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-03 Thread Samuel Williams
Dear Kyle, Improving the example to use more idiomatic Haskell is a good idea. I'm happy for you to propose another approach entirely. I'm simply not skilled in Haskell to do anything better. However, thanks for writing some comments for the code below, it will certainly help. Kind regards,

Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-03 Thread Samuel Williams
Dear Kyle, I've recevied the following program. You did a fantastic job of explaining the other one, but as you said it wasn't a great approach, if you have a moment could you explain this one? doorOpen :: Int - Bool doorOpen door = doh door door doh :: Int - Int - Bool doh door 0 = True doh