no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


jui:cviko2 [2011/08/16 20:33] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== JUI - 2. cviceni ======
 +list neni case sensitive
 +logicke hodnoty
 +  * pro false je NIL
 +  * pro true je T
 +
 +pro zruseni vyhodnoceni vyrazu se pred to dava apostrof
 +<code lisp>
 +'(+ 1 2)  =>  (+ 1 2)
 +(+ 1 2)   =>  3
 +
 +
 +(if (test)
 +     (then_kod)
 +     (else_kod) 
 +
 +(defun vetsi (a b) 
 +  (if (> a b) a b)
 +
 +
 +(defun fact (a)
 +  (if (zerop a) 
 +     
 +     (* a (fact (1- a) ) )
 +  )
 +
 +</code>
 +
 +===== funkce pro seznamy =====
 +
 +<code lisp>
 +(list 'a 4)   - vytvari seznam
 +
 +car - vraci prvni prvek
 +(car (list 1 2 3))
 +(car '(list 1 2 3))
 +  
 +cdr - vraci seznam bez prvniho prvku
 +  
 +last - posledni prvek
 +append - spoji dva seznamy do jednoho
 +
 +(defun nodeat (s i)  //vraci i-ty prvek seznamu s
 +  (if (= i 1) 
 +     (car s) 
 +     (nodeat (cdr s) (1- i))
 +  )
 +)
 +
 +(defun ctvrty (l) 
 +  (nodeat l 4)
 +)
 +</code>
  
jui/cviko2.txt · Last modified: 2011/08/16 20:33 by 127.0.0.1
Back to top
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0