POV-Ray : Newsgroups : povray.off-topic : Logic programming Server Time
6 Nov 2024 18:25:40 EST (-0500)
  Logic programming (Message 1 to 10 of 68)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Orchid XP v7
Subject: Logic programming
Date: 26 Mar 2008 15:02:14
Message: <47eaabc6$1@news.povray.org>
OK, so I realise absolutely nobody here will think this is in any way 
"neat" or "cleaver", but still...

I've managed to construct an interpretter for a kind of primitive logic 
programming language. Currently it's extremely hard to operate, and the 
output isn't very human-readable, but it can do some interesting stuff.

For example, suppose I define a function "join" as follows:

   join(x, y, z) =
     x = [] & y = z   ||   x = (t:ts1) & z = (t:ts2) & join(ts1,y,ts2)

In other words, either x is an empty list and y and z are equal, or the 
first element of x and z is the same and ... well, you can read.

Given this definition, typing join([1,2,3], [4,5,6], z) yields

   z = [1,2,3,4,5,6]

Which is obviously what the answer should be. However, the slightly 
bizare thing is that if I do join(x, [4,5,6], [1,2,3,4,5,6]), I get

   x = [1,2,3]

In other words, it can "un-join" the list. The join operator works 
backwards!

But that's not all. It gets weirder: join([1,2,3], y, [1,2,3,4,5,6] gives

   y = [4,5,6]

But now we come to the really mental part: join(x, y, [1,2,3]) yields

   x = [] & y = [1,2,3]   ||
   x = [1] & y = [2,3]    ||
   x = [1,2] & y = [3]    ||
   x = [1,2,3] & y = []

In other words, all *possible* ways that x and y could be set such that 
their join is [1,2,3]! How neat is that?

OK, I'll sit down now... :-/

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Jim Henderson
Subject: Re: Logic programming
Date: 26 Mar 2008 15:02:55
Message: <47eaabef$1@news.povray.org>
On Wed, 26 Mar 2008 20:02:28 +0000, Orchid XP v7 wrote:

> OK, so I realise absolutely nobody here will think this is in any way
> "neat" or "cleaver", but still...

Well, I don't know about "cleaver", but I'd go for "clever". ;-)

Jim


Post a reply to this message

From: Orchid XP v7
Subject: Re: Logic programming
Date: 26 Mar 2008 15:58:10
Message: <47eab8e2$1@news.povray.org>
Jim Henderson wrote:

> Well, I don't know about "cleaver", but I'd go for "clever". ;-)

Damn. I spent several hours implementing a piece of technology, and the 
only comment I receive is somebody telling me my spelling sucks. :-(

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Jim Henderson
Subject: Re: Logic programming
Date: 26 Mar 2008 16:24:30
Message: <47eabf0e$1@news.povray.org>
On Wed, 26 Mar 2008 20:58:24 +0000, Orchid XP v7 wrote:

> Jim Henderson wrote:
> 
>> Well, I don't know about "cleaver", but I'd go for "clever". ;-)
> 
> Damn. I spent several hours implementing a piece of technology, and the
> only comment I receive is somebody telling me my spelling sucks. :-(

Oh, come on - I was just twaking your nose, and it's only been 90 minutes 
since our original post. ;-)

And I *did* go for "clever" after all. ;-)

Jim


Post a reply to this message

From: Jim Henderson
Subject: Re: Logic programming
Date: 26 Mar 2008 16:26:12
Message: <47eabf74$1@news.povray.org>
On Wed, 26 Mar 2008 16:24:30 -0500, Jim Henderson wrote:

> twaking

s/twaking/tweaking/

McKean's law strikes again.....

Jim


Post a reply to this message

From: Warp
Subject: Re: Logic programming
Date: 26 Mar 2008 16:48:26
Message: <47eac4aa@news.povray.org>
Orchid XP v7 <voi### [at] devnull> wrote:
> I spent several hours implementing a piece of technology

  It sounded to me like you reinvented prolog...

-- 
                                                          - Warp


Post a reply to this message

From: Jim Henderson
Subject: Re: Logic programming
Date: 26 Mar 2008 17:00:46
Message: <47eac78e$1@news.povray.org>
On Wed, 26 Mar 2008 16:48:26 -0500, Warp wrote:

> Orchid XP v7 <voi### [at] devnull> wrote:
>> I spent several hours implementing a piece of technology
> 
>   It sounded to me like you reinvented prolog...

Sometimes, reimplementing something is the best way to learn - even if 
you didn't know it existed before.

I tried to learn Prolog once upon a time - ugly language to learn from 
what I recall (but I was a teenager at the time, I probably still have a 
copy of Turbo Prolog around here somewhere).

Jim


Post a reply to this message

From: St 
Subject: Re: Logic programming
Date: 26 Mar 2008 17:04:02
Message: <47eac852@news.povray.org>
"Jim Henderson" <nos### [at] nospamcom> wrote in message 
news:47eabf74$1@news.povray.org...
> On Wed, 26 Mar 2008 16:24:30 -0500, Jim Henderson wrote:
>
>> twaking
>
> s/twaking/tweaking/
>
> McKean's law strikes again.....

  No, "Sods Law" will suffice... ;)

    ~Steve~


>
> Jim


Post a reply to this message

From: Jim Henderson
Subject: Re: Logic programming
Date: 26 Mar 2008 17:07:29
Message: <47eac921$1@news.povray.org>
On Wed, 26 Mar 2008 22:03:54 +0000, St. wrote:

> "Jim Henderson" <nos### [at] nospamcom> wrote in message
> news:47eabf74$1@news.povray.org...
>> On Wed, 26 Mar 2008 16:24:30 -0500, Jim Henderson wrote:
>>
>>> twaking
>>
>> s/twaking/tweaking/
>>
>> McKean's law strikes again.....
> 
>   No, "Sods Law" will suffice... ;)

Well, maybe, but McKean's law is much more apropos to the situation, no?

Jim


Post a reply to this message

From: St 
Subject: Re: Logic programming
Date: 26 Mar 2008 17:25:20
Message: <47eacd50$1@news.povray.org>
"Jim Henderson" <nos### [at] nospamcom> wrote in message 
news:47eac921$1@news.povray.org...
> On Wed, 26 Mar 2008 22:03:54 +0000, St. wrote:
>
>> "Jim Henderson" <nos### [at] nospamcom> wrote in message
>> news:47eabf74$1@news.povray.org...
>>> On Wed, 26 Mar 2008 16:24:30 -0500, Jim Henderson wrote:
>>>
>>>> twaking
>>>
>>> s/twaking/tweaking/
>>>
>>> McKean's law strikes again.....
>>
>>   No, "Sods Law" will suffice... ;)
>
> Well, maybe, but McKean's law is much more apropos to the situation, no?

    True, true. But Sod's Law will always sneak in there at some point, so 
it's got to be relevant. I mean, at some stage when I'm composing an email 
or a reply post in OE and I type the word 'the', it will get repeated twice 
in a sentence - but I *know* I only typed the word once once once. (Joking. 
:) What a weird word 'once' is).

    Sods Law. Otherwise, something weird is going on.  :oO

     ~Steve~




>
> Jim


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.