Clojure and Groovy side-by-side
Clojure | Groovy | |
map |
36,173,112,115,116 |
Clojure and Groovy side-by-side
Clojure | Groovy | |
map |
(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))))))) |
(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"} |
#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))) |
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): |
# | |
# 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({ |
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>" |
JavaScript | Python | |
Object | {}; new Object(); new function() {} | |
Array | []; new Array() | |
List | []; list() | |
RegExp | // |