@@ -0,0 +1,108 @@
#| (defunc max-ident-sublist (l)
:input-contract (listp l)
:output-contract (natp (max-ident-sublist l))
(if (endp l)
nil
(let ((maxRest (max-ident-sublist blah))
(maxTser (max-ident-sublist blah2)))
(if (> maxRest maxTser)
maxRest
maxTser))))
|#
;; count occurrence of n in l
;; for now this is going to return mode of list
(defunc occur (l n)
:input-contract (listp l)
:output-contract (natp (occur l n))
(if (endp l)
0
(if (equal (first l) n)
(+ 1(occur (rest l) n))
(occur (rest l) n))))
#|
;;max in list
(defunc maxlist (l)
:input-contract (listp l)
:output-contract (natp (maxList l))
(if (endp l)
0
(if (let (a (first l)) (b (first (rest l)))
(if (a > b)
|#
(defunc delAll (a l)
:input-contract (listp l)
:output-contract (listp (delAll a l))
(cond ((endp l) nil)
((equal a (first l)) (delAll a (rest l)))
(t (cons (first l) (delAll a (rest l))))))
#|
(defunc alet (n)
:input-contract (natp n)
:output-contract (natp (alet n))
(let ((a (+ n 1)) (b (+ n 2)))
a))
;; create list of occurences of elements in list
(defunc occurList (l)
:input-contract (listp l)
:output-contract (listp (occurList l))
(if (endp l)
nil
(if (equal (remove-dups l) nil)
nil
(cons (occur l (first (remove-dups l))) (occurList (rest l))))))
####
(let ((noDeps (remove-dups l)) (cleanList (del (first (remove-dups l)) l)))
|#
(defunc occurList (l)
:input-contract (listp l)
:output-contract (listp (occurList l))
(if (endp l)
nil
(if (equal (delAll (first l) l) nil)
nil
(cons (occur l (first l)) (occurList (delAll (first l) l))))))
(defunc ocList (l l1)
:input-contract (and (listp l) (listp l1))
:output-contract (listp (ocList l l1))
(if (or (endp l) (endp l1))
nil
(cons (occur l (first l1)) (ocList l (rest l1)))))
(defunc ocList2 (l)
:input-contract (listp l)
:output-contract (listp (ocList2 l))
(if (endp l)
nil
(ocList l (remove-dups l))))
(defunc max (a b)
:input-contract (and (natp a) (natp b))
:output-contract (natp (max a b))
(if (< a b) b a))
(defdata rationallist (listof rational))
(defdata natlist (listof nat))
(defunc maxList (l)
:input-contract (natlistp l)
:output-contract (natp (maxList l))
(if (or (endp l) (equal (rest l) nil))
0
(if (< (first l) (first (rest l)))
(maxList (rest l))
(first l))))
(defunc max-ident-list (l)
:input-contract (listp l)
:output-contract (natp (max-ident-list l))
(maxList (ocList2 l)))