This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Незаконченная басня о воробьях. | |
Стояла пора гнездованья, но после долгих дней, полных тяжелой работы, воробьи сидели в вечерних лучах, расслабляясь и чирикая о том о сём. | |
„Мы такие маленькие и слабые. Представить себе только, как легка была бы наша жизнь, если бы у нас была сова, которая помогала бы нам вить наши гнёзда!“ | |
„Верно!“, говорит другой, „Она бы могла нам ещё и помочь ухаживать за стариками и птенцами.“ | |
„Она могла давать нам советы; могла бы приглядывать за соседской кошкой,“ добавил третий. | |
И тогда Пастус, старейшина, сказал: „давайте же пошлем разведчиков во все стороны света, пусть они поищут брошенного совёнка или совиное яйцо. Воронёнок тоже сойдет, или даже детёныш ласки. Это может стать лучшим событием в нашей истории после открытия Бесконечного Вместилища Зерна на заднем дворе“. Стая с энтузиазмом подхватила идею, воробьи повсюду зачирикали, что было мочи. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Read a number from STDIN | |
; Read that many lines of input from STDIN. Print output to STDOUT | |
(defn shashank [s] | |
(- (count s) (count (partition-by identity s)))) | |
(defn -main [] | |
(println "give me a number of lines followed by that | |
many lines") | |
(loop [t (Integer/parseInt (read-line))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (def lazy-fib (lazy-cat [0 1] (map + lazy-fib (rest lazy-fib)))) | |
#'user/lazy-fib | |
user=> (count (take 200 lazy-fib)) | |
ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1424) | |
user=> (count (take 200 lazy-fib)) | |
93 | |
user=> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def comp2(f,g): | |
return lambda x: f(g(x)) | |
def comp(*fs): | |
return reduce(comp2, fs) | |
def reduce(reducing_function, fs, initial_value=None): | |
fs = iter(fs) | |
v = fs.next() if initial_value is None else initial_value | |
for f in fs: | |
v = reducing_function(v, f) | |
return v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
def reduce(reducing_function, fs, initial_value=None): | |
fs = iter(fs) | |
v = fs.next() if initial_value is None else initial_value | |
for f in fs: | |
v = reducing_function(v, f) | |
return v | |
square = lambda x: x**2 | |
def s(n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
def reduce(reducing_function, fs, initial_value=None): | |
fs = iter(fs) | |
v = fs.next() if initial_value is None else initial_value | |
for f in fs: | |
v = reducing_function(v, f) | |
return v | |
square = lambda x: x**2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
def reduce(reducing_function, fs, initial_value=None): | |
fs = iter(fs) | |
v = fs.next() if initial_value is None else initial_value | |
for f in fs: | |
v = reducing_function(v, f) | |
return v | |
square = lambda x: x**2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = do | |
getLine | |
pss <- read . lines . getContents | |
print $ foldr1 pss | |
-- list of numbers in the form of prime-power pairs | |
-- e.g. 35 would be [5 1 7 1] | |
gcd' _ [] = [] | |
gcd' [] _ = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ~/.emacs.d/package.el from http://repo.or.cz/w/emacs.git/blob_plain/1a0a666f941c99882093d7bd08ced15033bc3f0c:/lisp/emacs-lisp/package.el | |
(when | |
(load | |
(expand-file-name "~/.emacs.d/elpa/package.el")) | |
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/") | |
("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/"))) | |
(package-initialize)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; then enter the text in that file's own buffer. | |
OlderNewer