Skip to content

Instantly share code, notes, and snippets.

Mu Lei NalaGinrut

Block or report user

Report or block NalaGinrut

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@NalaGinrut
NalaGinrut / s2b.scm
Created Oct 19, 2012
string->binary
View s2b.scm
(use-modules (rnrs))
(define* (string->binary str #:key (base 16) (endiannes 'little))
(let ((n (string->number str base))
(f (case endiannes
((big) identity)
((little) reverse)
(else (error "wrong endiannes" endiannes)))))
(let lp ((n n) (result '()))
(if (zero? n)
@NalaGinrut
NalaGinrut / fix-name.scm
Created Aug 14, 2012
patches set name fixing
View fix-name.scm
#! /usr/local/bin/guile \
-e main -s
!#
(use-modules (ice-9 regex) (ice-9 ftw))
(define (sub from to str) (regexp-substitute #f (string-match from str) 'pre to 'post))
(define (usage args) (format #t "~a from to path~%" (car args)))
(define main
@NalaGinrut
NalaGinrut / srfi-28-compiler.scm
Created Jul 24, 2012 — forked from ijp/srfi-28-compiler.scm
turn format strings into a procedure
View srfi-28-compiler.scm
#!r6rs
;; a toy for turning srfi 28 format strings into a procedure, that
;; performs the format, and outputs to stdout
(library (toys srfi-28-compiler)
(export format-string->procedure)
(import (rnrs)
(only (srfi :1 lists) fold)
(srfi :8 receive))
(define (escape-char? char)
@NalaGinrut
NalaGinrut / wrp.scm
Created Jul 20, 2012
weekly report parser
View wrp.scm
#! /usr/local/bin/guile \
-e main -s
!#
(define main
(lambda args
(let ((wrl (primitive-eval (read))))
(for-each (lambda (x)
(format #t "[~a]:~%" (car x))
@NalaGinrut
NalaGinrut / ft1.scm
Created Jul 20, 2012
the shortest snake arrange algorithm (slow version)
View ft1.scm
(define (main . args)
(let* ((ll ((@ (srfi srfi-1) iota) (read) 1)) (len (length ll)) (m (1- (/ len 2))))
(display len)(newline)
(let lp((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1))
(and (< n len) (for-each (lambda (x y) (display x)(display " ")(display y)(display " ")) a b)(newline)
(lp `(1 ,(car b) ,@(cdr a)) `(,@(cdr b) ,(list-ref a m)) (1+ n))))))
@NalaGinrut
NalaGinrut / ft2.scm
Created Jul 20, 2012
the shortest snake arrange algorithm
View ft2.scm
#! /usr/local/bin/guile \
-e main -s
!#
(define (main . args)
(let* ((ll ((@ (srfi srfi-1) iota) (read) 1)) (len (length ll)) (m (1- (/ len 2))))
(display len)(newline)
(let lp((a (list-head ll (1+ m))) (b (list-tail ll (1+ m))) (n 1))
(and (< n len) (for-each (lambda (x y) (display x)(display " ")(display y)(display " ")) a b)(newline)
(lp (append (list 1 (car b)) (cdr a)) (append (cdr b) (list (list-ref a m))) (1+ n))))))
You can’t perform that action at this time.