Skip to content

Instantly share code, notes, and snippets.

View ijp's full-sized avatar

Ian Price ijp

  • Aberdeen, Scotland
View GitHub Profile
#!r6rs
(library (toys quasiquote)
(export quasiquote
unquote
unquote-splicing
)
(import (except (rnrs) quasiquote unquote unquote-splicing))
(define-syntax unquote
(lambda (stx)

Semantic Key-bindings

The following is an issue that comes up from time to time on #emacs, and we don’t really have a good answer to it. I don’t for a minute think that I have figured this whole thing out, but here goes.

The problem

Joe Hacker is an Emacs user, and is quite content, only some he doesn’t like a particular key-binding. To make things concrete, he

#!/usr/local/bin/guile
!#
(define (bug? form)
(equal? form '((display "scheme sucks!\n"))))
(define buggy-code
'((display "scheme is great!\n")))
(define safe-compiler
@ijp
ijp / C.scm
Created April 14, 2013 00:37
;; Problem
;; Little John likes palindromes, and thinks them to be fair (which is
;; a fancy word for nice). A palindrome is just a number that reads
;; the same backwards and forwards - so 6, 11 and 121 are all
;; palindromes, while 12, 223 and 2244 are not.
;; He recently became interested in squares as well, and formed the
;; definition of a fair and square number - it is a number that is a
;; palindrome and a square of a palindrome at the same time. For
@ijp
ijp / commentator.py
Last active May 17, 2020 16:25
Road to Yokozuna - Slohyo prototype
class StdioLogger(object):
def log(self, msg):
print(msg)
class NullLogger(object):
def log(self, msg):
pass
@ijp
ijp / blog.org
Created January 21, 2012 15:56
yin yang problem explanation

The Yin Yang Problem

08/06/2011

(let* ((yin
         ((lambda (cc) (display #\@) cc) (call-with-current-continuation (lambda (c) c))))
       (yang
         ((lambda (cc) (display #\*) cc) (call-with-current-continuation (lambda (c) c)))) )
    (yin yang))

While I figured out this before, I never bothered to write down my

@ijp
ijp / fraktur
Created September 7, 2014 19:49
#!/usr/local/bin/guile -s
!#
;; Hey emacs this is -*- scheme -*- code
(eval-when (compile load eval)
(set! %load-extensions '(".guile.sls" ".sls" ".ss" ".scm" "")))
(import (ijputils strings)
(only (rnrs) let*-values)
(ice-9 match))
@ijp
ijp / SECD2.hs
Created February 18, 2013 22:21
-- An implementation of Peter Landin's SECD machine, as described in
-- "The Mechanical Evaluate of Expressions"
import Prelude hiding (lookup)
type Name = String
data Expr a = ID Name
| Obj a
| Fun Name (Expr a)
| Apply (Expr a) (Expr a)
@ijp
ijp / SECD.hs
Created February 18, 2013 22:21
-- An implementation of Peter Landin's SECD machine, as described in
-- "The Mechanical Evaluate of Expressions"
import Prelude hiding (lookup)
type Name = String
data Expr = ID Name
| Fun Name Expr
| Apply Expr Expr
deriving (Eq, Show)
@ijp
ijp / evil-map.scm
Last active July 30, 2017 17:38
a map on two lists, as one right fold
;; <ski> turbofail : for fun, express a `map' taking two lists with calls to
;; `foldr' (one for each list)
;; ...
;; <Fuco> what is "map taking two lists"
;; <Fuco> you mean zipWith?
;; ...
;; <Fuco> because you can't do that as a fold on list [23:11]
;; <ijp> Fuco: want a bet?
;; ...
;; <ijp> I think I might be able to do it with one