Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5dfbf91

Browse files
committed
01/1 - Idris
1 parent0c38dd3 commit5dfbf91

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎2018/01_1/idris/appositum.idr‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Data.String
2+
3+
subtract:Neg a=> a-> a-> a
4+
subtract x y= y- x
5+
6+
parse:List Char-> Integer-> Integer
7+
parse (x::xs)=
8+
case parseInteger (pack xs)of
9+
Nothing=>id
10+
Just num=>
11+
case xof
12+
'+'=> (+num)
13+
'-'=> subtract num
14+
15+
loop: Integer->List (List Char)-> Integer
16+
loop acc lst=foldl (\x, f=> f x) acc (map parse lst)
17+
18+
main:IO()
19+
main=do
20+
args<- getArgs
21+
case argsof
22+
(_::arg::_)=>do
23+
file<-readFile arg
24+
case fileof
25+
Right res=>print$ loop0$map unpack (lines res)
26+
Left_=>putStrLn"File not found"
27+
_=>putStrLn"Usage: ./appositum input.txt"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp