-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.hs
More file actions
207 lines (112 loc) · 2.47 KB
/
Copy pathprocess.hs
File metadata and controls
207 lines (112 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import System.Process
readProcess "seq" ["1", "10"] ""
:{
let isPlus x
| x == '+' = True
| otherwise = False
:}
:{
let isSpacs x
| x == ' ' = True
| otherwise = False
:}
isSpacs ' '
map isSpacs "asdk j dkfjf j"
-- need to count which position you're at
--
head [3]
:t tokenizeSpaces
:{
let tokenizeSpaces [] [y] a = y:a
tokenizeSpaces (s:ss) (x:xs) a
| s /= ' ' = tokenizeSpaces ss ((s:x):xs) a
| otherwise = tokenizeSpaces ss xs (x:a)
:}
let s2 = "asdkjf jdfkfjdkdjd jdjj jd"
-- ahhh cs is improperly defined
cs s2
tokenizeSpaces s2 (nXs 0 []) []
tokenizeSpaces "asdf" (nXs 0 []) []
nXs 0 []
:{
let tk s = tokenizeSpaces s (nXs asdf []) []
where asdf = cs s
:}
nXs (cs s2) []
tk s2
cs s2
:t cs
:{
let ts string = tokenizeSpaces string emptys []
where emptys = nXs spaces []
spaces = countSpaces string
countSpaces = length . filter (isSpacs ' ')
:}
:{
let ts str = tokenizeSpaces str (nXs (cs str) []) []
:}
ts "askjdf jfjdjk askdj"
-- here's the final fcn
reverse $ map reverse $ ts "askjdf jfjdjk askdj"
:{
let listTil c [] = []
listTil c (x:xs)
| x /= c = x : listTil c xs
| otherwise = []
:}
listTil ' ' "asdjf asdf"
listTil ' ' "asdf"
:{
let listTil c [] = []
listTil c (x:xs)
| x /= c = x : listTil c xs
| otherwise = []
:}
:{
let listAfterC c [] = []
listAfterC c (x:xs)
| x == c = xs
| otherwise = listAfterC c xs
:}
listAfterC ' ' "asdjf asdf"
listAfterC ' ' "asdf"
listAfterC ' ' ""
:{
let reltc c [] = []
reltc c xs = listTil c xs : reltc c (listFromC c xs)
:}
reltc ' ' "asjkd jfdjkfjd jd jddks"
splitL :: Int -> [x] -> [[x],[x]]
splitL 0 xs b = head b : (xs : tail b)
splitL n (x:xs) b = splitL (n-1) xs (consHead x b)
-- note the first half of the list gets reversed
:{
let splitL 0 xs b = head b : (xs : tail b)
splitL n (x:xs) b = splitL (n-1) xs (consHead x b)
:}
splitL 4 [1..10] [[]]
let consHead x b = (x : head b) : (tail b)
consHead 3 [[],[]]
[3] : [[]]
let s1 = "askjdf jfjdjk askdj"
cs s1
nXs (cs s1) []
cs
cs "asdf ddsa d sfsd 3k"
let cs = (+1) . length . filter (isSpacs ' ')
length $ filter (isSpacs ' ') "asd dfj d"
:{
let isSpacs c x
| x == c = True
| otherwise = False
:}
:{
let nXs 0 x = []
nXs n x = x : nXs (n-1) x
:}
nXs 3 4
tokenizeSpaces "askdj jfjkd j dkk" [[],[],[],[]] []
parseStringforPlus
map isPlus "+*/-"
[1,2,3] == "123"
[1,2,3] == [1,2,3]