You may want to use a mutable array.
>The performance may suffer from the memory allocation for the list. I
>wonder if it's possible to make Haskell implementation work faster
>without changing the algorithm (there's are actually a few tricks to
>make it work faster, but neither implementations ha
Job Vranish wrote:
> Its main advantages are:
> Very easy to use.
> Almost entirely Haskell98 (the non Haskell98 pieces are not critical, just
> nice)
> The datatype is a member of Foldable, Traverable, Applicative, Monad,
> etc...
> Then length of the list is encoded in the type in a natural
Hello. I have written 2 implementation of bubble sort algorithm in C
and Haskell. Haskell implementation:
module Main where
main = do
contents <- readFile "./data"
print "Data loaded. Sorting.."
let newcontents = bubblesort contents
writeFile "./data_new_ghc" newcontents
print
newStdGen results in IO Ints whereas i need normal Ints and it seems theres
no easy way to convert them without a lot more knowledge of haskell. I have
tried using a where clause instead of using do but this is giving me the
occurs check error again!
--function used to shuffle cards
--list equal
I uploaded a new fixed length list library to hackage:
http://hackage.haskell.org/package/fixed-list
Its main advantages are:
Very easy to use.
Almost entirely Haskell98 (the non Haskell98 pieces are not critical, just
nice)
The datatype is a member of Foldable, Traverable, Applicative, M
love_pku wrote:
> It is true that I have asked about the installation of Haskell on
> the beginners list. But the problems appeared one after another. I
> just felt very sorry to trouble other peopel again and again.
Its still better to keep it in one place so that people can see the
thread of
As a beginner, i cannot understand completely what both Maciej Piechotka and
Daniel Fischer-4 said. However, i think it will be a big step for me to
study haskell once i understand it.
thanks !
zaxis wrote:
>
>>let f x xs = [x:xs,xs]
>> :t f
> f :: a -> [a] -> [[a]]
>
>>:t (>>=) .f
> (>>=)
yes, i am a haskell-beginners. However, i still feel haskell-cafe is a good
place for me to learn haskell !
If the question is too simple for you to answer, then you can just ignore it
. I believe somebody else can still supply help even if without you.
Ivan Lazar Miljenovic wrote:
>
> Hein
Thank you for response!
It is true that I have asked about the installation of Haskell on the
beginners list. But the problems appeared one after another. I just felt very
sorry to trouble other peopel again and again.Thus ,I begin to wonder if I am
too stupid or the installation of Haskell
Hello Daniel,
Regarding your solution, can I apply {-# SPECIALISE ... #-} statements to
datatypes I define?
And if so, I am not able to import the datatypes to the module where
binarySearch is.
The problem is that if I import them a circular dependency is detected and
the compiler gives an error.
boblettoj writes:
> I was using a do loop to try and create a generator before using it in the
> randomR call, is there a better way to do this?
Use newStdGen in IO, then pass it around everywhere.
> randoms and randomRs return lists whereas i just want a single number.
> thanks
OK, I though
I was using a do loop to try and create a generator before using it in the
randomR call, is there a better way to do this? randoms and randomRs return
lists whereas i just want a single number.
thanks
--
View this message in context:
http://old.nabble.com/Occurs-check-error%2C-help%21-tp27966341
boblettoj writes:
> Yes sorry, that line should be indented, now it gives me a bigger error :(
> What that line is trying to achieve is return a list where the first element
> is the card at the given random number in the first list and the rest of the
> list should be fed back in to shuffle alon
Yes sorry, that line should be indented, now it gives me a bigger error :(
What that line is trying to achieve is return a list where the first element
is the card at the given random number in the first list and the rest of the
list should be fed back in to shuffle along with a new random number.
boblettoj writes:
> shuffle i cards = do
> gen <- mkStdGen 10
> return ([(cards!!i) : (shuffle (randomR (0, ((length cards)-2)) gen)
> (delete (cards!!i) cards))])
Thta last line doesn't make sense; should it be on the line above?
--
Ivan Lazar Miljenovic
ivan.miljeno...@gmai
Oh yeh, how silly.
How do i create a generator to use in that function call then?
i've tried using a do like this:
shuffle i cards = do
gen <- mkStdGen 10
return ([(cards!!i) : (shuffle (randomR (0, ((length cards)-2)) gen)
(delete (cards!!i) cards))])
but that gives me
2010/3/20 boblettoj :
>
> Ah yes, that makes sense now, however i have another problem, here is the
> updated code:
>
> --function used to shuffle cards
> --list equals random member of array plus the rest of the array
> --i is randomly generated from range of length equal to that of cards.
> shuff
Ah yes, that makes sense now, however i have another problem, here is the
updated code:
--function used to shuffle cards
--list equals random member of array plus the rest of the array
--i is randomly generated from range of length equal to that of cards.
shuffle :: Int -> [a] -> [a]
shuffle i [
Hi,
> shuffle :: int -> [a] -> [a]
> shuffle i [cards] = ...
So 'cards' is of type 'a' :
cards :: a
> ... = (cards!!i)
So 'cards' is a list of something:
cards :: [b]
> ... = (cards!!i) + ...
(+) :: b -> b -> b,
the result of the 'shuffle' should be of type [a], so
b :: [a],
cards :: [[a
We are gauging interest in another Haskell hackathon to be hosted at U
Penn in May, the weekend of either May 15 or May 22. If you might be
interested in attending such a thing, send me an email (please DON'T
reply to all!) with your name and whether you have a strong preference
for one or the oth
Hi i am writing a shuffle function which takes in a random number i and a
list and then produces a jumbled up version of the list at the end. Here is
what i have at the moment (i'm not sure if it works yet as it won't compile!
--function used to shuffle cards
--list equals random member of array
On Sat, Mar 20, 2010 at 3:32 AM, Vasyl Pasternak
wrote:
> Hi Cafe,
>
> I have another problem, please look at code:
>
> storeInDb = withSession (connect "test.db")
> (do
> execDDL (sql "create table x (y int)")
> forM_ ([1..1] :: [Int])
>
On Fri, Mar 19, 2010 at 5:49 PM, vlado wrote:
> +1 - I like it, I've used this technique in some private projects
Nice, I hope you can use this package.
> I wonder if this would be a place to add a function returning the pair
> of the read and write capabilities (for the lack of a better word) o
Hi Cafe,
I have another problem, please look at code:
storeInDb = withSession (connect "test.db")
(do
execDDL (sql "create table x (y int)")
forM_ ([1..1] :: [Int])
(\x -> do
execDML (cmdbind ("insert int
>From ZuriHac, we bring you...
*Call for Praatjes: Dutch HUG Day*
To celebrate our first anniversary, the Dutch Haskell Users Group (HUG)
invites Haskell and functional programming enthusiasts in the Netherlands
and surrounding area to a short symposium. The Dutch HUG is an informal
group with mo
Hi, seems, that I found how to solve it. I replased `mtl` dependency
with `transformers` and `monads-fd` and everything works fine.
BTW. Iteratee and Takusen didn't want to work because of different
instances of MonadIO (Iteratee needs MonadIO from transformers
package, but Takusen implements Mona
26 matches
Mail list logo