using lists, and
attempting to index into them and measure their lengths. Perhaps a
different data structure is in order.
Thanks
Tom Davie
On 3 Apr 2013, at 17:38, Lone Wolf amslonew...@gmail.com wrote:
http://stackoverflow.com/questions/8940470/algorithm-for-finding-numerical
.
Thanks
Tom Davie
On 3 Apr 2013, at 17:38, Lone Wolf amslonew...@gmail.com wrote:
http://stackoverflow.com/questions/8940470/algorithm-for-finding-numerical-permutation-given-lexicographic-index
How would you rewrite this into Haskell? The code snippet is in Scala.
/**
example
http://stackoverflow.com/questions/8940470/algorithm-for-finding-numerical-permutation-given-lexicographic-index
How would you rewrite this into Haskell? The code snippet is in Scala.
/**
example: index:=15, list:=(1, 2, 3, 4)
*/
def permutationIndex (index: Int, list: List [Int
efficient, because you're using lists, and
attempting to index into them and measure their lengths. Perhaps a different
data structure is in order.
Thanks
Tom Davie
On 3 Apr 2013, at 17:38, Lone Wolf amslonew...@gmail.com wrote:
http://stackoverflow.com/questions/8940470/algorithm-for-finding
Sorry for the delayed response -- I've had exams the past few days.
On Sun, May 27, 2012 at 8:21 PM, Eugene Kirpichov ekirpic...@gmail.com wrote:
A lot of people have done this :) eg from me: google up a fairly recent
thread from me about processing streams and perhaps the keyword timeplot
Hello all
I just came up with a way of executing multiple folds in a single
pass. In short, we can write code like this:
average = foldLeft $ (/) $ sumF * lengthF
and it will only traverse the input list once.
The code is at: https://gist.github.com/2802644
My question is: has anyone done
A lot of people have done this :) eg from me: google up a fairly recent thread
from me about processing streams and perhaps the keyword timeplot (writing
from a dying phone, can't do myself)
27.05.2012, в 12:04, Chris Wong chrisyco+haskell-c...@gmail.com написал(а):
Hello all
I just came
There are a few blog posts by Conal Elliott and Max Rabkin (I think)
reifying folds as a data type to get more composition and thus fold
different functions at the same time. Search for beautiful folding
with the above authors names.
Personally I didn't find the examples significantly more
Hi Chris,
On 05/27/2012 10:04 AM, Chris Wong wrote:
I just came up with a way of executing multiple folds in a single
pass. In short, we can write code like this:
average = foldLeft $ (/)$ sumF* lengthF
and it will only traverse the input list once.
The code is at:
On Sat, Jan 21, 2012 at 8:18 AM, Twan van Laarhoven twa...@gmail.com wrote:
Notice that there are lots of miku-X prefixes found. This is probably not
what you want. What exactly do you want the algorithm to do? For example,
is obviously a prefix of every string, but it is not very long. On the
On 2012-01-20 23:44, Gwern Branwen wrote:
On Fri, Jan 20, 2012 at 1:57 PM, Twan van Laarhoventwa...@gmail.com wrote:
Here is some example code (untested):
Well, you're right that it doesn't work. I tried to fix the crucial
function, 'atLeastThisManyDescendants', but it's missing something
name files with hyphens as the
delimiters like the hypothetical '1998-wadler-monads.pdf', and it
would be easy to write a stdin/stdout filter to break Strings on
hyphens and sort by whatever is most common. But this is rather
hardwired, can I solve the more general problem of finding the longest
On 20/01/12 18:45, Gwern Branwen wrote:
Recently I wanted to sort through a large folder of varied files and
figure out what is a 'natural' folder to split out, where natural
means something like4 files with the same prefix.
My idea for an algorithm would be: build a trie for the input
On Fri, Jan 20, 2012 at 1:57 PM, Twan van Laarhoven twa...@gmail.com wrote:
Here is some example code (untested):
Well, you're right that it doesn't work. I tried to fix the crucial
function, 'atLeastThisManyDescendants', but it's missing something
because varying parts doesn't much affect the
Stephen Tetley wrote:
I thought I read that Firefox does a font swap if it can't find a
glyph, but thinking about it myself I can't see that this would make
sense - Firefox would have to know an awful lot about the OSes fonts
to know if they have missing glyphs.
You're pretty much right,
Hello John
Thanks for the information - after I posted that message I read the
CSS section of Yannis Haralambous's Fonts Encodings (_the_ book of
all things font) and it has this text:
In other words, the browser will check not only the existence of a
given font but also the existence of each
On 05/11/2010 09:05 PM, Stephen Tetley wrote:
On 5 November 2010 20:08, Andrew Coppinandrewcop...@btinternet.com wrote:
Would it be hard to replace - with a real Unicode arrow character?
It should be quite easy - whether a given font has an arrow readily
available is a different matter.
I
On 6 November 2010 09:52, Andrew Coppin andrewcop...@btinternet.com wrote:
I can't remember the last time I saw a browser that couldn't do this. There
/are/ symbols that don't work reliably, but the basic arrow symbols seem to
be pretty well supported.
Okay I'll shift my position a bit...
On Nov 6, 2010, at 3:56 AM, Stephen Tetley wrote:
Modern browsers might add in arrow from a different font if it is not
present in the one chosen by the web page author - I suspect this is
happening on this page where the arrow looks wrong typographically:
I don't think that's what's going
On 6 November 2010 18:01, Alexander Solla a...@2piix.com wrote:
On Nov 6, 2010, at 3:56 AM, Stephen Tetley wrote:
Modern browsers might add in arrow from a different font if it is not
present in the one chosen by the web page author - I suspect this is
happening on this page where the arrow
dons:
magnus:
I know there's a .cabal file for the latest version of HP somewhere,
but I can't coerce Google into finding me a link that actually works.
Furthermore, the following page:
http://hackage.haskell.org/platform/contents.html
does list all the contents, but to my big
On 05/11/2010 02:59 PM, Don Stewart wrote:
The changelog now lists all the versions:
http://hackage.haskell.org/platform/changelog.html
This is quite optimal.
It would still be nice if one could easily answer the question which HP
release was the one that contained process-1.0.1.1,
On 5 November 2010 20:08, Andrew Coppin andrewcop...@btinternet.com wrote:
Would it be hard to replace - with a real Unicode arrow character?
It should be quite easy - whether a given font has an arrow readily
available is a different matter. It might be be simpler to drop into
the Symbol font
On 2010-11-05 21:05 +, Stephen Tetley wrote:
On 5 November 2010 20:08, Andrew Coppin andrewcop...@btinternet.com wrote:
Would it be hard to replace - with a real Unicode arrow character?
It should be quite easy - whether a given font has an arrow readily
available is a different matter.
On 5 November 2010 21:31, Nick Bowler nbow...@elliptictech.com wrote:
Except that the Symbol font family is not available in all browsers.
Ah ha - indeed you are right and the puritans at W3C and Mozilla.org
seem to have dug their heels in.
Unfortunately arrows don't appear to be in either the
I know there's a .cabal file for the latest version of HP somewhere,
but I can't coerce Google into finding me a link that actually works.
Furthermore, the following page:
http://hackage.haskell.org/platform/contents.html
does list all the contents, but to my big surprise it doesn't link
magnus:
I know there's a .cabal file for the latest version of HP somewhere,
but I can't coerce Google into finding me a link that actually works.
Furthermore, the following page:
http://hackage.haskell.org/platform/contents.html
does list all the contents, but to my big surprise
On Mon, Nov 1, 2010 at 14:47, Don Stewart d...@galois.com wrote:
magnus:
I know there's a .cabal file for the latest version of HP somewhere,
but I can't coerce Google into finding me a link that actually works.
Furthermore, the following page:
http://hackage.haskell.org/platform
On Mon, 18 Oct 2010 22:03:15 +0200, d...@patriot.net wrote:
OK, I'm trying to install Haskore and it depends on an old version of
QuickCheck. I'm happy to hack and update, but is there any way of
finding
out which modules depend on QuickCheck rather than going through each
file
one by one
On 18 October 2010 21:03, d...@patriot.net wrote:
[SNIP]
I'm happy to hack and update, but is there any way of finding
out which modules depend on QuickCheck rather than going through each file
one by one?
grep for QuickCheck? - any module that uses it will need it in the
import list
Günther Schmidt gue.schm...@web.de writes:
how can I find out which gcc a ghc is hard-coded to use and is it
possible to override it?
At least in Linux as of 6.12.2, the /usr/bin/ghc wrapper script has a
link to it.
--
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
Hello,
how can I find out which gcc a ghc is hard-coded to use and is it
possible to override it?
Günther
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
If you're on Windows, I believe you can find the gcc.exe at the following
location:
C:\Program Files\Haskell Platform\2009.2.0.2\gcc.exe
See this link for how to pick which C compiler to use:
http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/options-phases.html#replacing-phases
2010/8/6
On 6 Aug 2010, at 18:05, Günther Schmidt wrote:
Hello,
how can I find out which gcc a ghc is hard-coded to use and is it
possible to override it?
See this page:
http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/options-phases.html
Cheers,
G
Sergey Mironov wrote:
Sorry for late answer. Luke, Heinrich - thank you very much for explanations.
I feel that I need more reading to get familiar with differentiation
of functors and chain rule. Could you suggest some books or papers?
For differentiation of data types, there is for example
2010/7/2 Heinrich Apfelmus apfel...@quantentunnel.de:
Sergey Mironov wrote:
Hello list!
I am trying to understand zipper concept using papers like [1] and [2].
Though main idea looks clear, I still have a problem in applying it for
custom data types.
Please help me with deriving
Günther Schmidt wrote:
Hi list,
the problem I have stems from the app I had developed. What my app does
is to split the money a hospital receives for a case to the departments
involved in a fair way.
An additional requirement however was to allow the users of the app to
re-map any revenue
If you ignore the identity mappings (which all technically create
trivial loops), these mappings would form a directed acyclic graph
(DAG). I would look at some of the graph libraries, e.g. fgl, to see
if they have anything appropriate.
John
From: G?nther Schmidt gue.schm...@web.de
Hi list,
Hi list,
the problem I have stems from the app I had developed. What my app does
is to split the money a hospital receives for a case to the departments
involved in a fair way.
An additional requirement however was to allow the users of the app to
re-map any revenue shares credited to
What sort of model would be suitable to describe this, some sort of
matrix?
You still can get loops if your matrix represents graph.
Sounds like you need a tree.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Luke Palmer wrote:
I would just use List. IIRC the derivative of list is:
data DList a = DLIst [a] [a]
Understood as the elements before the focused one and those after it.
Unfortunately I can't remember how that is derived, and my own
experiments failed to come up with anything similar.
Sergey Mironov wrote:
Hello list!
I am trying to understand zipper concept using papers like [1] and [2].
Though main idea looks clear, I still have a problem in applying it for
custom data types.
Please help me with deriving Zipper-type from
data DTree a = P | D [(a, DTree)]
Looking in [1]
Hello list!
I am trying to understand zipper concept using papers like [1] and [2].
Though main idea looks clear, I still have a problem in applying it for
custom data types.
Please help me with deriving Zipper-type from
data DTree a = P | D [(a, DTree)]
Looking in [1] ('Zippers via
On Thu, Jul 1, 2010 at 1:54 PM, Sergey Mironov ier...@gmail.com wrote:
Hello list!
I am trying to understand zipper concept using papers like [1] and [2].
Though main idea looks clear, I still have a problem in applying it for
custom data types.
Please help me with deriving Zipper-type from
Günther Schmidt wrote:
I've got a problem, in short my haskell code sucks. While it does work
and I do manage to use higher-orderish aspects quite extensively to make
my code more concise it still is nowhere abstract, always concrete and
thus always with lots of boilerplate.
Oh I have
Hello,
I've got a problem, in short my haskell code sucks. While it does work
and I do manage to use higher-orderish aspects quite extensively to make
my code more concise it still is nowhere abstract, always concrete and
thus always with lots of boilerplate.
Oh I have gotten better
2010/2/14 Günther Schmidt gue.schm...@web.de:
So fellows, what is the next stop on my road to enlightenment? I really
think I need best to start from scratch. I think I'm sufficiently familiar
now with most of Haskell's technicalities but how do I climb the ladder of
abstraction?
A couple of
* On Sun, Feb 14 2010, Günther Schmidt wrote:
So fellows, what is the next stop on my road to enlightenment? I
really think I need best to start from scratch. I think I'm
sufficiently familiar now with most of Haskell's technicalities but
how do I climb the ladder of abstraction?
Read more
Hi Günther
Promoting a slightly contrary view, I'm not sure that abstraction
should be a goal in itself. Richard Gabriel makes a point of valuing
'habitable' code over abstract code in his 'Patterns of Software' book
(free from his website now that it's out of print). Habitable code
being code
On Feb 14, 2010, at 4:38 AM, Günther Schmidt wrote:
I've got a problem, in short my haskell code sucks. While it does
work and I do manage to use higher-orderish aspects quite
extensively to make my code more concise it still is nowhere
abstract, always concrete and thus always with lots
Well I just noticed that the boilerplate part consists of this:
Import data by selecting fields from a table, feed them into some sort
of internal data structure for later querying, times 12. All this
involves quite a bit of boilerplate.
Yeah, I guess I could abstract here a little.
Günther
Hello,
2010/2/14, Günther Schmidt gue.schm...@web.de:
Hello,
I've got a problem, in short my haskell code sucks. While it does work
and I do manage to use higher-orderish aspects quite extensively to make
my code more concise it still is nowhere abstract, always concrete and
thus always
Hi all,
I was looking through some of the Hackage packages to find examples of
how developers are extending UserHooks in their Setup files, but it
wasn't easy, since the great majority of Cabal Setup files in Hackage
simply require only the standard line of 'main = defaultMain' or
Malcolm Wallace wrote:
The suggestion was to have a single Download button, leading to a
*page* of suitably described links, allowing the user to choose
whether they only wanted the basics (a choice of compiler/interpreter
+ cabal), or the whole Platform, or something else. It would be the
The suggestion was to have a single Download button, leading to a *page* of
suitably described links, allowing the user to choose whether they only
wanted the basics (a choice of compiler/interpreter + cabal), or the whole
Platform, or something else. It would be the ideal place to explain
Don Stewart wrote:
vandijk.roel:
On Wed, Dec 2, 2009 at 11:44 PM, Gregory Crosswhite
gcr...@phys.washington.edu wrote:
On a more serious note, Download Haskell /= Download Haskell Platform, so if I were glancing
down the sidebar looking for a link to download the Haskell Platform then the
On Wed, Dec 2, 2009 at 11:44 PM, Gregory Crosswhite
gcr...@phys.washington.edu wrote:
On a more serious note, Download Haskell /= Download Haskell Platform, so
if I were glancing down the sidebar looking for a link to download the
Haskell Platform then the first link wouldn't have registered
Furthermore, when someone offers feedback designed to improve a page, and
does so in a very non-threatening way:
On Dec 2, 2009, at 2:26 PM, Andrew Coppin wrote:
My suggestion is that if we really want people to grab the HP rather than
download GHC directly, maybe we could make the
2009/12/3 Tony Morris tonymor...@gmail.com:
Furthermore, when someone offers feedback designed to improve a page, and
does so in a very non-threatening way:
On Dec 2, 2009, at 2:26 PM, Andrew Coppin wrote:
My suggestion is that if we really want people to grab the HP rather than
If I wanted to know something *about* the *Haskell Platform* I would
click the link The Haskell Platform under the section About. So it is
actually mentioned 3 times on the front page. What could be improved
are the 2 download links: Download Haskell and Download GHC. It
would perhaps be
vandijk.roel:
On Wed, Dec 2, 2009 at 11:44 PM, Gregory Crosswhite
gcr...@phys.washington.edu wrote:
On a more serious note, Download Haskell /= Download Haskell Platform,
so if I were glancing down the sidebar looking for a link to download the
Haskell Platform then the first link
I think it makes sense, the HP is supposed to set up the entire
environment needed for typical haskell development (at least, that is
my understanding). As such, what's the point in making downloading
haskell mean downloading a single _peice_ of haskell (GHC) only to
have to download
I'm all for making HP the default as long as we find a way to make some of
the larger packages (I'm thinking gtk2hs) either ship with HP in Windows or
install correctly with HP.
On Thu, Dec 3, 2009 at 11:46 AM, Joe Fredette jfred...@gmail.com wrote:
I think it makes sense, the HP is supposed to
It would perhaps be better to have one nice big Download button
that
takes you to a separate download page.
Having a single download link that only points to the Haskell Platform
would be a bit of a policy shift.
... but that was *not* what was suggested.
The suggestion was to have a
malcolm.wallace:
The suggestion was to have a single Download button, leading to a *page*
of suitably described links, allowing the user to choose whether they
only wanted the basics (a choice of compiler/interpreter + cabal), or the
whole Platform, or something else. It would be the ideal
On Dec 3, 2009, at 11:43 , Don Stewart wrote:
vandijk.roel:
On Wed, Dec 2, 2009 at 11:44 PM, Gregory Crosswhite
gcr...@phys.washington.edu wrote:
On a more serious note, Download Haskell /= Download Haskell
Platform, so if I were glancing down the sidebar looking for a
link to download the
Today I was setting up a my new, and I wanted to put Haskell on it.
Rather than download GHC itself, I decided to install the Haskell
Platform instead, just to see what it's like.
Much to my surprise, I couldn't actually find any reference to its
existence anywhere from the haskell.org home
andrewcoppin:
Today I was setting up a my new, and I wanted to put Haskell on it.
Rather than download GHC itself, I decided to install the Haskell
Platform instead, just to see what it's like.
Much to my surprise, I couldn't actually find any reference to its
existence anywhere from
On Dec 2, 2009, at 2:26 PM, Andrew Coppin wrote:
Subsequently, I realise [as somebody will no doubt point out] that the link
is actually there, on the front page, right next to GHC, Hugs, et al.
On Dec 2, 2009, at 2:29 PM, Don Stewart wrote:
It is listed right on the front page, twice.
I wrote a solution to this problem, but it appears to return incorrect
results. There's a pastebin of the code at
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2121 and a picture of the
inputs, outputs, and expected results graphed at
http://img510.imageshack.us/img510/9971/resultsg.jpg
I'm
Whenever I'm looking for a bug in Haskell code, I find it helpful to start
by seeing if I can simplify the code any first. In this case, there are a
couple of things I notice:
- validPointsOf is just a filter. It would be easier to write valid ::
MyDirection - Bool and then validPointsOf =
Am Donnerstag, 5. März 2009 13:40 schrieb Rob Crowther:
I wrote a solution to this problem, but it appears to return incorrect
results. There's a pastebin of the code at
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2121 and a picture of the
inputs, outputs, and expected results graphed at
Quick question.
In Linux, if you want to find the PID of a process, you use getProcessID from
System.Posix.Process.
How do you do the same under Windows? I cannot find the equivalent function
in System.Win32 and searching Google does not yield any useful results.
Thanks.
Hello Alexandru,
Sunday, February 22, 2009, 7:38:31 PM, you wrote:
In Linux, if you want to find the PID of a process, you use getProcessID from
The GetCurrentProcessId function returns the process identifier of the calling
process.
DWORD GetCurrentProcessId(VOID)
you need to make FFI
On 16/04/2008, at 22:15, Graham Fawcett wrote:
Hi folks, I'm a newbie, so please forgive any terminological mistakes.
I've been using Shim in Emacs with great success, but there's one
issue I've encountered, and I don't know if it's configuration problem
or something fundamental. Consider a
On Thu, Apr 17, 2008 at 4:26 AM, pepe [EMAIL PROTECTED] wrote:
On 16/04/2008, at 22:15, Graham Fawcett wrote:
I'd like to be able to tell Shim that 'App' is the root of my project,
and to locate modules from that root. Is this possible?
Shim already does this. All it requires is that
I'd like to be able to tell Shim that 'App' is the root of my project,
and to locate modules from that root. Is this possible?
If adding the cabal file does'nt work contact me and we'll try to
reslove this issue. Are you willing to test new versions/ extensions?
Are you already using ghc-6.8 ?
On Thu, Apr 17, 2008 at 10:41 AM, Marc Weber [EMAIL PROTECTED] wrote:
I'd like to be able to tell Shim that 'App' is the root of my project,
and to locate modules from that root. Is this possible?
If adding the cabal file does'nt work contact me and we'll try to
reslove this issue.
It
Graham == Graham Fawcett [EMAIL PROTECTED] writes:
Graham Equally glad that it's being supported! Thank you.
Where one can found it?
Few days ago I was told on #haskell that shim is dead :-/
Sincerely,
Gour
--
Gour | Zagreb, Croatia | GPG key: C6E7162D
2008/4/17 Gour [EMAIL PROTECTED]:
Graham == Graham Fawcett [EMAIL PROTECTED] writes:
Graham Equally glad that it's being supported! Thank you.
Where one can found it?
Few days ago I was told on #haskell that shim is dead :-/
The original, I believe:
http://mapcar.org/haskell/shim/
Hi folks, I'm a newbie, so please forgive any terminological mistakes.
I've been using Shim in Emacs with great success, but there's one
issue I've encountered, and I don't know if it's configuration problem
or something fundamental. Consider a module 'App' and submodules
'App.Front' and
On Wed, Feb 27, 2008 at 2:01 AM, Judah Jacobson
[EMAIL PROTECTED] wrote:
Hi Denis,
I was unable to run your program; it looks like there's a missing
module 'Properties'. To include it in the sdist you probably need to
add it under the other-modules field in the .cabal file.
Sorry about
On Wed, Feb 27, 2008 at 12:06 AM, [EMAIL PROTECTED] wrote:
Fortuitously, I recently came across a bunch of bioinformatics software in
Haskell. One of the libraries was called 'interlude', and it claims to be
able to give line locations for errors in the Prelude. I was intending to
upload
Hi all,
I've got some code crashing with Prelude.foldr1: empty list. In
GHCi, the code uses too much memory (I kill it after it consumes 1GB)
to be able to use :trace and :history, but I just found out about the
-xc RTS option. I tried that, and I get the following:
GHC.List.CAFdsat:
On 2008.02.26 23:13:59 -0500, Denis Bueno [EMAIL PROTECTED] scribbled 7.4K
characters:
Hi all,
I've got some code crashing with Prelude.foldr1: empty list. In
GHCi, the code uses too much memory (I kill it after it consumes 1GB)
to be able to use :trace and :history, but I just found out
Hi Denis,
I was unable to run your program; it looks like there's a missing
module 'Properties'. To include it in the sdist you probably need to
add it under the other-modules field in the .cabal file.
-Judah
2008/2/26 Denis Bueno [EMAIL PROTECTED]:
Hi all,
I've got some code crashing
The challenge was the implement the modcount algorithm not to calculate
primes per se.
(see e.g. http://jjinux.blogspot.com/2005/11/io-comparison.html).
-Alex-
Donald Bruce Stewart wrote:
alex:
This implementation of calculating 1 primes (compiled with GHC -O2)
is 25% slower than the
Thought perhaps the problem is that modcount is just a slower algorithm.
... nevermind. Thanks.
-Alex-
Alex Jacobson wrote:
The challenge was the implement the modcount algorithm not to calculate
primes per se.
(see e.g. http://jjinux.blogspot.com/2005/11/io-comparison.html).
-Alex-
Alex:
The challenge was the implement the modcount algorithm not to calculate
primes per se.
(see e.g. http://jjinux.blogspot.com/2005/11/io-comparison.html).
Can you show us the Python code?
Paulo
___
Haskell-Cafe mailing list
Why not just:
primes = sieve [2..]
sieve (p : xs) = p : sieve [x | x - xs, x `mod` p 0]
main = print (take 1000 primes)
I am unable to see how exactly this will run. Given that primes is an infinite
list, and that when it reaches numbers say, as large as
On 8/6/07, Vimal [EMAIL PROTECTED] wrote:
I am unable to see how exactly this will run. Given that primes is an infinite
list, and that when it reaches numbers say, as large as 1, it will have to
keep track of all the numbers (essentially prime numbers, which is the
answer),
whose
Isn't it how it runs ? :
2: sieve [3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,
47,49,... ]
then
2:3:sieve [5,7,11,13,17,19,23,25,29,31,35,37,41,43,47,49,... ]
then
2:3:5:sieve [7,11,13,17,19,23,29,31,37,41,43,47,49,... ]
then
2:3:5:7:sieve
primes n = sieve (take n [2..])
sieve (p:xs) = p : sieve [x | x - xs, x `mod` p 0]
print (primes 1000)
-- Vimal
But as we can see, this obviously doesn't *take* 1000 primes,
:-)
-- Vimal
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Vimal wrote:
Why not just:
primes = sieve [2..]
sieve (p : xs) = p : sieve [x | x - xs, x `mod` p 0]
main = print (take 1000 primes)
I am unable to see how exactly this will run. Given that primes is an infinite
list, and that when it reaches numbers say, as
Paulo Tanimoto wrote:
The challenge was the implement the modcount algorithm not to calculate
primes per se.
(see e.g. http://jjinux.blogspot.com/2005/11/io-comparison.html).
Can you show us the Python code?
Note this is python for the naive, accumulate and do modulus version.
Not for
It's been a while, but I believe that you can solve integer programming
problems of this type using Groebner bases.
(Google for integer programming with Groebner bases).
I have some Groebner basis code in Haskell at
http://www.polyomino.f2s.com/david/haskell/commalg.html
On Jun 6, 2007, at 11:38 PM, Daniel McAllansmith wrote:
[Trying to find the domain of a bounded integer linear program]
How would you go about finding extreme vertices? Would it be
quicker than
solving the constraints for each max/min?
If you're just looking to find bounding coordinates
On Wed, Jun 06, 2007 at 12:23:03PM +1200, Daniel McAllansmith wrote:
Hello.
I've got a system of linear inequalities representing half-spaces. The
half-spaces may or may not form a convex hull.
I need to find the integral coordinates that are contained within the convex
hull, if there
Do you simply want the set of coordinates, or do you want to do
something smart with the them (i.e. optimize a function value etc)?
In the first case, with a good starting point and a function that
enumerates all coordinates (by going in a spiral, perhaps), I think
this can be done in O(nm),
Daniel McAllansmith wrote:
Hello.
I've got a system of linear inequalities representing half-spaces. The
half-spaces may or may not form a convex hull.
They could only fail to define a convex volume if they are inconsistent and
define an empty set. Though they might define a convex volume
1 - 100 of 128 matches
Mail list logo