{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

chapter2 - PROGRAMMING IN HASKELL Chapter2FirstSteps 1 The...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 PROGRAMMING IN HASKELL Chapter 2 - First Steps
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 The Hugs System Hugs is an implementation of Haskell 98, and is  the most widely used Haskell system; The interactive nature of Hugs makes it well  suited for teaching and prototyping purposes; Hugs is available on the web from: www.haskell.org/hugs
Image of page 2
3 Starting Hugs % hugs __   __ __  __  ____   ___      _________________________________________ ||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard ||___|| ||__|| ||__||  __||     Copyright (c) 1994-2005 ||---||         ___||           World Wide Web: http://haskell.org/hugs ||   ||                         Report bugs to: [email protected] ||   ||                         _________________________________________ > On a Unix system, Hugs can be started from the %  prompt by simply typing hugs :
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 The Hugs > prompt means that the Hugs system  is ready to evaluate an expression. For example: > 2+3*4 14 > (2+3)*4 20 > sqrt (3^2 + 4^2) 5.0
Image of page 4
5 The Standard Prelude The library file Prelude.hs  provides a large number  of standard functions.  In addition to the familiar  numeric functions such as + and *, the library also  provides many useful functions on lists . Select the first element of a list: > head [1,2,3,4,5] 1
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
6 Remove the first element from a list: > tail [1,2,3,4,5] [2,3,4,5] Select the nth element of a list: > [1,2,3,4,5] !! 2 3 Select the first n elements of a list: > take 3 [1,2,3,4,5] [1,2,3]
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern