Fernan Bolando wrote:
what is the simplest way to implement the following code in haskell?
it's just printing the contents of 2D array.
for(i = 0; i imax; i++){
for(n = 0; n nmax; n++){
printf(%i:%i = %f\n, array[i][n]);
}
}
*%* ghci
___ ___ _
* / _ \ /\ /\/ __(_)
Thanks for all the excellent answers to my original question. Somehow
it feels like I advanced and got one level closer to a black belt in
Haskell due to this; I've now legitimately used a function from
System.IO.Unsafe :-)
I tried to document it all: http://therning.org/magnus/archives/249
/M
On Thu, 18 Jan 2007, Novák Zoltán wrote:
I have to admit that I do not fully understand the Haskell numerical tower...
Now I'm using the Newton method:
mysqrt :: (Fractional a) = a - a
mysqrt x = (iterate (\y - (x / y + y) / 2.0 ) 1.0) !!2000
But I want a faster solution. (Not by
Magnus Therning [EMAIL PROTECTED] writes:
Thanks for all the excellent answers to my original question. Somehow
it feels like I advanced and got one level closer to a black belt in
Haskell due to this; I've now legitimately used a function from
System.IO.Unsafe :-)
I tried to document it
On Jan 18, 2007, at 10:09 PM, Yitzchak Gale wrote:
I wrote:
Will (id :: A - A $!) do the trick?
Ulf Norell wrote:
The problem is not with id, it's with composition. For any f and g we
have
f . g = \x - f (g x)
So _|_ . g = \x - _|_ for any g.
OK, so then how about
f .! g = ((.) $! f)
On Fri, Jan 19, 2007 at 11:19:16 +0100, Ferenc Wagner wrote:
Magnus Therning [EMAIL PROTECTED] writes:
Thanks for all the excellent answers to my original question. Somehow
it feels like I advanced and got one level closer to a black belt in
Haskell due to this; I've now legitimately used a
Hi,
Am Freitag, den 19.01.2007, 11:19 +0100 schrieb Ferenc Wagner:
Magnus Therning [EMAIL PROTECTED] writes:
Thanks for all the excellent answers to my original question. Somehow
it feels like I advanced and got one level closer to a black belt in
Haskell due to this; I've now
Hi,
Thanks for the answers. The best solution would be a general purpose
arbitrary precision math library for Haskell. I found two:
http://medialab.freaknet.org/bignum/
http://r6.ca/FewDigits/
I think both uses power series and have trigonometric functions too. (I only
need sqrt, so probably I
Hi Fernan,
You wrote:
what is the simplest way to implement the following code in haskell?
it's just printing the contents of 2D array.
for(i = 0; i imax; i++){
for(n = 0; n nmax; n++){
printf(%i:%i = %f\n, array[i][n]);
}
}
There are many different ways of
Greg Fitzgerald wrote:
I'd like to write a very simple Haskell script that when given a URL,
looks up the page, and returns a string of HTML. I don't see an HTTP
library in the standard libs, and the one in Hackage requires Windows
machines have GHC and MinGW to be installed and in the PATH.
Hi Zoltán,
I only need sqrt, so probably I will... use... just
the simple Newton alg.
It is still not clear to me what type you want
to work in. Is it Rational? In that case, you don't
need the Newton algorithm.
realToFrac . sqrt . realToFrac
works fine, as you originally suggested. If that
On Jan 19, 2007, at 1:06 PM, Yitzchak Gale wrote:
Hmm. I wrote:
for simplicity, we will ignore these distinctions
But do we really want to do that? Are the monads
that we use every day in Haskell really monads
if we check the axioms using (.!) instead of (.)
as we should? I'm not so sure
On Fri, 19 Jan 2007, Ulf Norell [EMAIL PROTECTED] wrote:
Personally I think that the distinction between _|_ and \x - _|_ is
a mistake and should be ignored whenever possible.
If you want to write an accessible tutorial you should probably use a
total programming language, or at least the
Ulf Norell wrote:
In the section on the category laws you say that the identity morphism
should satisfy
f . idA = idB . f
This is not strong enough. You need
f . idA = f = idB . f
Unfortunately, fixing this means that the category Hask is no longer a
category since
_|_ . id
If it's arbitrary precision floating point that you want then sqrt
should where it already is, as a member of Floating. (I find
arbitrary precision real to be an oxymoron, the real numbers are
the real numbers, they already have arbitrary precision.)
For a real number module, you can use,
And this is why some of us think that adding polymorphic seq to
Haskell was a mistake. :(
-- Lennart
On Jan 19, 2007, at 08:05 , [EMAIL PROTECTED] wrote:
Ulf Norell wrote:
In the section on the category laws you say that the identity
morphism
should satisfy
f . idA = idB . f
G'day all.
Quoting Henning Thielemann [EMAIL PROTECTED]:
Newton method for sqrt is very fast. It converges quadratically, that is
in each iteration the number of correct digits doubles. The problem is to
find a good starting approximation.
Yup. So how might we go about doing this?
First
Hello,
On Friday 19 January 2007 16:48, [EMAIL PROTECTED] wrote:
...
sqrtApprox' :: Integer - Rational
sqrtApprox' n
| n 0 = error sqrtApprox'
| otherwise = approx n 1
where
approx n acc
| n 256 = (acc%1) * approxSmallSqrt (fromIntegral n)
On 19/01/07, Yitzchak Gale [EMAIL PROTECTED] wrote:
OK, thanks! Time to re-write the Note
paragraph yet again. Here goes a first
shot at it:
This was a bit much to include in the introduction section, so I added
a footnote. Hopefully I got everything right; I tend to take the view
that we
Lennart Augustsson wrote:
On Jan 19, 2007, at 08:05 , [EMAIL PROTECTED] wrote:
Thus, Hask is not a category, at least not as defined in the article.
The problem is that (either) morphisms or the morphism composition
('.')
are not internalized correctly in Haskell.
And this is why some of
Hi Brian,
I've often wondered why seq is the primitive and not $!
Would this solve the problem?
Is there any solution that would allow excess laziness to be removed from a
Haskell program such that Hask would be a category?
class Seq a where
seq :: a - b - b
Then you have a different seq
Alistair, Neil, Brad, Yitzchak, Bjorn,
Thanks all for your help.
-Greg
On 1/19/07, Björn Bringert [EMAIL PROTECTED] wrote:
Greg Fitzgerald wrote:
I'd like to write a very simple Haskell script that when given a URL,
looks up the page, and returns a string of HTML. I don't see an HTTP
On Jan 19, 2007, at 1:07 PM, Brian Hulley wrote:
Lennart Augustsson wrote:
On Jan 19, 2007, at 08:05 , [EMAIL PROTECTED] wrote:
Thus, Hask is not a category, at least not as defined in the
article.
The problem is that (either) morphisms or the morphism composition
('.')
are not
CALL FOR PAPERS
Trends in Functional Programming 2007
New York, USA
April 2-4, 2007
http://cs.shu.edu/tfp2007/
NEW: Abstract submission is now open! Link:
http://cs.shu.edu/tfp2007/submissions.html
NEW: Invited Talk: John McCarthy, Standford University
The symposium on Trends in Functional
Neil Mitchell wrote:
Hi Brian,
Is there any solution that would allow excess laziness to be removed
from a Haskell program such that Hask would be a category?
class Seq a where
seq :: a - b - b
Then you have a different seq based on the types, and it doesn't go
wrong. You would probably
On 19/01/07, Brian Hulley [EMAIL PROTECTED] wrote:
1) Does anyone know why this was not used in the first place?
It was decided that strictness annotations, and optimisations in
general, should typically come after you'd written your program.
However, requiring a Seq context everywhere would
On 1/20/07, Brian Hulley [EMAIL PROTECTED] wrote:
Neil Mitchell wrote:
Hi Brian,
Is there any solution that would allow excess laziness to be removed
from a Haskell program such that Hask would be a category?
class Seq a where
seq :: a - b - b
Then you have a different seq based on
Hi all,
Some time ago I reported a strange file locking problem. I have reduced my
offending program to a relatively small size.
This reduction process was quite entertaining. At one point, I could
reliably turn the locking off and on by removing and reintroducing a
certain unused import :s. I
Except that the example was not attached. Sorry.
Greetings,
Arie
min.tar.gz
Description: application/gzip
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
No, making $! the primitive would not help. You can define seq from $!.
I think seq is a suitable primitive, it's just that it ruins nice
properties.
The original formulation of seq in Haskell was the right one in my
opinion:
class Eval where
seq :: a - b - b
This way you get a
This solution was used in the first place. But then some people were
too lazy
to actually use the Eval (as Seq was called) class, so they wanted
a polymorphic seq. And so we're in this mess. And it is a mess,
e.g., the foldr/build transformation ghc uses to fuse list processing
isn't really
One nit and one massive praise.
nit first. in 'the monad laws and their importance' you say given a
monad M and then outline the laws a functor must satisfy to be a
monad. I would find it clearer to say 'a functor M', and then
emphasise the iff relationship between the laws and the functor M.
32 matches
Mail list logo