JavaScript | Python | |
Object | {}; new Object(); new function() {} | |
Array | []; new Array() | |
List | []; list() | |
RegExp | // |
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 os | |
from os.path import splitext | |
def xml_start(): | |
return """<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | |
<properties> | |
""" | |
def xml_end(): | |
return "</properties>" |
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
# | |
# simplified version of http://en.wikipedia.org/wiki/Shunting-yard_algorithm | |
# no error checking for mismatched parentheses | |
# letters used instead of numbers | |
# | |
def shunting_yard(s): | |
output_queue = [] | |
operator_stack = [] | |
operators = dict({ |
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
def parse(people): | |
""" | |
returns a list of tuples; first element in tuple - last name; second element - a dict | |
""" | |
people_dicts = [dict(zip(("first", "last", "email"), person.split())) for person in people.splitlines()] | |
return [(d["last"], d) for d in people_dicts] | |
def santafy(l): | |
def index(i): |
Generated from ‘List of programming languages by type’ from Wikipedia: http://en.wikipedia.org/wiki/Categorical_list_of_programming_languages
- Reflective languages
- Machine languages
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
#lang scheme | |
(define (atom? x) | |
(and (not (pair? x)) (not (null? x)))) | |
(define lat? | |
(lambda (l) | |
(cond | |
((null? l) #t) | |
((atom? (car l)) (lat? (cdr l))) |
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 list-soup.views.common | |
(:use [noir.core :only [defpartial]] | |
[hiccup.page-helpers :only [include-css include-js html5]])) | |
(defpartial layout [& content] | |
(html5 | |
[:head | |
[:title "list-soup"] | |
(include-css "/css/bootstrap.css") | |
[:style {:type "text/css"} |
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
(def l [0 1 2 3 4 5 6 7 8 9]) | |
(defn union-qf[p q l] | |
(let [pid (nth l p)] | |
(map #(if (= % pid) (nth l q) %) l))) | |
(println (union-qf 6 7 (union-qf 2 8 (union-qf 0 5 (union-qf 7 1 (union-qf 4 3 (union-qf 2 3 l))))))) |
Clojure and Groovy side-by-side
Clojure | Groovy | |
map |
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
36,173,112,115,116 |