Skip to content

Instantly share code, notes, and snippets.

@abhilater
abhilater / n-primes.clj
Created May 18, 2017 14:25
Written a Clojure lazy-seq function to generate n prime numbers. It generates .5 million prime numbers in 20 secs
;; Clojure lazy-seq function to generate n prime numbers.
;; It generates .5 million prime numbers in 20 secs using
;; the naive non-sieve algo
;; Author: Abhishek Gupta (@abhilater)
(defn n-primes
[]
(filter (fn [num]
(loop [end (int (Math/sqrt num)), div 2, re (rem num div)]
(cond
@abhilater
abhilater / caesar-cipher-transducer.clj
Last active May 17, 2017 15:22
Caesar cipher's implementation using Clojure Transducer
;; The Caesar Cipher implementation using Clojure Transducers
;; Author: Abhishek Gupta
;The Caesar Cipher
;Given a string, use transducers to:
;
;Filter out vowels and non-ASCII characters
;Filter out upper-case characters
;Rotate all remaining characters via a Caesar cipher,
;And reduce the rotated characters into a map counting the number of occurrences of each character.
@ghoseb
ghoseb / ns-cheatsheet.clj
Last active April 11, 2024 05:28 — forked from alandipert/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.