Lurker News
Preferably an elegant snippet rather than an entire (well engineered) codebase.

Comments (380) 116 threads

Earlier comments
tgvaughan#
I think this was the first line of the forth in the library of an older version of jonesforth (https://rwmj.wordpress.com/2010/08/07/jonesforth-git-reposit...), but now I can only find it in my port:

  : \ IMMEDIATE
        #IB @ >IN !
  ; \ We can now comment!
Implementing a forth system is unbelievably fun because of gems like this.
peterwwillis#
This number:

  4856507896573978293098418946942861377074420873513579240196520736 6869851340104723744696879743992611751097377770102744752804905883
  1384037549709987909653955227011712157025974666993240226834596619 6060348517424977358468518855674570257125474999648219418465571008
  4119086259716947970799152004866709975923596061320725973797993618 8606316914473588300245336972781813914797955513399949394882899846
  9178361001825978901031601961835034344895687053845208538045842415 6548248893338047475871128339598968522325446084089711197712769412
  0795862440547161321005006459820176961771809478113622002723448272 2493232595472346880029277764979061481298404283457201463489685471
  6908235473783566197218622496943162271666393905543024156473292485 5248991225739466548627140482117138124388217717602984125524464744
  5055834628144883356319027253195904392838737640739168912579240550 1562088978716337599910788708490815909754801928576845198859630532
  3823490558092032999603234471140776019847163531161713078576084862 2363702835701049612595681846785965333100770179916146744725492728
  3348691600064758591746278121269007351830924153010630289329566584 3662000800476778967984382090797619859493646309380586336721469695
  9750279687712057249966669805614533820741203159337703099491527469 1835659376210222006812679827344576093802030447912277498091795593
  8387121000588766689258448700470772552497060444652127130404321182 610103591186476662963858495087448497373476861420880529443
This is a 1811-digit illegal prime number, which when unpacked into binary, becomes a compressed ELF executable which will decrypt DVDs. This was one of many ways used to enable people who had legally purchased a DVD with copy protection to play it on Linux. Here's the story behind finding the prime: https://web.archive.org/web/20070223075434/http://asdf.org/~...

Aside from that, the qrpff perl scripts that became t-shirts (https://web.archive.org/web/20011221024307/http://www.copyle...) were another fun and illegal way to point out the stupidity of the DMCA. But they aren't so pretty ;)

YeGoblynQueenne#
This grammar of the aⁿbⁿ language in Prolog's Definite Clause Grammar syntactic sugar:

  s --> a,b.
  s --> a,s,b.
  a --> [a].
  b --> [b].
s is a non-terminal, a and b are preterminals, [a] and [b] are terminals and "-->" can be read as "expands to". The syntax is the same as BNF and the grammar is a Prolog program that is directly executable as both a recogniser or a generator, depending on instantiation pattern at call time.

How does the grammar work? It must accept, or generate, a string of equal numbers of a's and b's, but the grammar is not keeping track of the length. There is nothing to count how many a's have been consumed or produced so far. How does it know?
s is the start symbol of the grammar. The first production of s, which is also the terminating condition for the recursion, accepts or produces one a followed by one b. The second production of s accepts an a, followed by an s-string, followed by a b.
Suppose we executed the grammar as a generator. In the first step, the output would be the string S₁ = ab. In the second step, the output would be the string S₂ = aS₁b. In the n'th step the output would be aSₙb.
So the grammar would always add exactly one a at the start, and one be at the end of its output, recursively.
And it would always generate the same number of a's as b's.
Similar for when it runs as an acceptor.
You can visualise the first couple of steps as follows:

           S
   ,-------|-------.
   |       S       |
   A      / \      B
   |     A   B     |
   a     |   |     b
         a   b

Load more comments