

Line 22: 
Line 22: 
 </source>   </source> 
   
−  The main problem of emacs lisp here is ineded the lack of bignums.In this circumstances, a smart solution is only valid up to list lengths of 13 or 19.We could try to use rationals to compute f/p instead, but we couldn't guarantee to stay within fixnum for numerators and denominators on all inputs (it would depend on the order of the numbers and their decomposition in prime factors).;; Notice: the following missingandduplicateintegers functions;; still use O(log N) space, hidden in the factorial and product;; bignums (for lists of length>13 (32bit) or length>19 (64bit)).(defun factorial (n) (loop for i from n downto 1 for p = i then (* p i) finally (return p)))(defun missingandduplicateintegers (lopi) " 2. Given a list of integers from 1 to n but with one of the integers missing and another integer repeated, write an efficient algorithm for finding the missing and repeated integers. The numbers in the list are in no particular order.Return: a list (missing duplicate)" ;; We won't count checking the precondition in the time or space complexity: (assert (every (lambda (i) (and (<= 1 i) (<= i (length lopi)))) lopi)) (assert (= (1 (length lopi)) (length (removeduplicates lopi)))) (let* ((n (length lopi)) (s (reduce '+ lopi)) (p (reduce '* lopi)) (f (factorial n)) (a (/ (* n (1+ n)) 2))) (list (/ (* ( a s) f) ( f p)) (/ (* ( a s) p) ( f p)))))(defun missingandduplicateintegers (lopi) " 2. Given a list of integers from 1 to n but with one of the integers missing and another integer repeated, write an efficient algorithm for finding the missing and repeated integers. The numbers in the list are in no particular order.Return: a list (missing duplicate)" (assert (every (lambda (i) (and (<= 1 i) (<= i (length lopi)))) lopi)) (assert (= (1 (length lopi)) (length (removeduplicates lopi)))) (loop for i from 1 for e in lopi for a = i then (+ a i) for f = i then (* f i) for s = e then (+ s e) for p = e then (* p e) finally (return (list (/ (* ( a s) f) ( f p)) (/ (* ( a s) p) ( f p))))))(list (missingandduplicateintegers '(1 2 3 3 4 5 7 8)) (missingandduplicateintegers '(1 1 2 3 4 5 6 7)) (missingandduplicateintegers '(2 3 4 5 6 7 8 8)))((6 3) (8 1) (1 8))
 +  == Emacs 24 == 
 +  
 +  <source lang="lisp"> 
 +  (addtolist 'customthemeloadpath "~/.emacs.d/themes/") 
 +  (loadtheme 'zenburn t) 
 +  </source> 
   
 = See Also =   = See Also = 
Latest revision as of 02:17, 8 August 2012
Zenburn for Emacs is a direct port of the popular Zenburn theme for vim, developed by Jani Nurminen.
The theme has two versions  one for Emacs 23, relying on the colortheme package and another for Emacs 24 using the builtin theming support there.
Basic setup
Emacs 23
(require 'colorthemezenburn)
(colorthemezenburn)
Emacs 24
(addtolist 'customthemeloadpath "~/.emacs.d/themes/")
(loadtheme 'zenburn t)
See Also
Project Pages