It would be very much like Opera... when I use Opera, I feel like I am using something orthogonal to the internet and opposed to right down in it.
Opera goes to great pains to be elegant and correct and will not let down its hair in the name of practicality or speed. It is very beautiful and it would be nice if the internet raised its standards to opera. But that isn't going to happen.
Life is unfortunately more of a slugfest than a ballet dance. More of a play-it-by-the-ear than force-a-conclusion-by-mathematical-induction.
Ok, first LD(n) is the least divisor of n. It is a number, p, such
that p*a = n and a > p and p > 1.
So now to express LD(n) as a Haskell function:
ld n = ldf 2 n
Where ldf 2 n means the least divisor of n that is >= 2.
Hopefully it is understood that the Haskell expression of ld(n) is
equivalent to our initial mathematical definition.
Now, something else that is asserted and then proved:
n > 1 and n not prime IMPLIES (LD(n))^2 less than or equal to n
So then the following definition of ldf k n is offered
ld n = ldf 2 n ldf k n | divides n k = k | k^2 > n = n | otherwise = ldf (k+1) n
But I do not understand why the second guard is true. Clearly it has
to do with "n > 1 and n not prime IMPLIES (LD(n))^2 <= n" but I do not
see how they relate.
Stating things tractably:
Let's forget about my problem for a second and look at how to state
It may be true that if n is prime then that means that n is only
divisible by 1 and itself. But is that the most algebraic way of
stating it? Can you go from that statement you just made to anything
useful? Maybe, but let's take a look at this way of stating it:
n prime means that only 1 * n = n and nothing else
One other thing. Let's try this same technique for what it means for a to be divisible by b? It means that b * x = a, where x is integral.
Now what have we bought ourselves? Instead of primeness and divisibility being two concepts with no apparent relation, we see them both in terms of what it means for products involving things which are prime and things which are divisible. Both concepts are now expressed as
E * Fwhere E and F vary based on which concept we are talking about.
Why is this useful? Because at one point in my following the proof, I hit this statement: assume c = LD(n) is not prime. In other words "Assume that the least divisor of n is c and it is not prime." Now we reach the second thing:
State all implicationsSo let's take our statement and explore each isolated fact: First, c is the least divisor of n tell us all of this:
And c not prime tells us all of this:
Now what threw me is when the author of the text said: "Then there are natural numbers a and b with c = a * b, and also 1 < a and a < c. but then a divides n..." and that is what confused me. He did not directly show how it was true that a divides n. But if you look above, we have
c * q = nbut also
a * b = c. By substituing
a * bfor c, we have
a * b * q = nwhich means that a divide n.
Any ideas on how much work needs to be done for using Haskell on PPC Windows Mobile platform?
It would be interesting to use PPC as:
1) Haskell learning tool, so small code snipets could be entered and run directly on hand-held (REPL). How hard is it to port Hugs to PPC for this? Do any other (then Hugs) implementations exist that are easier to port?
2) Running on PPC Haskell applications cross-compiled on host PC. How much work must be done for GHC to support this?
3) There are several ways both for porting Haskell to PPC as well as cross-compiling Haskell code. Which one makes more sense to implement and will take less effort:
a) Porting/compiling to VM byte code (Java, Parrot)?
b) Porting/compiling to .NET CLR?
4) And finally, do any projects already exist in this area?
Haskell newbie: Recursive lambda definitions?
Simon Thompson gives the following exercise (10.9) in his "Haskell. The Craft of Functional Programming" book:
10.9 Define a function total
total:: (Int -> Int) -> (Int -> Int)
so that total f is the function which at value n gives the total
f 0 + f 1 + ... + f n
I use 'where' clause to describe the resulting function 'tot':
total:: (Int -> Int) -> (Int -> Int) total f = tot where tot n | n >= 0 = (f n) + (tot (n-1)) | otherwise = 0 test = total f1 4
Q: Is it possible instead of naming and defining a resulting function (such as 'tot' in this example) just use recursive lambda definition? In this example recursion is required to create a function which is a variable sum of another function applications like:
f 0 + f 1 + ... + f n
Giving function a name ('tot' in this case) makes recursive definition possible. But what about lambda recursion? Can it be defined?
In the same article Joel Spolsky seems to imply that it is impossible to do recursion in Java.
I find that hard to believe...
In the Perils of Java Schools, Joel Spoelsky states:
Without understanding functional programming, you can't invent MapReduce, the algorithm that makes Google so massively scalable. The terms Map and Reduce come from Lisp and functional programming. MapReduce is, in retrospect, obvious to anyone who remembers from their 6.001-equivalent programming class that purely functional programs have no side effects and are thus trivially parallelizable. The very fact that Google invented MapReduce, and Microsoft didn't, says something about why Microsoft is still playing catch up trying to get basic search features to work, while Google has moved on to the next problem: building Skynet^H^H^H^H^H^H the world's largest massively parallel supercomputer. I don't think Microsoft completely understands just how far behind they are on that wave
[17:00:07] > let fibs = 1:1:(zipWith (+) fibs (tail fibs)) in take 10 $ fibs
[17:00:14] <_metaperl> the free haskell books are not very good
[17:00:31] they're good enough for me, for now
[17:00:49] <_metaperl> jethr0: he did something like [ | x <- [1, 1] , y <- [2, ] ]
[17:00:52] <_metaperl> I cant remember it
[17:01:07] let fibs = [1,1] ++ [x + y | x <- fibs, y <- tail fibs] in take 10 $ fibs
length :: [a] -> Int. You'd also probably want to allow swizzling of the input arguments so that you could find "map" with a search like "[a] -> (a -> b) -> [b]". Then the next step would be to analyze your existing code to see if you've reinvented any wheels.