Skip to content

Commit dc117b4

Browse files
committed
started to work with data structures
list
1 parent b4c021b commit dc117b4

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

ProgrammingForLinguistics.org

+107
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,109 @@ we can deal with an Array object using ( get ) method from Clojure
231231

232232
#+RESULTS:
233233
: bond
234+
* 7 - Data Structures
235+
** List
236+
- they grow at the head
237+
*** Creating lists
238+
239+
#+BEGIN_SRC clojure
240+
241+
(def ls (list "this" "is" "a" "list"))
242+
243+
244+
#+END_SRC
245+
246+
#+RESULTS:
247+
: #'user/ls("this" "is" "a" "list")
248+
*** getting elements of the list
249+
250+
#+BEGIN_SRC clojure
251+
252+
(peek ls)
253+
(first ls)
254+
(rest ls)
255+
(last ls)
256+
(peek ls)
257+
258+
#+END_SRC
259+
260+
#+RESULTS:
261+
: this
262+
263+
*** dropping n items
264+
265+
#+BEGIN_SRC clojure
266+
267+
(drop 3 ls)
268+
269+
#+END_SRC
270+
271+
#+RESULTS:
272+
| list |
273+
274+
*** finding elements in the list
275+
#+BEGIN_SRC clojure
276+
277+
(.indexOf "a" ls)
278+
279+
(.lastIndexOf "a" ls)
280+
281+
#+END_SRC
282+
283+
#+RESULTS:
284+
*** the empty list
285+
#+BEGIN_SRC clojure
286+
287+
(list? ())
288+
289+
#+END_SRC
290+
291+
#+RESULTS:
292+
: true
293+
294+
*** building up from empty lists
295+
- doesn't really matter if we quote it or not
296+
297+
#+BEGIN_SRC clojure
298+
299+
(cons 'a ())
300+
301+
#+END_SRC
302+
303+
#+RESULTS:
304+
| a |
305+
306+
*** general native functions for collections/sequences
307+
308+
#+BEGIN_SRC clojure
309+
310+
count
311+
empty
312+
not-empty
313+
into
314+
conj
315+
316+
distinct?
317+
every?
318+
empty?
319+
not-every?
320+
some
321+
not-any?
322+
323+
#+END_SRC
324+
325+
*** stuff from walk
326+
327+
#+BEGIN_SRC clojure
328+
329+
330+
#+END_SRC
331+
** Vector
332+
** Map
333+
** Set(def
334+
* 8 - Algorithms
335+
** Algorithms Unlocked
336+
***
234337
* LATER
235338
** More on Clojure and LISP as it's heritage
236339
** Introduction to the DSL
@@ -247,3 +350,7 @@ we can deal with an Array object using ( get ) method from Clojure
247350
** Our Understanding of a Language
248351
*** The depth of chunking a language we try out.
249352
*** Clarify that we abstract away from the Cultural Contexts in a language.
353+
** How to design programs
354+
** sicp
355+
** introduction to algorithms
356+
** Algorithms - cormen

0 commit comments

Comments
 (0)