I came up with this function to try to extract the main diagonal.
getDiag :: [[a]] - [a]
getDiag = map (head . head) . iterate (tail . map tail)
The problem is, this function doesn't work unless I have an infinite
grid.
Could anyone provide me with some hints to lead me in the right
On Thu, Jul 19, 2007 at 11:39:26PM -0400, Ronald Guida wrote:
In Problem 11, a 20x20 grid of numbers is given, and the problem is to
find the largest product of four numbers along a straight line in the
grid. The line can be horizontal, vertical, or diagonal.
I found it easier to work with
Hello all,
Inspired by exercise on the minimal value of a given list I tried
myself produce several versions of such a function:
exercise: using just ($), head, filter, null, id, map, () without
explicit recursion definition
direct-forward: direct implementation using forward recursion,
Olivier Boudry [EMAIL PROTECTED] wrote:
(Wed Jul 18 11:56:56 EDT 2007)
Hi Dmitri,
I built gtk2hs on Windows with GHC 6.6.1 and gtk2hs-0.9.11. Here's are the
steps that worked for me: (not sure I didn't missed some)
First you need to install a GTK+ development package for windows. I think
mine
Anyone care to code up a Haskell implementation of this trivial interpreter
for comparison:
http://groups.google.co.uk/group/comp.lang.lisp/browse_frm/thread/7b1ab36f5d5cce0a/0ca59e0bfb794e07?hl=en#0ca59e0bfb794e07
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
Hello haskell-cafe,
can anyone provide wxHaskell already compiled/compilable with ghc 6.6.1 on
Windows?
--
Best regards,
Bulat mailto:[EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Ronald Guida ronguida at mindspring.com writes:
I started looking at the Euler problems [1]. I had no trouble with
problems 1 through 10, but I'm stuck on problem 11. I am aware that
the solutions are available ([2]), but I would rather not look just
yet.
I am the author of that solution
Sebastian Sylvan wrote:
minimumValue :: [Int] - Int
minimumValue ns = head (iSort ns)
If I were going to use a sort, then yes, that's the way I would do it.
Of course, sorting isn't the best way to solve the problem, as sorting
will always be at least O(n * log n), whereas a more
2007/7/19, Jason Dagit [EMAIL PROTECTED]:
I prefer,
allEqual [] = True
allEqual xs = foldl1 (==) xs
But, unfortunately, it's not a one liner like yours (unless you allow
allEqual [] = undefined).
Oh and silly me, that only works for [Bool].
My natural instinct is,
allEqual [] = True
Hello Benja,
Friday, July 20, 2007, 6:10:15 PM, you wrote:
My natural instinct is,
allEqual [] = True
allEqual (x:xs) = all (== x) xs
with the same caveat about allEqual [] as in your case.
allEqual xs = all (== head xs) xs
--
Best regards,
Bulat
2007/7/20, Bulat Ziganshin [EMAIL PROTECTED]:
allEqual [] = True
allEqual (x:xs) = all (== x) xs
with the same caveat about allEqual [] as in your case.
allEqual xs = all (== head xs) xs
Rght. Not evaluated in the edge case, because xs is empty. Didn't
think of that, nice :-)
-
Ronald Guida wrote:
Hi, again.
I started looking at the Euler problems [1]. I had no trouble with
problems 1 through 10, but I'm stuck on problem 11. I am aware that
the solutions are available ([2]), but I would rather not look just
yet.
[...]
FWIW I used a 2D array and a
Jim Burton wrote:
Ronald Guida wrote:
Hi, again.
I started looking at the Euler problems [1]. I had no trouble with
problems 1 through 10, but I'm stuck on problem 11. I am aware that
the solutions are available ([2]), but I would rather not look just
yet.
[...]
FWIW I
2007/7/20, Tillmann Rendel [EMAIL PROTECTED]:
Re, Joseph (IT) wrote:
At this point I'm out of ideas, so I was hoping someone could identify
something stupid I've done (I'm still novice of FP in general, let alone
for high performance) or direct me to a guide,website,paper,library, or
some
Thank you for all the hints.
Here's how I ended up solving it:
module Main
where
import Data.List
import Data.Maybe
gridText = 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08\n\
\49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00\n\
\81 49 31 73 55 79 14 29 93
Ah, I thought I might have to resort to one of the ByteStrings modules.
I've heard of them but was more or less avoiding them due to some
complexities with installing extra libraries in my current dev
environment. I'll try to work that out with the sysadmins and try it
out.
Thanks for the advice
Dougal Stanton wrote:
I think I will have to, sooner or later, become more versed in the
subtle ways of non-IO monads. They seem to be capable of some
seriously tricksy shenanigans.
Keep trying. At some point you will achieve enlightenment in a blinding
flash of light. Then you will write a
I wrote a short perl script to convert literate Haskell emails into pdf's.
It requires lhs2TeX and pdflatex and might not work on Windows. You can
darcs get http://rwf.mit.edu/~kyle/src/lhs-email/
I've tested it on a couple of articles from Oleg's FTP site - the source
and pdf output are in
Newbie question: why does the following give Not in scope 'c' for the last
line?
string :: Parsec.Parser String
string = do c - Parsec.letter
do cs - string
return c:cs
Parsec.| return [c]
(This is copied more or less rote from
Oh, I didn't realize how much of a difference it would make. Thanks a
lot!
-- Joseph Re
-Original Message-
From: Salvatore Insalaco [mailto:[EMAIL PROTECTED]
Sent: Friday, July 20, 2007 12:21 PM
To: Tillmann Rendel
Cc: Re, Joseph (IT); haskell-cafe@haskell.org
Subject: Re:
On Unix-like OSes:
If I run ghc test.hs and then run ghci test.hs, ghci fails to load
up my code. I have to touch test.hs and then run ghci. I can
understand ghci refusing to recompile something it thinks it has
already compiled. But it appears to refuse to load it into an
interactive session -
On Fri, Jul 20, 2007 at 10:10:58PM +0200, Hugh Perkins wrote:
Newbie question: why does the following give Not in scope 'c' for the last
line?
I assume you meant
string :: Parsec.Parser String
string = do c - Parsec.letter
do cs - string
return c:cs
Kindof vaguely made a start on this, but cant quite see how to handle
variables.
I guess variables can be stored as a (Map.Map String Double), at least for a
first draft?
Then, I'm building up two hierarchies in parallel:
- a set of parsec functions to parse the incoming string into a Program
Hugh Perkins wrote:
That works just fine as long as the only thing eval has to cope with
is print statements (so eval has type IO ()), but I'm guessing the
clean solution is to thread a Map.Map through that somehow?
You could do that but your code starts to become messy and you'll hit
other
Hi Dan,
On Fri, Jul 20, 2007 at 02:12:12PM -0700, Dan Piponi wrote:
On Unix-like OSes:
If I run ghc test.hs and then run ghci test.hs, ghci fails to load
up my code. I have to touch test.hs and then run ghci. I can
understand ghci refusing to recompile something it thinks it has
already
Ok, that got the variables working.
Example:
*Minim evaluateprog $ ProgramTree ( ProgramLeaf $ AssignmentStatement(
VarAssignment (Variable test) ( ValueFromConstant (Constant 3 (
PrintStatement (PrintValue( ValueFromVariable(Variable test
3.0
3.0
I'm having eval return the IO monad,
Hi Bulat,
can anyone provide wxHaskell already compiled/compilable with ghc 6.6.1 on
Windows?
Please try the darcs version
darcs get http://darcs.haskell.org/wxhaskell
It's probably simplest to get it working with wxWidgets 2.6.4
27 matches
Mail list logo