notes-computer-jasper-jasperLibraries

std lib:

+ - * / pow e exp log (sqrt = pow(x,.5) ; log = exp^-1, not to be confused with 1/exp) matrix multiplication

see Haskell prelude see Scala std libs see Python std fns see Octave std fns see Common Lisp

sort n-way merge a dict. many different ways (different ways of handling conflicts): prefer left over right (in general, preference list) prefer right over left (same as permuting args as above) leave out items with conflicting keys indeterminate: one of the above but no guarantees which turn every key into a tuple, with the first element indicating which one it came from include conflicts twice (you get a multidict at the end rather than a dict) decide conflicts based on an arbitrary function (provided by caller) (the fn can return null to indicate that this pair should just be left out) conflicting values are turned into a set (e.g. if {1:2, 3:4} merged with {1:5}, then {1:{2,5}, 3:4} throw an error if there are conflicts

map pickle zip (nway) i think Python zip is nway btw this demonstrates the usefulness of variadic functions..

delegate

if you have a multilevel dict, rearrange the levels (e.g. {'a': {'1': 11 '2': 22}, 'b': {'1': 33, '2': 44}} --> {'1': {'a': 11 'b': 33}, '2': {'a': 22, 'b': 44}})

python's 'cmp'

permute an n-d vector permute args of fn

conventions: should have some std conventions on:

capitalization of functions whether the lib name can equal the name of something within it, like python's datetime.datetime (no) do predicate function names start with "is"? (no) nouns or verbs (verbs) by default do operations vectorize or do some more clever thing (e.g. does X * Y when X and Y are matrixes do matrix multiplication or elementwise multiplication?) (vectorize)

multiprocessing: need most of the constructs in Python's 'multiprocessing' lib. Also need to be able to select() over Event variables (and mb Condition vars), i.e. to say 'sleep until any of these Events occur'.

other libs:

linregress plotting imshow histogram pseudoinverse function maximization corrcoef std var polyfit cross-correlation autoc svd eig kmeans? pca dim reduction framework supervised learning framework clustering framework conv (n-d) griddata

homomorphisms, cosets

cat theory diagrams

perl spaceship operator (<=>)

map fold arcmap arcfold

host (e.g. host(nil) = None if the host is Python)

the equiv of dict(), and dict.values()

first, rest (== head, tail)

first last take (like tail but for head; the first n elements; might also call head?) rest (all but the first n elements) tail (the last n elments) init (all but the last n elements; think of a better name tho)

logging: ALL, VERBOSEDEBUG, DEBUG, DETAILEDINFO, INFO, REPORT, WARNING, ERROR, CRITICAL suggested usages:

  ALL: reports all calls to log
  DEBUG: useful almost exclusively when debugging
   DEBUG1, DEBUG2, DEBUG3
   VERBOSEDEBUG, NORMALDEBUG, SUMMARYDEBUG
  INFO: info reported to the user during the normal operation of the program, in ascending order of importance:
   INFO1, INFO2, INFO3
   VERBOSEINFO, NORMALINFO, SUMMARYINFO
  MINOR: stuff that is abnormal but not too important:
   MINOR1, MINOR2, MINOR3
   WARNING: not an error, but a warning
   TRIVIALERROR: technically an error, but it should usually be disregarded
   MINORERROR: an error that is not very important
  MAJOR: important errors:
   MAJOR1, MAJOR2, MAJOR3
   ERROR: an ordinary error
   MAJORERROR: a big error, the sort which an autonomous system would probably email someone about
   CRITICAL: a super important error, the sort which should result in paging someone

or could just use:

logging.DEBUG = 10 logging.DEBUG2 = 15 logging.DEBUG3 = 17

logging.INFO = 10 logging.INFO2 = 15 logging.INFO3 = 17

logging.WARN = 10 logging.WARN2 = 15 logging.WARN3 = 17

logging.ERROR = 10 logging.ERROR2 = 15 logging.ERROR3 = 17

logging.CRITICAL = 10 logging.CRITICAL2 = 15 logging.CRITICAL3 = 17

---

second argument to string replace should be treated as a simple string literal (by default): ruby doesnt do this and it causes problems: http://neugierig.org/software/blog/2011/10/quoting.html http://evan-tech.livejournal.com/209849.html

---

graph substitution (replace a node with a subgraph; possibly connecting different edges in the original node with different nodes in the subgraph)

---

http://news.ycombinator.com/item?id=3857667

transitive closure operator

equivalencePartitions: given a set and an equivalence relation, returns a set of cosets

--- this should be easier:

cPickle.dump({'a':a, 'a2':a2, 'a3':a3, 'a4':a4, 'a5':a5, 'a6':a6, 'a7':a7, 'a2l':a2l, 'a3l':a3l, 'a4l':a4l, 'a5l':a5l, 'a6l':a6l, 'a7l':a7l}, open('/tmp/test.p', 'w'))

flatten nested list to n levels: lofl = [[180.0], [173.8], [164.2], [156.5], [147.2], [138.2]] l = [val for subl in lofl for val in subl]

or itertools.chain.from_iterable

or recursively:

matplotlib.cbook.flatten

---

http://blog.yhathq.com/posts/10-R-packages-I-wish-I-knew-about-earlier.html

someone (http://sergimansilla.com/blog/promise-of-ffos/) said they liked Apple's ios library names: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByReplacingPercentEscapesUsingEncoding (but were they being sarcastic?)

timeouts by default (i was just reading Release It :) )

--- ways to preallocate containers for efficiency:

https://speakerdeck.com/alex/why-python-ruby-and-javascript-are-slow

--- " the jQuery.when() function, which takes a list of promises and returns a new promise that resolves when all the inputs resolve.)

"

the promise api in http://blog.jcoglan.com/2013/03/30/callbacks-are-imperative-promises-are-functional-nodes-biggest-missed-opportunity/ (then, resolve, reject)

---

http://dfellis.github.com/queue-flow/2012/09/22/why-queue-flow/

numpy, scipy stuff allclose

any, all

some problems in Excel to avoid: On the accuracy of statistical procedures in Microsoft Excel 2007 B.D. McCullough? a , ∗ , David A. Heiser http://www.pages.drexel.edu/~bdm25/excel2007.pdf

also mentions the "NIST StRD? has five suites of test problems: univariate summary statistics, one-way ANOVA, linear regression, nonlinear least squares, and Markov-chain Monte Carlo (this last suite is not applicable here"

python enumerate

http://stackoverflow.com/questions/983354/how-do-i-make-python-to-wait-for-a-pressed-key


a = time.start b = time.since(a)

---

fundamental data struct should support python list, hash, set ops

--

flipdim, transpose, rot90, tile, len, concat, append, head, tail

--

the idea of generalizing a lookup in a dict into a lookup in a handler tree of dicts should itself be abstracted.

use that to implement scopes and multiscopes

in fact, any dict (node) should be transparently replacable by a handler tree!

--

optional support for cons-list style interface to lists, e.g. [1 2 3] == (cons 1 (cons 2 ( cons 3 nil))), head([]) = error, [] == nil, head([]) == EXCEPTION, tail([]) = nil

--

see slide 9 of https://speakerdeck.com/stilkov/clojure-for-oop-folks-how-to-design-clojure-programs: :

" ( def my-set

  1. { :a :b :c :c :c })
#{
a :b :c} ( def v [2 4 6 9 23]) (v 0) ;; 2 (v 2) ;; 6 ( def people { :pg "Phillip" , :st "Stefan" }) (people :st ) ;; "Stefan" ( :pg people) ;; "Phillip" ( :xyz people) ;; nil (+ 2 2) ;; 4 (+ 2 3 5 4) ;; 14 (class (/ 4 3)) ;; clojure.lang.Ratio (* (/ 4 3) 3) ;; 4 ( format "Hello, %s # %d" "world" 1)

( format "Hello, %s # %d" "world" 1) ; "Hello, World # 1"

(apply format [ "Hello, %s # %d" "world" 1])

; (a 2 3) (quote (a 2 3)) ;; (a 2 3) '(a 2 3) ;; (a 2 3) ; Evaluation (eval '( format "Hello, %s" "World" )) (eval (read-string "(+ 2 2)" ))

(fn [x] ( format "The value is %s\n" x)) ;; user$eval__1706$fn__1707@390b755d (( fn [x] ( format "The value is %s\n" x)) "Hello" ) ;; "The value is Hello" ( def testfn ( fn [x] ( format "The value is %s\n" x))) (testfn "Hello" ) ( defn testfn [x] ( format "The value is %s\n" x)) (testfn "Hello" )

"

--

clojure's

(iterate inc 0)

should be assigned to a constant, e.g. 'nat' (natural numbers)

--

clojure doseq (nested for loops):

http://clojuredocs.org/clojure_core/clojure.core/doseq

" Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by "for". Does not retain the head of the sequence. Returns nil. © Rich Hickey. All rights reserved. Eclipse Public License 1.0 5 Examples top

    link | changes
    view sourceprint?
    01	user=> (doseq [x [1 2 3]
    02	               y [1 2 3]]
    03	         (prn (* x y)))
    04	1
    05	2
    06	3
    07	2
    08	4
    09	6
    10	3
    11	6
    12	9
    13	nil"

note that doseq can progressively destructure, e.g. see slide 16 of https://speakerd.s3.amazonaws.com/presentations/2471a370b3610130440476a0f7eede16/2013-05-17-ClojureOOP-Geecon.pdf

--

clojure's map, which stops when either of its args runs out (i think) is useful for letting you work with lazy, infinite sequences

--

clojure iterate, repeatedly, cycle

iterate vs. repeatedly: no side effects vs. side effects?

--

from slide 32 of:

assoc assoc-in butlast concat conj cons count cycle difference dissoc distinct distinct? drop-last empty empty? every? filter first flatten group-by interleave interpose intersection into join lazy-cat mapcat merge merge-with not-any? not-empty? not-every? nth partition partition-all partition-by peek pop popy project remove replace rest rseq select select-keys shuffle some split-at split-with subvec take take-last take-nth take-while union update-in

--

clojure maps are also fns from keys to vals

--

flatten

--

clojure's swap! applies an arbitrary fn:

( defn id-generator ([prefix] (id-generator prefix 0)) ([prefix v] ( let [cnt ( atom v)] ( fn [] (make-id prefix ( swap! cnt inc))))))

--

mb this bit of code should be given a name, like 'swapconst', in clojure:

(swap! s (fn [_] s0))

(or mb swap! should be called swapf! and this should be called swap!)

--

clojure dorun http://clojuredocs.org/clojure_core/clojure.core/dorun

--

clojure defmulti multimethods, but with metadata

(comparing to this: https://speakerd.s3.amazonaws.com/presentations/2471a370b3610130440476a0f7eede16/2013-05-17-ClojureOOP-Geecon.pdf )

http://clojure.org/multimethods

--

"bindings to GTK2, the Windows API, the POSIX API, OpenGL?, SDL, Cario, Python, Lua, TCL, X11, libzip, PCRE, libcurl, mySQL and SQLite are included in the standard distribution." -- http://nimrod-code.org/index.html

--

convert boundaries from labels on the edges on the boundary, to wrappers, to labels on the nodes inside the boundary