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
import random | |
class Node: | |
def __init__(self, v, l=None, r=None): | |
assert v is not None, "can't create a node with value = None" | |
self.v = v | |
self.l = l | |
self.r = r | |
def __repr__(self): |
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
""" | |
Reflection utils for repl interaction | |
""" | |
import types | |
from collections.abc import Iterable | |
from itertools import groupby | |
def kinds(m): | |
""" |
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
;; Un peu de combinatoire: | |
;; | |
;; Definition recursive de l'Ensemble Puissance (powerset) | |
;; (avec variantes stylistiques) | |
(setq lexical-binding t) | |
(defun pset (s) | |
(if (null s) | |
'(()) |
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
class Gun: | |
''' | |
>>> g = Gun() | |
>>> f = g() | |
>>> [next(f), next(g)] | |
[2, 1] | |
>>> [next(f), next(g)] | |
[3, 2] | |
>>> [next(f), next(g)] | |
[4, 3] |
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
// une tranche est un intervalle et un pourcentage | |
var defaut = { | |
tranches: [ | |
{lo:0, hi:9964, percent:0}, | |
{lo:9964, hi:27519, percent:14}, | |
{lo:27519, hi:73779, percent:30}, | |
{lo:73779, hi:156244, percent:41}, | |
{lo:156244, hi:999999999999, percent:45} | |
] | |
} |
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
package x | |
import java.util.Stack | |
import java.io.File | |
import javax.xml.parsers.* | |
import org.xml.sax.* | |
import org.xml.sax.helpers.* | |
class Node(val l:String, val q:String, val u:String, val a:Map<String,String>) { | |
val children:MutableList<Node> = mutableListOf<Node>() |
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
import os | |
import sys | |
import hashlib | |
DIR=os.path.expanduser('~/Downloads') | |
def md5(f,c=4096): | |
m = hashlib.md5() | |
with open(f,'rb') as b: | |
m.update(b.read(c)) |
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 buffer is for text that is not saved, and for Lisp evaluation. | |
;; To create a file, visit it with C-x C-f and enter text in its buffer. | |
;; | |
;; arithmetic expression compiler for elisp stack machine (and more) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Tree -> Stack | |
(defun left (a) | |
(cadr a)) |
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 buffer is for text that is not saved, and for Lisp evaluation. | |
;; To create a file, visit it with C-x C-f and enter text in its buffer. | |
;; | |
;;; Attempt at bringing f-string in elisp. | |
;;; (@f "{a} = {b}") | |
;;; -> | |
;;; (let ((a~ a) | |
;;; (b~ b)) | |
;;; (concatenate 'string a~ " = " b~)) |
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
[]\[\(.;..\)?[[:digit:]]*?m → |
OlderNewer