(defn next-seq
[& {:keys [sep type] :or {sep " " type nil}}]
(let [line (read-line)
parts (clojure.string/split line (re-pattern sep))]
(case type
:int (map #(Integer/parseInt %) parts)
:double (map #(Double/parseDouble %) parts)
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 date-stream (&key (start-date nil) (interval 1) (interval-type :day)) | |
(let ((start (if (not start-date) (now) start-date))) | |
(lambda () | |
(let ((current start)) | |
(setq start (funcall (cond | |
((eq interval-type :day) #'day+) | |
((eq interval-type :month) #'month+) | |
((eq interval-type :year) #'year+) | |
(t #'day+)) start interval)) | |
current)))) |
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
#lang racket | |
(define (freq-list str) | |
(let ([sl (map (λ (x) (format "~a" x)) | |
(string->list str))]) | |
(hash->list | |
(make-hash | |
(map (λ (x) (cons (list x) | |
(count (λ (y) (string=? x y)) sl))) |
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 all-pos (n) | |
(loop for i from 0 to (- n 1) | |
append (loop for j from 0 to (- n 1) | |
collect (cons i j)))) | |
(defun single-queen (n) | |
(loop for i in (all-pos n) | |
collect (list i))) | |
(defun safep (p moves) |
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
#lang racket | |
(define (all-positions n) | |
(for*/list ([i n] | |
[j n]) | |
(cons i j))) | |
(define (single-solutions n) | |
(for/list ([i (all-positions n)]) |
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
' Newton's square root method | |
TextWindow.Write("Enter a positive number: ") | |
n = TextWindow.ReadNumber() | |
guess = 1.0 | |
Calculate: | |
diff = Math.Abs(n - (guess * guess)) | |
If diff <= 0.001 Then |
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
#include <openssl/hmac.h> | |
#include <openssl/sha.h> | |
#include <openssl/evp.h> | |
#include <string.h> | |
#define EXPECTED "0d696548764b6f910bdd3c07d8e465112c0783a03f2c1cf5ef893b8aa27f3290" | |
int main() | |
{ | |
unsigned char *message = (unsigned char *)"this is highly sensitive user data"; |
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
(ql:quickload :ironclad) | |
(defpackage :test (:use :cl :ironclad)) | |
(in-package :test) | |
(defun hmac-sha256 (secret data) | |
(let* ((secret-bytes (ascii-string-to-byte-array secret)) | |
(data-bytes (ascii-string-to-byte-array data)) | |
(h (make-hmac secret-bytes :sha256))) | |
(update-hmac h data-bytes) | |
(byte-array-to-hex-string (hmac-digest h)))) |
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
program cat(input, output); | |
var | |
fname: string[60]; | |
f: text; | |
ln: string[100]; | |
rw: integer; | |
i: integer; | |
begin | |
write('FILE? '); | |
readln(fname); |
OlderNewer