Loading ...
Sorry, an error occurred while loading the content.

Re: [extremeperl] Book: Higher Order Perl

Expand Messages
  • Terrence Brannon
    ... Here s a working example. My earlier example was borked. mydat = [1 .. 4] trans1 x = [x] trans2 x = [x, x +1] trans3 x = [x +5] trans4 :: Integer - [Char]
    Message 1 of 58 , Mar 29, 2005
    • 0 Attachment
      Terrence Brannon <bauhaus@...> writes:


      > And a monad ...
      >
      > Example:

      Here's a working example. My earlier example was borked.

      mydat = [1 .. 4]

      trans1 x = [x]
      trans2 x = [x, x +1]
      trans3 x = [x +5]

      trans4 :: Integer -> [Char]
      trans4 x = replicate (fromIntegral x) 'a' ++ [':']

      *Main> mydat >>= trans1
      [1,2,3,4]
      *Main> (>>=) mydat trans1
      [1,2,3,4]
      *Main> mydat >>= trans2
      [1,2,2,3,3,4,4,5]
      *Main> mydat >>= trans3
      [6,7,8,9]
      *Main> mydat >>= trans4
      "a:aa:aaa:aaaa:"
      *Main> mydat >>= trans1 >>= trans2 >>= trans3
      [6,7,7,8,8,9,9,10]
      *Main> mydat >>= trans1 >>= trans2 >>= trans3 >>= trans4
      "aaaaaa:aaaaaaa:aaaaaaa:aaaaaaaa:aaaaaaaa:aaaaaaaaa:aaaaaaaaa:aaaaaaaaaa:"
      *Main>

      --
      Carter's Compass: I know I'm on the right track when,
      by deleting something, I'm adding functionality.
    • Tom Vilot
      ... Wait. That sounds like Rob .... ;c) (kidding) ... Wait. That *also* sounds like Rob ... ... (not kidding!)
      Message 58 of 58 , Apr 8, 2005
      • 0 Attachment
        Greg C wrote:

        >
        >
        > Consider: projects A and B have identical goals. In project A, you
        > have free
        > rein in your choice of software and hardware tools. However, the
        > manager sets
        > arbitrary deadlines, likes to stand behind people and criticize their
        > code as
        > they type,


        Wait. That sounds like Rob ....
        ;c) (kidding)

        > On project B, the choice of langauge and hardware are made for you and
        > there's
        > only one computer per two programmers. On the other hand, the manager
        > sees his
        > people as people, negotiates requirements and schedules on a realistic
        > basis,
        > trusts his people, follows a set of best practices (be it XP or some
        > other) and
        > chases everyone out of the office at 5:30.


        Wait. That *also* sounds like Rob ...

        :c)

        (not kidding!)
      Your message has been successfully submitted and would be delivered to recipients shortly.