new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
8
Task/Binary-search/PicoLisp/binary-search-1.l
Normal file
8
Task/Binary-search/PicoLisp/binary-search-1.l
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(de recursiveSearch (Val Lst Len)
|
||||
(unless (=0 Len)
|
||||
(let (N (inc (/ Len 2)) L (nth Lst N))
|
||||
(cond
|
||||
((= Val (car L)) Val)
|
||||
((> Val (car L))
|
||||
(recursiveSearch Val (cdr L) (- Len N)) )
|
||||
(T (recursiveSearch Val Lst (dec N))) ) ) ) )
|
||||
11
Task/Binary-search/PicoLisp/binary-search-2.l
Normal file
11
Task/Binary-search/PicoLisp/binary-search-2.l
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(de iterativeSearch (Val Lst Len)
|
||||
(use (N L)
|
||||
(loop
|
||||
(T (=0 Len))
|
||||
(setq
|
||||
N (inc (/ Len 2))
|
||||
L (nth Lst N) )
|
||||
(T (= Val (car L)) Val)
|
||||
(if (> Val (car L))
|
||||
(setq Lst (cdr L) Len (- Len N))
|
||||
(setq Len (dec N)) ) ) ) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue