Zenburn-theme

From WikEmacs
Jump to navigation Jump to search

Zenburn for Emacs is a direct port of the popular Zenburn theme for vim, developed by Jani Nurminen.

Zenburn theme
Description The Zenburn theme, ported to Emacs
Author Jami Nurminen
Maintainer Bozhidar Batsov
Source https://github.com/bbatsov/zenburn-emacs

The theme has two versions - one for Emacs 23, relying on the color-theme package and another for Emacs 24 using the built-in theming support there.

Zenburn

Basic setup

Emacs 23

(require 'color-theme-zenburn)
(color-theme-zenburn)

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 missing-and-duplicate-integers functions;; still use O(log N) space, hidden in the factorial and product;; bignums (for lists of length>13 (32-bit) or length>19 (64-bit)).(defun factorial (n) (loop for i from n downto 1 for p = i then (* p i) finally (return p)))(defun missing-and-duplicate-integers (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 pre-condition in the time or space complexity: (assert (every (lambda (i) (and (<= 1 i) (<= i (length lopi)))) lopi)) (assert (= (1- (length lopi)) (length (remove-duplicates 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 missing-and-duplicate-integers (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 (remove-duplicates 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 (missing-and-duplicate-integers '(1 2 3 3 4 5 7 8)) (missing-and-duplicate-integers '(1 1 2 3 4 5 6 7)) (missing-and-duplicate-integers '(2 3 4 5 6 7 8 8)))((6 3) (8 1) (1 8))

See Also

Project Pages