|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Jim Henderson escribió:
> On Thu, 14 Feb 2008 13:07:07 -0200, Nicolas Alvarez wrote:
>
>> Invisible escribió:
>>> I have no idea whether this is actually executable or whether it does
>>> anything interesting, but somebody *clearly* has a lot of free time on
>>> their hands....
>>>
>>>
>> You haven't seen the International Obfuscated C Code Contest, have you?
>
> Do they still hold that? I remember examples from the past of things
> like a morse code translator and a source "picture" that was an ASCII
> train.
>
I remember one that read data from stdin, and outputted it reversed
(last character first). And the sourcecode of the program compiled if
you reverted its characters.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Thu, 14 Feb 2008 15:20:37 -0200, Nicolas Alvarez wrote:
> Jim Henderson escribió:
>> On Thu, 14 Feb 2008 13:07:07 -0200, Nicolas Alvarez wrote:
>>
>>> Invisible escribió:
>>>> I have no idea whether this is actually executable or whether it does
>>>> anything interesting, but somebody *clearly* has a lot of free time
>>>> on their hands....
>>>>
>>>>
>>> You haven't seen the International Obfuscated C Code Contest, have
>>> you?
>>
>> Do they still hold that? I remember examples from the past of things
>> like a morse code translator and a source "picture" that was an ASCII
>> train.
>>
>>
> I remember one that read data from stdin, and outputted it reversed
> (last character first). And the sourcecode of the program compiled if
> you reverted its characters.
I remember a couple that were like that - one that when compiled and was
fed the source code generated another program (in another language, IIRC)
that could then be compiled and run to translate the code into a third
language.
Jim
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Invisible <voi### [at] devnull> wrote:
> Warp wrote:
> > What language is that?
> It parses as valid Haskell.
I asked because 'let' sounded to me like an assignment, which is not
functional. (In many languages, eg. afaik lisp and scheme, 'let' is an
explicit variable assignment, and an admitted deviation from pure
functionality.)
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> I asked because 'let' sounded to me like an assignment, which is not
> functional.
I'm pretty sure you're right about Lisp. But in Haskell, it's not an
assignment - although it does look like one.
In Haskell, "let" introduced local variables. For example,
solve2 a b c =
let det2 = b*b - 4*a*c
det = sqrt det2
a2 = 2*a
in [(0-b-det)/a2, (0-b+det)/a2]
Now that looks pretty damn identical to the following JavaScript fragment:
function solve2(a, b, c)
{
var det2 = b*b - 4*a*c;
var det = Math.sqrt(det2);
var a2 = 2*a;
return Array((0-b-dat)/a2, (0-b+det)/a2));
}
So what's the difference? Well, let's try this:
function solve2(a, b, c)
{
var det = Math.sqrt(det2);
var det2 = b*b - 4*a*c;
var a2 = 2*a;
return Array((0-b-dat)/a2, (0-b+det)/a2));
}
Hmm, that's not going to work properly... However, the corresponding
Haskell works exactly as before:
solve2 a b c =
let det = sqrt det2
det2 = b*b - 4*a*c
a2 = 2*a
in [(0-b-det)/a2, (0-b+det)/a2]
So in Haskell, the ordering doesn't matter. But maybe you're not
convinced yet. OK, well try this:
foo x y =
let xs = x : ys
ys = y : xs
in xs
Notice how these definitions are muturally recursive. No matter which
way round you write this in JavaScript, it won't work properly:
function foo(x,y)
{
var xs = new Node(x, ys);
var ys = new Node(y, xs);
return xs;
}
But in Haskell it works just fine, and returns a circular linked list.
This works exactly because it's a definition, not an assignment.
(You'll also be unsurprised to hear that you're not allowed to define
the same name twice in a single let-block. But I wanted to emphasize
that the difference is much deeper than that.)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
whoa! Haskell is becoming another Perl or Brainf*ck.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
nemesis wrote:
> whoa! Haskell is becoming another Perl or Brainf*ck.
Nah. You can write increadibly cryptic stuff in *any* language. ;-)
I'm sure somebody could come up with some POV-Ray SDL like this if they
tried hard enough...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Invisible <voi### [at] devnull> wrote:
> (g,s) = (\x -> x, \x -> x*x)
>
> That last line is the best. I didn't even realise you could *do* that!
yes! very cool! Looks like Perl/Python 2 way assignment, but of course there's
no assignment here, it's 2 functions defined in the same line by 2 tuples!
Haskell is amazing...
> Very odd...
>
> Right, so, let's do some analysis here.
man, just run this madness and see what it does...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
nemesis wrote:
> Invisible <voi### [at] devnull> wrote:
>> (g,s) = (\x -> x, \x -> x*x)
>>
>> That last line is the best. I didn't even realise you could *do* that!
>
> yes! very cool! Looks like Perl/Python 2 way assignment, but of course there's
> no assignment here, it's 2 functions defined in the same line by 2 tuples!
> Haskell is amazing...
I should have realised that this was possible - I've just never seen it
at the top-level before.
It's kinda nice to be able to write things like
(a',b',c',d') = (b,c,d,a)
to do a rotation. All those C programmers are sitting there defining
temporary variables to handle the shuffle, while I can just tell the
compiler exactly what I want the end result to be, and it just does it...
Interestingly, the compiler infers some rather strange types for those
functions. Clearly \x -> x is id, yet the compiler infers a less general
type than this - presumably due to the tupling. Or perhaps to the other
call sites in the program, I'm not sure...
>> Very odd...
>>
>> Right, so, let's do some analysis here.
>
> man, just run this madness and see what it does...
And how do you suggest I do that, given that there's no obvious "entry
point"?
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:
> It's not obfuscated if it has readable function names.
I don't think readable means much when all you get is "un" or "po". You could
change those for kanji and it'd make about as much sense...
of course, you could try to guess: perhaps "un" is to unfoo something and "po"
to position something. not much better...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Thu, 14 Feb 2008 14:46:25 -0500, nemesis wrote:
> Brainf*ck.
Now there's a language I'm unfamiliar with - who wrote the book on that
one? ;-)
Jim
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |