I tend to write rather functional code in Python so when I switch to Clojure I don't have to learn lots of things. Yet I often forget how to express some concepts in Clojure.
itertools.count(0)
becomes (iterate inc 0)
--- src/common/server.c.old 2011-06-11 13:42:31.126537883 +0200 | |
+++ src/common/server.c 2011-06-11 13:43:14.559870355 +0200 | |
@@ -115,7 +115,7 @@ | |
} | |
} else | |
{ | |
- if (using_irc) /* using "IRC" encoding (CP1252/UTF-8 hybrid) */ | |
+ if (0) /* using "IRC" encoding (CP1252/UTF-8 hybrid) */ | |
/* if all chars fit inside CP1252, use that. Otherwise this | |
returns NULL and we send UTF-8. */ |
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
from itertools import izip | |
from datetime import datetime | |
from PIL import Image | |
from numpy.random import randint | |
x, y = 2560, 1920 |
<?xml version="1.0" encoding="UTF-8"?> | |
<interface> | |
<!-- interface-requires gtk+ 3.0 --> | |
<object class="GtkWindow" id="MainWindow"> | |
<property name="can_focus">False</property> | |
<property name="has_resize_grip">False</property> | |
<signal name="destroy" handler="on_window_destroy" swapped="no"/> | |
<child> | |
<object class="GtkBox" id="vbox"> | |
<property name="width_request">400</property> |
#!/usr/bin/env python3 | |
import base64 | |
from gi.repository import Gtk as gtk | |
from gi.repository import GdkPixbuf as gdk_pixbuf | |
from gi.repository import Gio as gio | |
PYTHON_AT_WORK_48 = b""" | |
R0lGODlhMAAwAPcAADladTldfE9PT19fX0NjfFVsfmRkZG5ubXRwbWNtdnNz | |
c3t4dXR3eXx8fP+7G/+9I//DJP/EK//KLf/FMv/LNP/FPv/OOv/SNf/TPYWB |
npm http GET https://registry.npmjs.org/jsdom | |
npm http GET https://registry.npmjs.org/zap | |
npm http GET https://registry.npmjs.org/docco | |
npm http GET https://registry.npmjs.org/coffee-script | |
npm http 200 https://registry.npmjs.org/zap | |
npm http GET https://registry.npmjs.org/zap/-/zap-0.2.4-1.tgz | |
npm http 200 https://registry.npmjs.org/docco | |
npm http GET https://registry.npmjs.org/docco/-/docco-0.3.0.tgz | |
npm http 200 https://registry.npmjs.org/coffee-script | |
npm http GET https://registry.npmjs.org/coffee-script/-/coffee-script-1.2.0.tgz |
import string, random | |
l = [''.join(random.choice(string.printable) for i in xrange(20)) for e in xrange(10000)] | |
print [e for e in l if "dbe" in e] |
# switch to a nicer syntax | |
.syntax unified | |
# declare main as exportable (public) | |
.global main | |
# our main "function" | |
main: | |
# push return address (lr) and ip on the stack | |
push {ip, lr} |
% rlwrap io | |
Io 20080120 | |
Io> Range | |
==> Range_0x912e7d0: | |
first = Range_first() | |
foreach = Range_foreach() | |
index = Range_index() | |
last = Range_last() | |
next = Range_next() | |
previous = Range_previous() |
OperatorTable addAssignOperator(":", "atPutNumber") | |
curlyBrackets := method( | |
r := Map clone | |
call message arguments foreach(arg, | |
r doMessage(arg)) | |
r) | |
Map atPutNumber := method( | |
self atPut( | |
call evalArgAt(0) asMutable removePrefix("\"") removeSuffix("\""), |