Regular Expression: exclude a word/string

If you want to exclude a certain word/string in a search pattern, a good way to do this is regular expression assertion function. It is indispensable if you want to match something not followed by something else. A Simple Example String str = "programcreek"; Pattern p = Pattern.compile(".*program(?=creek).*"); Matcher m = p.matcher(str);   if(m.matches()){ System.out.println("Match!"); … Read more

Lisp Code: Add two list

Can we have a function that can add two list to one, such as (add ‘(1 2 3) ‘(4 5 6)) = (5 7 9)

(defun add-two-list (l r)
; e.g. (1 2 3) (2 3 4)
; returns (3 5 7)
  (setf return-value '())
  (loop for i from 0 to (- (length l) 1)
        do (setf return-value (cons (+ (nth i l) (nth i r)) return-value))
)
 (reverse return-value)
)

Read more