sudo apt-get install bzr
sudo apt-get install bzr-fastimport
bzr branch lp:p2psp
*.beam |
#include<stdio.h> | |
#include<string.h> | |
#include<stdlib.h> | |
#include<time.h> | |
#include<unistd.h> | |
#include<ncurses.h> | |
#define BLACKJACK 21 | |
#define GAMEPOINTS 3 | |
#define TRUE 1 |
(declaim (optimize (debug 2))) | |
;; Part one. | |
(defun line-number (fname code-loc) | |
(let* ((all-offsets (sb-di::debug-source-start-positions code-loc)) | |
;; Get last item from the array, I haven't found anything | |
;; like 'pop' to do it better. | |
(offset (aref all-offsets (- (length all-offsets) 1)))) | |
(with-open-file (f fname) |
open StdLabels | |
type 'a tree = Node of ('a * 'a tree list) | |
let rec make ~f init = | |
let (label, forest) = f init in | |
Node (label, (List.map ~f:(make ~f) forest)) | |
and draw ~f (Node (label, forest)) = | |
let rec inner = function |
(* Functions for printing lists of strings, lists of chars, lists of ints, | |
* and lists of floats. | |
* *) | |
(* Helper function. *) | |
let print_list to_string l = | |
let rec loop rem acc = | |
match rem with | |
| [] -> acc | |
| [s] -> acc ^ (to_string s) |
/* Prints binary representation of any data type in C (including ints, arrays, structs, etc.). | |
* Assumes big endian. | |
* Adapted from: https://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format | |
* | |
* Example use: | |
* int i = 123456789; | |
* print_bits(&i, sizeof i); | |
* Prints: 00010101 11001101 01011011 00000111 | |
* */ | |
void print_bits(void const * const ptr, size_t const size) { |
/* Improved version for https://codereview.stackexchange.com/questions/228979/read-string-of-any-length-in-c */ | |
#include <stdlib.h> | |
#include <stdio.h> | |
/* Reads string input up to, but not including, the first newline or EOF. | |
* Returns a pointer to the string, or NULL on error. | |
* The pointer to the string must be freed. | |
*/ | |
char* input() { |