- Make sure developer tools are installed.
- Get the source from Freshmeat.
- Run
tar xvfj ex-050325.tar.bz2 && cd ex-050325
. - Add
include <sys/ioctl.h>
to fileex.h
. - Run the following:
make install INSTALL=/usr/bin/install \
PREFIX=${HOME}/.local/ \
tar xvfj ex-050325.tar.bz2 && cd ex-050325
.include <sys/ioctl.h>
to file ex.h
.make install INSTALL=/usr/bin/install \
PREFIX=${HOME}/.local/ \
// Solves problem 62 by iterating over all ints in increasing order | |
// and storing each in a map keyed by the lexigraphically-sorted | |
// cube of that number's digits. Repeat until storing an int results | |
// in the map key having five values associated with it. | |
// | |
// https://projecteuler.net/problem=62 | |
// | |
// It turns out big ints weren't necessary to solve the problem, | |
// but re-writing numerics code from regular to big numbers is | |
// a huge PITA, so it's better to start with math/big if you think |
package main | |
import "fmt" | |
func main() { | |
fmt.Printf("%d\n", iter(36, []int{25, 10, 5, 1})) // descending order, reverse of naive. | |
} | |
type Cache map[string]int |
;; Collection Iterators | |
;; Edwin Watkeys | |
;; May 22, 2020 | |
;; MIT Licensed | |
(define-library (iterator) | |
(import (scheme base) (scheme list) (srfi 111) (chibi generic)) | |
(export iterable? iterate map reduce next empty into done? | |
icons imake inext iempty imap-proc) |
;; Collection Iterators | |
;; Edwin Watkeys | |
;; May 22, 2020 | |
;; MIT Licensed | |
(define-library (iterator) | |
(import (scheme base) (scheme list) (srfi 111) (chibi generic)) | |
(export iterable? iterate map reduce next empty into done? | |
icons imake inext iempty imap-proc) |
;; Collection Iterators | |
;; Edwin Watkeys | |
;; May 22, 2020 | |
;; MIT Licensed | |
(define-library (iterator) | |
(import (scheme base) (scheme list) (srfi 111) (chibi generic)) | |
(export iterable? iterate map reduce next empty into done? | |
icons imake inext iempty imap-proc) |
(define-library (atomic-box-test) | |
(import (scheme base) (scheme write) (chibi test) (atomic-box) (srfi 18)) | |
(export run-tests) | |
(begin | |
(define (thread-spawn thunk) | |
(let ((t (make-thread thunk))) | |
(thread-start! t) | |
t)) |
;;; This is not a good use of macros. See below for an | |
;;; example implementation of COND. | |
(define-syntax proc-all | |
(syntax-rules () | |
((_ exp () body ...) | |
(begin body ...)) | |
((_ exp (match matches ...) body ...) | |
(unless (= exp match) (proc-all exp (matches ...) body ...))))) |
def containsMatch(nums, lower, upper, match): | |
"""Returns `True` if `match` occurs within indices | |
[`lower`, `upper`] of sorted list `nums`.""" | |
while True: | |
i = (upper + lower) // 2 | |
cur = nums[i] | |
if match == cur: | |
return True | |
elif lower >= upper: |
(define-syntax let-optionally | |
(syntax-rules (_) | |
((_ vs () e f ...) | |
(let () e f ...)) | |
((_ vs (_ xv ...) e f ...) | |
(if (null? vs) | |
(let-optionally '() (xv ...) e f ...) | |
(let-optionally (cdr vs) (xv ...) e f ...))) | |
((_ vs ((x v) xv ...) e f ...) | |
(if (null? vs) |