Skip to content
View comment-prints.el
(defun s-trim-left (s)
"Remove whitespace at the beginning of S."
(if (string-match "\\`[ \t\n\r]+" s)
(replace-match "" t t s)
s))
(defun first-word (s)
(let ((s-trim (s-trim-left s)))
(car (split-string s-trim " "))))
View selmer templates
;;clojure-code
(:require [compojure.core :refer :all]
[trads.layout :as layout]
[trads.util :as util]
[monger.core :as mg]
[selmer.filters :as selm])
(selm/add-filter! :get-name #((first %) (second %)))
View changing delete in emacs
(defun get-back-char ()
(buffer-substring-no-properties (- (point) 6) (point)))
(defun del-backward ()
(interactive)
(let ((text-back (get-back-char)))
(do
(message "test")
(if (string= text-back "lambda")
(delete-backward-char 6)
View derivatives.lisp
(defparameter *maths-functions* (list))
(defmacro defun-maths (func-name args core)
"appends the code of func-name into maths-functions."
`(progn
(push (list :name (quote ,func-name) :variable (quote ,args) :core (quote ,core)) *maths-functions*)
(defun ,func-name ,args ,core)))
(defun get-source (func-name)
(car (remove-if-not (lambda (f) (eql (getf f :name) func-name)) *maths-functions*
View derivator-first-class.lisp
(defparameter *maths-functions* (list))
(defmacro defun-maths (func-name args core)
"appends the code of func-name into maths-functions."
`(progn
(push (list (quote ,func-name) (quote ,@args) (quote ,core)) *maths-functions*)
(defun ,func-name ,args ,core)))
View save-source.lisp
(defparameter *maths-functions* (list))
(defmacro defun-maths (func-name args core)
"appends the code of func-name into maths-functions."
`(progn
(push (list (quote ,func-name) (quote ,@args) (quote ,core)) *maths-functions*)
(defun ,func-name ,args ,core)))
View eq-assoc++.lisp
(defun eq-assoc (assoc-a assoc-b)
(and (equal (length assoc-a) (length assoc-b))
(reduce (lambda (accum pair)
(and accum
(equal pair (assoc (car pair) assoc-b))))
assoc-a
:initial-value t)))
(defun group (list)
(let ((even t))
View newton-raphson.clj
(ns newton-raphson.core)
;;utility function for list manipulation
(defn keep-list [expr]
(if (and (coll? expr) (not (= 1 (count expr)))) (list expr) expr))
(defn to-list [expr]
(cond (list? expr) expr
(coll? expr) (seq expr)
View gist:1163944
(fn [x n]
(loop [res (), k 0]
(cond (>= k n) (if (list? x) res (reverse res))
:else (recur (conj res (filter #(= k (mod % n)) x)) (inc k)))))
View gist:1148056
(defn is-palindrome [x]
(= x (Integer/parseInt (apply str (reverse (str x)))))
)
(defn problem4 []
;Find the largest palindrome made from the product of two 3-digit numbers.
(def max-palindrome 0)
(doseq [i (range 999)]
(doseq [j (range i)]
(do
Something went wrong with that request. Please try again.