Name: Anonymous 2008-03-08 8:38
LISP
import os
import sys
import imp
TEMPLATE_DIR = 'theme'
def import_module(name, path):
filename = os.path.join(path, name.replace('.', '/') + '.py')
mtime = os.stat(filename)[8]
module_name = 'template.' + name
if module_name in sys.modules:
module = sys.modules[module_name]
if mtime <= getattr(module, '__mtime__', 0):
print 'Not reloaded'
return module
module = imp.load_source(module_name, filename)
module.__mtime__ = mtime
return module
def fetch_template(name, *args, **kwargs):
tmpl = import_module(name, TEMPLATE_DIR)
if callable(tmpl.__template__):
return tmpl.__template__(*args, **kwargs)
return tmpl.__template__
print fetch_template('comment-form', reference=1)
void sort(uintmax_t *numbers, size_t length){
uintmax_t temp[length];
uintmax_t *arrays[2] = {numbers, temp};
for(uint_fast8_t i = 0; i < sizeof(uintmax_t) * CHAR_BIT; ++i){
for(size_t j = 0, start = 0, end = length - 1; j < length; ++j){
if(!(arrays[i & 1][j] & 1 << i))
arrays[i & 1 ^ 1][start++] = arrays[i & 1][j];
if(arrays[i & 1][length - j - 1] & 1 << i)
arrays[i & 1 ^ 1][end--] = arrays[i & 1][length - j - 1];
}}}
uintmax_t temp[length];uintmax_t *arrays[2] = {numbers, temp};
uintmax_t (*p)[*] = temp;(define (radix-sort list radix)
(define (vector-mutate! v i f) (vector-set! v i (f (vector-ref v i))))
(let loop ((list (map cons list list)))
(if (zero? (apply + (map cdr list)))
(map car list)
(do ((list list (cdr list)) (buckets (make-vector radix '())))
((null? list) (loop (apply append (map reverse (vector->list buckets)))))
(vector-mutate!
buckets (remainder (cdar list) radix)
(lambda (x) (cons (cons (caar list) (quotient (cdar list) radix)) x)))))))$ cat sort.c
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void sort(uintmax_t *numbers, size_t length){
uintmax_t temp[length];
uintmax_t *arrays[2] = {numbers, temp};
for(uint_fast8_t i = 0; i < sizeof(uintmax_t) * CHAR_BIT; ++i){
for(size_t j = 0, start = 0, end = length - 1; j < length; ++j){
if(!(arrays[i & 1][j] & 1 << i))
arrays[i & 1 ^ 1][start++] = arrays[i & 1][j];
if(arrays[i & 1][length - j - 1] & 1 << i)
arrays[i & 1 ^ 1][end--] = arrays[i & 1][length - j - 1];
}}}
int main(int argc, char *argv[]){
if(argc>1){
size_t len=strlen(argv[1]);
uintmax_t *array = calloc(len,sizeof(uintmax_t));
for(size_t i=0;i<len;++i) array[i]=(uintmax_t)argv[1][i];
sort(array,len);
for(size_t i=0;i<len;++i) argv[1][i]=(char)array[i];
puts(argv[1]);
}
return 0;
}
$ gcc -Wall -ansi -pedantic -std=c99 sort.c; ./a.out 5a7asfgadf34; rm a.out
sort.c: In function `sort':
sort.c:13: warning: suggest parentheses around arithmetic in operand of ^
sort.c:15: warning: suggest parentheses around arithmetic in operand of ^
3457aaadffgs
$
lispROLL
//`'''```,
o // LISP `.,
,....OOo. .c;.',,,.'``.,,.`
.' ____.,'.//
/ _____ \___/.'
| / || \\---\|
||__|| \\__||
ˌ´ `ˌ ˌ´ `ˌ
| () | | () |
`ˌ__ˌ´ `ˌ__ˌ´