01001111 01110101 01110010 00100000 01100110 01100001 01110100
01101000 01100101 01110010 00101100 00100000 00001010 01110111
01101000 01101111 00100000 01100001 01110010 01110100 00100000
01101001 01101110 00100000 01101000 01100101 01100001 01110110
01100101 01101110 00101100 00100000 00001010 01101000 01100001
01101100 01101100 01101111 01110111 01100101 01100100 00100000
01100010 01111001 00100000 01010100 01101000 01111001 00100000
01101110 01100001 01101101 01100101 00101110 00100000 00001010
01010100 01101000 01111001 00100000 01101011 01101001 01101110
01100111 01100100 01101111 01101101 00100000 01100011 01101111
01101101 01100101 00101100 00100000 00001010 01110100 01101000
01111001 00100000 01110111 01101001 01101100 01101100 00100000
01100010 01100101 00100000 01100100 01101111 01101110 01100101
00100000 00001010 01101111 01101110 00100000 01100101 01100001
01110010 01110100 01101000 00100000 01100001 01110011 00100000
01101001 01110100 00100000 01101001 01110011 00100000 01101001
01101110 00100000 01101000 01100101 01100001 01110110 01100101
01101110 00101110 00100000 00001010 01000111 01101001 01110110
01100101 00100000 01110101 01110011 00100000 01110100 01101000
01101001 01110011 00100000 01100100 01100001 01111001 00100000
01101111 01110101 01110010 00100000 01100100 01100001 01101001
01101100 01111001 00100000 01100010 01110010 01100101 01100001
01100100 00101100 00100000 00001010 01100001 01101110 01100100
00100000 01100110 01101111 01110010 01100111 01101001 01110110
01100101 00100000 01110101 01110011 00100000 01101111 01110101
01110010 00100000 01110100 01110010 01100101 01110011 01110000
01100001 01110011 01110011 01100101 01110011 00101100 00100000
00001010 01100001 01110011 00100000 01110111 01100101 00100000
01100110 01101111 01110010 01100111 01101001 01110110 01100101
00100000 01110100 01101000 01101111 01110011 01100101 00100000
01110111 01101000 01101111 00100000 01110100 01110010 01100101
01110011 01110000 01100001 01110011 01110011 00100000 01100001
01100111 01100001 01101001 01101110 01110011 01110100 00100000
01110101 01110011 00101110 00100000 00001010 01001100 01100101
01100001 01100100 00100000 01110101 01110011 00100000 01101110
01101111 01110100 00100000 01101001 01101110 01110100 01101111
00100000 01110100 01100101 01101101 01110000 01110100 01100001
01110100 01101001 01101111 01101110 00101100 00100000 00001010
01100010 01110101 01110100 00100000 01100100 01100101 01101100
01101001 01110110 01100101 01110010 00100000 01110101 01110011
00100000 01100110 01110010 01101111 01101101 00100000 01100101
01110110 01101001 01101100 00101110 00100000 00001010 01000110
01101111 01110010 00100000 01110100 01101000 01101001 01101110
01100101 00100000 01101001 01110011 00100000 01110100 01101000
01100101 00100000 01101011 01101001 01101110 01100111 01100100
01101111 01101101 00101100 00100000 00001010 01100001 01101110
01100100 00100000 01110100 01101000 01100101 00100000 01110000
01101111 01110111 01100101 01110010 00101100 00100000 01100001
01101110 01100100 00100000 01110100 01101000 01100101 00100000
01100111 01101100 01101111 01110010 01111001 00100000 00001010
01100110 01101111 01110010 00100000 01100101 01110110 01100101
01110010 00100000 01100001 01101110 01100100 00100000 01100101
01110110 01100101 01110010 00101110 00001010 01000001 01101101
01100101 01101110 00101110 00100000 

In order to make this conversion, I wrote a little scheme program. This is my first and only attempt at using scheme. It's beautiful, mathematically, but I haven't quite got the hang of it. This should work on any unix system running guile.

":"; exec guile -s $0 "$@"

(define s "Our father,
who art in heaven,
hallowed by Thy name.
Thy kingdom come,
thy will be done
on earth as it is in heaven.
Give us this day our daily bread,
and forgive us our trespasses,
as we forgive those who trespass against us.
Lead us not into temptation,
but deliver us from evil.
For thine is the kingdom,
and the power, and the glory
for ever and ever.
Amen. ")

(define num->bin-rec
  (lambda (n count)
    (if (= count 1)
      (number->string (modulo n 2))
      (string-append 
        (num->bin-rec (quotient n 2) (- count 1))
        (number->string (modulo n 2))))))

;; Convert a number into a string of 1's and 0's.
;; Number between 0 and 255.
(define num->bin
  (lambda (n) (num->bin-rec n 8)))

;; Converts a char to binary string
(define char->bin 
  (lambda (c) (num->bin (char->integer c))))

;; Converts a string into a list of strings, each a binary
;; representation of a character from the string.
(define string->bin 
  (lambda (st) (map char->bin (string->list st))))

(display (string->bin s))

This essentialy takes the idea of the Lord's Prayer and encodes it into English sentences. These English sentences are written down using the latin alphabet. Each letter is represented on a computer as a number, as defined by ASCII. Each number is converted into a string of 1's and 0's that are the binary representation of that number.

It would be neat if a knight of the lambda calculus would show me how to make that function tail-recursive.


Any says re The Lord's Prayer : binary: The easy way to make it tail-recursive would be to pass the string so far as an argument to num->bin-rec, putting the string-append inside the recursive call. Is that enough? Given more space I could write it out.

Perl version:

#!/usr/bin/perl
my $s="Our father,
who art in heaven,
hallowed by Thy name.
Thy kingdom come,
thy will be done
on earth as it is in heaven.
Give us this day our daily bread,
and forgive us our trespasses,
as we forgive those who trespass against us.
Lead us not into temptation,
but deliver us from evil.
For thine is the kingdom,
and the power, and the glory
for ever and ever.
Amen. \n";
print unpack('B*',$s), "\n";

Here's a C program that converts stdin to binary on stdout. One must simply pipe the Lord's Prayer into it.

#include <stdio.h>
int main(void) {
        char c;
        int i;
        while (fread(&c, sizeof(c), 1, stdin) == 1) {
                for (i = 7; i > -1; i--) {
                        printf("%d", (c & (1 << i)) >> i);
                }
                printf(" ");
        }
        printf("\n");
        return 0;
}

"The Lord's Prayer: binary" E2 Writeup, Copyright 2002-2007 Frank Grimes.

This writeup is released under the Creative Commons Attribution-ShareAlike License v2.5. (For details, see http://creativecommons.org/licenses/by-sa/2.5/ ) Alternatively, permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2. (For details, see http://www.gnu.org/licenses/fdl.html)

--Frank Grimes, 2007

Log in or registerto write something here or to contact authors.