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
quicksort :: (Ord a) => [a] -> [a] | |
quicksort [] = [] | |
quicksort (x:xs) = smaller ++ equal ++ greater | |
where smaller = quicksort (filter (<x) xs) | |
equal = x:(filter (==x) xs) | |
greater = quicksort (filter (>x) xs) |
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
addStream :: (Num a) => [a] -> [a] -> [a] | |
addStream (x:xs) (y:ys) = x + y : addStream xs ys | |
natural :: [Integer] | |
natural = 1 : addStream natural (repeat 1) |
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
#!/bin/bash | |
error () { | |
# USAGE: error <message> <is_fatal> | |
echo -n "!!ERROR!! " 1>&2 | |
echo "$1" 1>&2 | |
if (( "$2" )); then | |
exit 1 | |
fi | |
} |
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
#! /bin/sh | |
FILENAME=`date +'%Y%m%d'` | |
if test ! -e $FILENAME; then | |
touch $FILENAME | |
fi | |
if test -s $FILENAME; then | |
cat >> $FILENAME <<HORIZONTAL |
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
/* | |
* Copyright (c) 2012 Stefano Sabatini | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
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
(defun powerset (list) | |
"powerset returns the list of sublists of list" | |
(reduce #'(lambda (e l) | |
(nconc (mapcar #'(lambda (l) (cons e l)) l) | |
l)) | |
list | |
:from-end t | |
:initial-value '(nil))) | |
(defun permutation (list) |
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
(defun precedence (op) | |
(cond | |
((or (eq op '*) (eq op '/)) 20) | |
((or (eq op '+) (eq op '-)) 10) | |
(t 0))) | |
(defun infix->postfix (infix-exp) | |
"infix->postfix returns a postfix version of the infix expression passed to it. Currently, it does no error checking and does not support expressions with brackets." | |
(labels ((helper (acc op el iexp) | |
(cond |
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
#! /usr/local/bin/guile \ | |
-e main -s | |
!# | |
(use-modules ((sxml xpath) | |
#:select (sxpath)) | |
(ice-9 getopt-long) | |
(ice-9 ftw)) | |
(define *processors* '()) |
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
#! /usr/local/bin/guile \ | |
-e main -s | |
!# | |
(use-modules (mro io) | |
(mro web client) | |
(mro lists) | |
(sxml simple) | |
(sxml xpath) | |
(web uri) |
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
#[link_name = "curl"] | |
mod ll { | |
use std::libc::{c_char}; | |
extern { | |
pub fn curl_version() -> *c_char; | |
} | |
} | |
fn main() { | |
let s = unsafe { ::std::str::raw::from_c_str(ll::curl_version()) }; |
OlderNewer