-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Seungcheol Jung
committed
Mar 11, 2010
1 parent
19cfcf7
commit 91fca9f
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
\chapter{\Large{First Steps}} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
\exercise{2.1} | ||
|
||
\begin{lstlisting}[language=Haskell,escapeinside=~~] | ||
(2 ^ 3) * 4 | ||
(2 * 3) + (4 * 5) | ||
2 + (3 * (4 ^ 5)) | ||
\end{lstlisting} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
\exercise{2.2} | ||
|
||
(생략) | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
\exercise{2.3} | ||
|
||
주어진 스크립트에는 다음 세가지 문제점이 있다. | ||
\begin{itemize} | ||
\item 함수 이름이 소문자로 시작되지 않는다. | ||
\item 함수를 인자 사이에서 쓰려면 따옴표(\texttt{'})가 아닌 | ||
역따옴표(\texttt{`})로 묶어야 한다. | ||
\item \texttt{where} 다음에 오는 문장의 들여쓰기가 일치하지 않는다. | ||
\end{itemize} | ||
|
||
수정된 스크립트는 다음과 같다. | ||
|
||
\haskell{./src/ch02-ex03.hs} | ||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
\exercise{2.4} | ||
|
||
\haskell{./src/ch02-ex04.hs} | ||
|
||
|
||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
\exercise{2.5} | ||
|
||
\haskell{./src/ch02-ex05.hs} | ||
|
||
|
||
%%% Local Variables: | ||
%%% mode: latex | ||
%%% TeX-master: "master" | ||
%%% End: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ | |
\maketitle | ||
\tableofcontents | ||
\input{ch01} | ||
\input{ch02} | ||
|
||
\end{document} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
n = a `div` length xs | ||
where | ||
a = 10 | ||
xs = [1,2,3,4,5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
last1 :: [a] -> a | ||
last1 xs = head (reverse xs) | ||
|
||
last2 :: [a] -> a | ||
last2 xs = xs !! (length xs - 1) | ||
|
||
last3 :: [a] -> a | ||
last3 xs = head (drop (length xs - 1) xs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
init1 :: [a] -> [a] | ||
init1 xs = reverse (tail (reverse xs)) | ||
|
||
init2 :: [a] -> [a] | ||
init2 xs = take (length xs - 1) xs |