aboutsummaryrefslogtreecommitdiff
path: root/Semestr 3/pf/lista13/BF.he
diff options
context:
space:
mode:
authorFranciszek Malinka <franciszek.malinka@gmail.com>2021-10-05 21:49:54 +0200
committerFranciszek Malinka <franciszek.malinka@gmail.com>2021-10-05 21:49:54 +0200
commitc5fcf7179a83ef65c86c6a4a390029149e518649 (patch)
treed29ffc5b86a0d257453cedcf87d91a13d8bf3b0d /Semestr 3/pf/lista13/BF.he
parentf8a88b6a4aba1f66d04711a9330eaba49a50c463 (diff)
Duzy commit ze smieciami
Diffstat (limited to 'Semestr 3/pf/lista13/BF.he')
-rw-r--r--Semestr 3/pf/lista13/BF.he57
1 files changed, 0 insertions, 57 deletions
diff --git a/Semestr 3/pf/lista13/BF.he b/Semestr 3/pf/lista13/BF.he
deleted file mode 100644
index cf33e4f..0000000
--- a/Semestr 3/pf/lista13/BF.he
+++ /dev/null
@@ -1,57 +0,0 @@
-effect Reader X =
- { ask : Unit => Option X
- }
-
-let hReadString str c =
- handle c () with
- | ask () => fn pos =>
- if pos >= String.length str then
- resume None pos
- else
- resume (Some (String.get pos str)) (pos+1)
- | return x => fn _ => x
- end 0
-
-data rec BF =
-| MoveR
-| MoveL
-| Inc
-| Dec
-| Output
-| Input
-| While of List BF
-
-let parse str =
- let rec parse () =
- match ask () with
- | None => []
- | Some c =>
- if Char.equal c '>' then MoveR :: parse ()
- elif Char.equal c '<' then MoveL :: parse ()
- elif Char.equal c '+' then Inc :: parse ()
- elif Char.equal c '-' then Dec :: parse ()
- elif Char.equal c '.' then Output :: parse ()
- elif Char.equal c ',' then Input :: parse ()
- elif Char.equal c '[' then
- begin let body = parse () in
- While body :: parse ()
- end
- elif Char.equal c ']' then []
- else parse ()
- end
- in
- handle parse () with hReadString str
-
-(** Odczytanie pojedynczego znaku ze standardowego wejścia *)
-let tryReadChar () =
- let str = input stdin 1 in
- if String.length str = 1 then
- Some (String.get 0 str)
- else None
-
-(** Wypisanie pojedynczego znaku na standardowe wyjście *)
-let printChar c =
- outputString stdout (String.repeat 1 c)
-
-(* Do konwersji pomiędzy typami Char i Int możesz użyć funkcji
-* Char.chr oraz Char.code *) \ No newline at end of file