The Lotus Cars Community banner

1 - 13 of 13 Posts

·
Registered
Joined
·
758 Posts
Discussion Starter #1
This might be interesting for some of you :

Jorge Luis Borges wrote a short story entitled 'the library of babel'. Each book in the library contains 410 pages, each page has 40 lines, and each line has 80 characters. Characters can be lower-cased letters, numbers, the period, the comma, or a space. There are as many books as there are combinations of characters.

I'm currently writing a linux scripting book for work. I decided I need one 'end of chapter' script that shows as many different functions as possible. So I wrote a script that produces a simplified library of babel. It just produces every different page in Borges' library.

The script itself isn't too impressive. But the different things it could output are. If you ran it, you'd find out when your Elise is going to arrive! Or what the next 40 winning lottery numbers will be! :)
 

·
Registered
Joined
·
758 Posts
Discussion Starter #2
Doesn't look like the script will be postable without removing indents :(

#!/bin/csh

set FUNC = `basename $0`
set START_TIME = `date`

set LTTR_ARY = ( a b c d e f g h i j k l m n o p q r s t u v w x y z )
set NUMB_ARY = ( 0 1 2 3 4 5 6 7 8 9 )
set CHAR_ARY = ( \ $LTTR_ARY[*] $NUMB_ARY[*] \, \. \? \" \' )

@ COMPLETE = 1

foreach LINE_CNT (`seq 1 40`)
foreach CHAR_CNT (`seq 1 80`)
@ X${LINE_CNT}${CHAR_CNT} = 1
end
end

while ( $COMPLETE != 0 )

foreach LINE_CNT (`seq 1 40`)
foreach CHAR_CNT (`seq 1 80`)
set VAL = `eval echo \$X${LINE_CNT}${CHAR_CNT}`
echo -n "$CHAR_ARY[$VAL]"
end

echo
end

@ LINE_CNT = 1
@ CHAR_CNT = 1
@ NEXT_RDY = 1

while ( $NEXT_RDY != 0 )
@ X${LINE_CNT}${CHAR_CNT}++

set VAL = `eval echo \$X${LINE_CNT}${CHAR_CNT}`

if ( $VAL >= 43 ) then
@ X${LINE_CNT}${CHAR_CNT} = 1
@ CHAR_CNT++

if ( $CHAR_CNT >= 81 ) then
@ CHAR_CNT = 1
@ LINE_CNT++

if ( $LINE_CNT >= 41 ) then
echo "$FUNC COMPLETE!"
goto complete
endif
endif
else
@ NEXT_RDY = 0
endif
end
end

complete:

echo "$FUNC Started at : $START_TIME"
echo "$FUNC Finished at: `date`"

exit 0
 

·
Registered
Joined
·
4,634 Posts
Well I'd sure like to know when I'm going to get my car, so go ahead then and run it for me, thanks very much ! :p

BTW, what the hell are you talking about ?
 

·
Registered
Joined
·
758 Posts
Discussion Starter #4
mikester said:
Well I'd sure like to know when I'm going to get my car, so go ahead then and run it for me, thanks very much ! :p

BTW, what the hell are you talking about ?
I would, but I'm busy looking for the ultimate question to life, the universe and everything :)

I just thought it was interesting how easy it is to get every peice of information possibly imaginable, yet have it be so completely useless !

If you ran the script to the very end, you'd have the cure for cancer, yet it would take many life times to sort through the information and find out which is the correct cure !

In the story, there's actually cults of people going around looking for the master index. A single book that will tell you which books are correct and which are false. But another cult goes around destroying all the books they find. So the master index might have already been destroyed !
 

·
Forum Founder
Joined
·
29,083 Posts
OUTPUT 42
 

·
Registered
Joined
·
1,155 Posts
Ah yes, but you'd also have all the answers to the questions that you're not intelligent enough to ask also.

And the answers to questions that arise from the answers of questions you're not intelligent enough to ask.

Which means it also contains the answer to the most commonly asked question when you're in the library: "what the hell am I looking at?", The second most asked question: "Where's the way out?" and the dangerously recursive question: "what do all the books in the library contain?"

On a similar vein:

http://user.tninet.se/~ecf599g/aardasnails/java/Monkey/webpages/
 

·
Registered
Joined
·
2,195 Posts
Gromit said:
Jorge Luis Borges wrote a short story entitled 'the library of babel'. Each book in the library contains 410 pages, each page has 40 lines, and each line has 80 characters. Characters can be lower-cased letters, numbers, the period, the comma, or a space. There are as many books as there are combinations of characters.
I follow you up until the last statement. Combinations of characters in... what? What's your "first class" object -- the thing which does not repeat?

If each line of 80 characters must be unique, occuring once in your books, you have something around 10^127 lines of 80 characters. That's an unfathomly huge amount of data... 10^115 terrabytes.

If lines can repeat, but each PAGE in a book must be unique, you have a seriously enormous amount of data.. 10^5,091

If each page can repeat, but books must be unique, then you're looking at 10^20,87,476, which is too large to even try to comprehend.

These are all just gibberish numbers until you consider that there are probably 10^23 grains of sand on planet Earth, and about 10^11 stars in our galaxy, maybe 10^22 total stars in the universe, and by some guesses 10^80 total atoms in the universe, so it's not likely even the simplest library would see print.
 

·
Registered
Joined
·
758 Posts
Discussion Starter #11
Re: Re: Library of Babel

Ground Loop said:
I follow you up until the last statement. Combinations of characters in... what? What's your "first class" object -- the thing which does not repeat?

If each line of 80 characters must be unique, occuring once in your books, you have something around 10^127 lines of 80 characters. That's an unfathomly huge amount of data... 10^115 terrabytes.

If lines can repeat, but each PAGE in a book must be unique, you have a seriously enormous amount of data.. 10^5,091

If each page can repeat, but books must be unique, then you're looking at 10^20,87,476, which is too large to even try to comprehend.

These are all just gibberish numbers until you consider that there are probably 10^23 grains of sand on planet Earth, and about 10^11 stars in our galaxy, maybe 10^22 total stars in the universe, and by some guesses 10^80 total atoms in the universe, so it's not likely even the simplest library would see print.
By his definition, each book is unique. Therefore you could have two books be almost identical other than a misplaced comma or missing period (the reason why the cultists don't mind the fact that the Master Index could have been destroyed).

Most books would be complete gibberish, but a select few would describe every star in the universe, or what you'll be having for lunch this time next year.

The library would contain every peice of information, fact or fiction, that can be expressed with our current characters. But, due to the overwhelming amount of gibberish, the library would be useless. Hence 'the library of *babel*' :)

Though the story got me thinking. He described a printed library (hard copy). But with computers, it would be pretty easy to limit down the output through a series of spell checks, or the like. You could even add a few characters, and have the computer try to compile each 'book'. Then you'd end up with every computer programme! But it might take a little time and disk space :D
 

·
Registered
Joined
·
2,558 Posts
Gromit said:
Doesn't look like the script will be postable without removing indents :(

Code:
#!/bin/csh

set FUNC = `basename $0`
set START_TIME = `date`

set LTTR_ARY = ( a b c d e f g h i j k l m n o p q r s t u v w x y z )
set NUMB_ARY = ( 0 1 2 3 4 5 6 7 8 9 )
set CHAR_ARY = ( \  $LTTR_ARY[*] $NUMB_ARY[*] \, \. \? \" \' )

@ COMPLETE = 1

foreach LINE_CNT (`seq 1 40`)
  foreach CHAR_CNT (`seq 1 80`)
    @ X${LINE_CNT}${CHAR_CNT} = 1
  end
end

while ( $COMPLETE != 0 )

  foreach LINE_CNT (`seq 1 40`)
    foreach CHAR_CNT (`seq 1 80`)
      set VAL = `eval echo \$X${LINE_CNT}${CHAR_CNT}`
      echo -n "$CHAR_ARY[$VAL]"
    end

    echo
  end

  @ LINE_CNT = 1
  @ CHAR_CNT = 1
  @ NEXT_RDY = 1

  while ( $NEXT_RDY != 0 )
    @ X${LINE_CNT}${CHAR_CNT}++

    set VAL = `eval echo \$X${LINE_CNT}${CHAR_CNT}`

    if ( $VAL >= 43 ) then
      @ X${LINE_CNT}${CHAR_CNT} = 1
      @ CHAR_CNT++

      if ( $CHAR_CNT >= 81 ) then
        @ CHAR_CNT = 1
        @ LINE_CNT++

        if ( $LINE_CNT >= 41 ) then
          echo "$FUNC COMPLETE!"
          goto complete
        endif
      endif
    else
      @ NEXT_RDY = 0
    endif
  end
end

complete:

echo "$FUNC Started at : $START_TIME"
echo "$FUNC Finished at: `date`"

exit 0
use [ code ] and [ / code ] (no spaces)

Regards,
-Über Nerd
 
1 - 13 of 13 Posts
Top