{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

chapter2

# chapter2 - PROGRAMMING IN HASKELL Chapter2FirstSteps 1 The...

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

1 PROGRAMMING IN HASKELL Chapter 2 - First Steps

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

View Full Document
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
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 :

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

View Full Document
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
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

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

View Full Document
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]
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern