This file contains hidden or 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
;; The as-> macro doesn't work with destructuring. This is invalid code: | |
(-> [1 2] | |
(as-> [a & b] | |
[a (inc b)] | |
[(inc a) b])) | |
;; because it is expanded to: | |
(let [[a & b] [1 2] |
This file contains hidden or 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
(defn remove-first [e [x & rest :as col]] | |
(lazy-seq | |
(cond (empty? col) [] | |
(= x e) rest | |
:default (cons x (remove-first e rest)) | |
))) |
This file contains hidden or 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
import functools | |
class A: | |
def __init__(s): | |
s.a = 1 | |
def c(s,b,c,d): | |
print s.a,b,c,d | |
a = A() | |
a.c(2,3,4) | |
#=> 1 2 3 4 |
This file contains hidden or 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
BIND_DN = "cn=read-only-admin,dc=example,dc=com" | |
BIND_PASSWORD = 'password' | |
import simpleldap | |
conn = simpleldap.Connection('ldap.forumsys.com',dn=BIND_DN, password=BIND_PASSWORD) | |
user = conn.get("uid=euler") |
This file contains hidden or 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
(ns c) | |
(defmacro print-ns [] (println [:c *ns*])) | |
(ns b) | |
(defmacro print-ns [] (c/print-ns)) | |
;;=> prints [:c #<Namespace b>] when c/print-ns is expanded | |
(b/print-ns) | |
;;=> nothing printed, c/print-ns already macroexpanded (and println executed) on the b/print-ns defmacro | |
(ns a) | |
(c/print-ns) | |
;;=> prints [:c #<Namespace a>] |