Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Relationship between graphs and queues? (Christopher Howard)
   2.  QuickCheck with monadic IO (Hartmut)
   3. Re:  Relationship between graphs and queues? (KC)


----------------------------------------------------------------------

Message: 1
Date: Fri, 12 Aug 2011 12:32:50 -0800
From: Christopher Howard <[email protected]>
Subject: [Haskell-beginners] Relationship between graphs and queues?
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I working through the practice problems in Davie's book (by myself) and 
there is one that is not quite clear to me:

"Construct an abstract data type for a queue. Attempt to supply an 
implementation (hidden from the user of the type) which allows access to 
the head of the queue and the construction of a new queue by adding 
elements to the end of an existing one. Both these interface functions 
should operate in time independent of the length of the queue. What 
implications does the this exercise suggest for search and 'updating' 
(by copying all unchanged nodes) a general graph?"

There are two parts to the problem here: 1) defining the data type and 
the interface functions, and 2) indicating the implications for general 
graphs. On the first part I'm a little unclear because I am not sure 
what he means by "allows access to the head of the queue"; i.e., does he 
mean to just get the value in the head of the queue, or pop the value 
off the head of the queue and return the new queue? If the former, a 
solution is not hard, but if the latter, then I am not sure how to solve 
this without somehow transversing the queue, which of course is not a 
time-independent activity. (Even in the implementation for a queue in 
the Data.Graph.Inductive.Internal.Queue, eventually a "reverse" call 
must be made.)

Anyway, maybe if someone could explain the relationship between this 
problem and graphs, I'll see the bigger picture and have a clearer view 
of the problem.

-- 
frigidcode.com
theologia.indicium.us



------------------------------

Message: 2
Date: Fri, 12 Aug 2011 23:31:58 +0200
From: Hartmut <[email protected]>
Subject: [Haskell-beginners] QuickCheck with monadic IO
To: [email protected]
Message-ID:
        <CAFz=tHEd95oOakaWJvkdmX_Vg=yny1wkyvzleqzd4rwcpd6...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Everyone,

I want to run an QuickCheck on "a most simple" IO monad.
When I compile and run :main, it says:
....................................................................................................+++
OK, passed 100 tests.
Well, thats fine, since *1 mapped on any Int gives the same Int back.
But it lasts 10 seconds (!) for doing those 100 Tests.
Something must be wrong?!
I'd appreciate your ideas.

Hartmut


module MonadicQuickCheck where

import IO
import Random
import Test.QuickCheck
import Test.QuickCheck.Monadic

main = do
  quickCheck x

x :: Property
x = monadicIO $ do
  a <- pick arbitrary
  pre $ not(null a)
  b <- run $ testfunction a
  assert $ b == a

testfunction :: [Int] -> IO [Int]
testfunction x = do
  putStr "."
  return $ map (*1) x
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110812/ecbc2db5/attachment-0001.htm>

------------------------------

Message: 3
Date: Fri, 12 Aug 2011 15:38:29 -0700
From: KC <[email protected]>
Subject: Re: [Haskell-beginners] Relationship between graphs and
        queues?
To: Christopher Howard <[email protected]>,
        [email protected]
Message-ID:
        <CAMLKXy=L6OcBni=xo1_oheqmac8jhoqxxuem8_zegyyzk5c...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Depth First Search uses a stack (implicit or explicit) and Breadth
First Search uses a queue.


-- 
--
Regards,
KC



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 38, Issue 28
*****************************************

Reply via email to