Try Doing This in C!!

G

grahamcooper7

PROGRAM LIST
X 1 = A [ # I ] B [ # K ] :-
@ A [ # I ] R
@ B [ # K ] R
X 2 lockup
X 3 @ clients [ # 1 ] tom
X 4 @ clients [ # 4 ] fred
X 5 %
X 6 @ managers [ # 2 ] jan
X 7 @ managers [ # 3 ] tom
X 8 %
X 9 @ postcodes [ # perth ] 6000
X 10 @ postcodes [ # brisbane ] 4000




TRACE
= managers [ # 3 ] WHICHARRAY [ # WHICHINDEX ] ?

HEAD 1
= A [ # I ] B [ # K ]
TAIL 1
@ A # I R
@ [ managers ] # [ 3 ] R
HEAD 1
@ managers [ # 3 ] tom
MATCH
TRUE 1
TAIL 2
@ B # K R
@ B # K [ tom ]
HEAD 1
@ clients [ # 1 ] tom
MATCH
TRUE 2
MATCH




= managers [ # 3 ] WHICHARRAY [ # WHICHINDEX ] ?

WHICHARRAY = clients
WHICHINDEX = 1







Talk about a Reverse Array Lookup!


Herc
 
J

James Kuyper

PROGRAM LIST
X 1 = A [ # I ] B [ # K ] :-
@ A [ # I ] R
@ B [ # K ] R
X 2 lockup
X 3 @ clients [ # 1 ] tom
X 4 @ clients [ # 4 ] fred
X 5 %
X 6 @ managers [ # 2 ] jan
X 7 @ managers [ # 3 ] tom
X 8 %
X 9 @ postcodes [ # perth ] 6000
X 10 @ postcodes [ # brisbane ] 4000

TRACE
= managers [ # 3 ] WHICHARRAY [ # WHICHINDEX ] ?

HEAD 1
= A [ # I ] B [ # K ]
TAIL 1
@ A # I R
@ [ managers ] # [ 3 ] R
HEAD 1
@ managers [ # 3 ] tom
MATCH
TRUE 1
TAIL 2
@ B # K R
@ B # K [ tom ]
HEAD 1
@ clients [ # 1 ] tom
MATCH
TRUE 2
MATCH

= managers [ # 3 ] WHICHARRAY [ # WHICHINDEX ] ?

WHICHARRAY = clients
WHICHINDEX = 1

Talk about a Reverse Array Lookup!

I'm not familiar with the language that's written in; you can reasonably
assume that this is also true of many other people monitoring this
newsgroup, given that it's a newsgroup devoted to C. Whatever language
that is, it's not sufficiently self-explanatory to justify leaving out
the explanation. Could you therefore please explain exactly what it
does? I could probably make a reasonable guess if I put more time into
studying it - but I shouldn't have to.
 
G

grahamcooper7

PROGRAM LIST
X 1 = A [ # I ] B [ # K ] :-
@ A [ # I ] R
@ B [ # K ] R
X 2 lockup
X 3 @ clients [ # 1 ] tom
X 4 @ clients [ # 4 ] fred
X 6 @ managers [ # 2 ] jan
X 7 @ managers [ # 3 ] tom
X 9 @ postcodes [ # perth ] 6000
X 10 @ postcodes [ # brisbane ] 4000

= managers [ # 3 ] WHICHARRAY [ # WHICHINDEX ] ?
HEAD 1
= A [ # I ] B [ # K ]
@ A # I R
@ [ managers ] # [ 3 ] R
@ managers [ # 3 ] tom

TRUE 1
@ B # K R
@ B # K [ tom ]
@ clients [ # 1 ] tom

TRUE 2

= managers [ # 3 ] WHICHARRAY [ # WHICHINDEX ] ?
WHICHARRAY = clients
WHICHINDEX = 1

Talk about a Reverse Array Lookup!



I'm not familiar with the language that's written in; you can reasonably

assume that this is also true of many other people monitoring this

newsgroup, given that it's a newsgroup devoted to C. Whatever language

that is, it's not sufficiently self-explanatory to justify leaving out

the explanation. Could you therefore please explain exactly what it

does? I could probably make a reasonable guess if I put more time into

studying it - but I shouldn't have to.




Right, I'm using LISP style brackets on PROLOG code, which incidentally
works great on the 'recursive descent into sub-terms' style of PROLOG evaluation/pattern matching.



So in ISO Prolog it's.


eq ( ARRAY1, key( INDEX1 ) , ARRAY2 , key( INDEX2 ) ) :-
array ( ARRAY1, key ( INDEX1 ) , RESULT ) ,
array ( ARRAY2, key ( INDEX2 ) , RESULT ) .


array( clients( key(1) , tom ) ).
array( clients( key(2) , jan ) ).

array( managers( key(1) , herc ) ).
array( managers( key(3) , tom ) ).

array( postcodes( key(perth) , 6000 ) ).
array( postcodes( key(brisbane) , 4000 ) ).



?- eq( managers , key(3) , WHICHARRAY , key(WHICHINDEX ) ).

PROLOG>
WHICHARRAY = clients
WHICHINDEX = 1




---------

Like I said..


@ clients [ # 1 ] tom
@ clients [ # 4 ] fred

is easier for data entry!!

I can add INFIX notation and IF THEN aswell...
ISO prolog uses 'negation as failure' rather than just 'ELSE' !


IF
managers[# 3] = group-leader[# detroit X ]
THEN
ACTIVITY = X
FI



PROLOG was the 1st RDB before SQL.


'@' and '#' are just 'a' and 'b'



http://phpprolog.com/demo/PROLOG-ARRAYS.png
EDITED!




Herc
 
J

James Kuyper

PROGRAM LIST
X 1 = A [ # I ] B [ # K ] :-
@ A [ # I ] R

You're using Google Group's broken interface to usenet. One of the key
things that's broken about it is that it inserts an extra line break
after each line in quoted text. You should get a proper newsreader (I
like Mozilla Thunderbird, but there's many to choose from) and sign up
to gain access to a proper news server (I recommend
eternal-september.org). However, if you insist on using Google Groups,
please remove the double spacing from quoted text before you send it.

....
Right, I'm using LISP style brackets on PROLOG code, which incidentally
works great on the 'recursive descent into sub-terms' style of PROLOG evaluation/pattern matching.

So in ISO Prolog it's.

eq ( ARRAY1, key( INDEX1 ) , ARRAY2 , key( INDEX2 ) ) :-
array ( ARRAY1, key ( INDEX1 ) , RESULT ) ,
array ( ARRAY2, key ( INDEX2 ) , RESULT ) .
....

Again - I'm sure if I studied your prolog version hard enough, I could
probably figure it out, but I shouldn't have to, and I have no intention
of trying. You're the one who decided to bring this to a C-oriented
newsgroup, so it's your responsibility to translate it. Ideally, you
should translate it to C, but your Subject: header implies that you
don't think it can easily be expressed in C. That's a reasonable thing
to claim, and it might even be true - but in that case you should
translate it into English. Not PHP, not Python, not Ruby, not Visual
Basic, not Delphi - it should either be C or English, because those are
the only two languages you can be reasonable sure that everyone
monitoring this newsgroup knows.

You might be able to get way with java, C++, perl, or C#, because of
their similarities with C - but only insofar as they are similar. If you
could write it in, for instance, java code that was sufficiently similar
to C code to justify posting it here, you could (and therefore should)
write it in C, instead, which is what you're claiming is difficult.
 
G

grahamcooper7

On 09/30/2013 08:32 PM, (e-mail address removed) wrote:

PROGRAM LIST

X 1 = A [ # I ] B [ # K ] :-

@ A [ # I ] R



You're using Google Group's broken interface to usenet. One of the key

things that's broken about it is that it inserts an extra line break

after each line in quoted text. You should get a proper newsreader (I

like Mozilla Thunderbird, but there's many to choose from) and sign up

to gain access to a proper news server (I recommend

eternal-september.org). However, if you insist on using Google Groups,

please remove the double spacing from quoted text before you send it.



...
Right, I'm using LISP style brackets on PROLOG code, which incidentally
works great on the 'recursive descent into sub-terms' style of PROLOG evaluation/pattern matching.

So in ISO Prolog it's.

eq ( ARRAY1, key( INDEX1 ) , ARRAY2 , key( INDEX2 ) ) :-
array ( ARRAY1, key ( INDEX1 ) , RESULT ) ,
array ( ARRAY2, key ( INDEX2 ) , RESULT ) .

...



Again - I'm sure if I studied your prolog version hard enough, I could

probably figure it out, but I shouldn't have to, and I have no intention

of trying. You're the one who decided to bring this to a C-oriented

newsgroup, so it's your responsibility to translate it. Ideally, you

should translate it to C, but your Subject: header implies that you

don't think it can easily be expressed in C. That's a reasonable thing

to claim, and it might even be true - but in that case you should

translate it into English. Not PHP, not Python, not Ruby, not Visual

Basic, not Delphi - it should either be C or English, because those are

the only two languages you can be reasonable sure that everyone

monitoring this newsgroup knows.



You might be able to get way with java, C++, perl, or C#, because of

their similarities with C - but only insofar as they are similar. If you

could write it in, for instance, java code that was sufficiently similar

to C code to justify posting it here, you could (and therefore should)

write it in C, instead, which is what you're claiming is difficult.


OK... this is EQUALS


= A [ # I ] B [ # K ] :-
@ A [ # I ] R
@ B [ # K ] R


It's solved with pattern matching.

You enter a QUERY

= clients [ # I ] managers [ # K ]

and it performs a binary search on all facts in the database
starting with @

@ A [ # I ] R

with 'clients' in position A




You ENTER arrays like so:

@ clients [ # 1 ] tom
@ clients [ # 4 ] fred

@ managers [ # 2 ] jan
@ managers [ # 3 ] tom



this is:

clients[1] = 'tom'
clients[2] = 'fred'




Now, watch as I use a 3 line definition of equals
to do a reverse array lookup!


TRACE
= managers [ # 3 ] WHICHARRAY [ # WHICHINDEX ] ?

HEAD 1
= A [ # I ] B [ # K ]
TAIL 1
@ A # I R
@ [ managers ] # [ 3 ] R
HEAD 1
@ managers [ # 3 ] tom
MATCH
TRUE 1
TAIL 2
@ B # K R
@ B # K [ tom ]
HEAD 1
@ clients [ # 1 ] tom
MATCH
TRUE 2
MATCH



WHICHARRAY = clients
WHICHINDEX = 1







If you can, in C, try doing this!


if (clients[3] = X[Y]) then
printf X
printf Y



Herc
 
B

BruceS

On 10/04/2013 07:45 PM, (e-mail address removed) wrote:
<snip>

Just to save people a little time, I'll weigh in here. I'm familiar
with Mr. Cooper. He's a paranoid schizophrenic, who believe he has
various magical powers. Any attempts he makes at code are going to be
sophomoric at best, and more likely just laughable. If you're
interested in attempting to teach him a little bit of software
development, or the C language, good for you. On the other hand, don't
be too disappointed when he turns out to be a total loon.

Oh, and Graham, you still owe Brad $1,000, and you should not threaten
to poison random people's food. Please take your meds, and stop
pestering the good folks of c.l.c. until you begin to enter into the
first edges of understanding of the C language, or at least of software
development in general. Thank you.
 
G

grahamcooper7

On 10/04/2013 07:45 PM, (e-mail address removed) wrote:

<snip>



Just to save people a little time, I'll weigh in here. I'm familiar

with Mr. Cooper. He's a paranoid schizophrenic, who believe he has

various magical powers. Any attempts he makes at code are going to be

sophomoric at best, and more likely just laughable. If you're

interested in attempting to teach him a little bit of software

development, or the C language, good for you. On the other hand, don't

be too disappointed when he turns out to be a total loon.



Oh, and Graham, you still owe Brad $1,000, and you should not threaten

to poison random people's food. Please take your meds, and stop

pestering the good folks of c.l.c. until you begin to enter into the

first edges of understanding of the C language, or at least of software

development in general. Thank you.



says Bruce the Penne & Teller fanatic who LOST a mindreading test against me
and has pestered me ever since!


http://tinyurl.com/1stMindreadingTest
OK, here it is:

Trial 1 was a miss, but you changed the protocol after that, so I'll
skip it.

A: Original question "Will I find a property in the Southeast to buy
before March, 2011?"
Trial 5
Your guesses: 5, including the right one.

That makes 7 "hits" and 4 "misses" out of the 11 trials.
....about a 5.5% chance of
doing at least that well.






BruceS makes his own Home Brew in Trailer Parks! (and usually posts pissed!)


He owns a Porche outright! by still owing most of his house mortgage!
and pays it off with mostly between work contracts of
CAD MACROS!!!!


Meanwhile... WESTERN MINING CORPORATION, DRILLEX, MINEPRO
and B.G.C. 5 of the biggest Mining Companies in Australia are
all running my database software.


Herc
--
I've been quite clear that I did not live in a trailer park
when I was a "young lad". I lived in one years ago, as an adult.
BruceS (aus.tv)





BTW! this isn't the last you'll hear on Bruce about me...
now his slander gets real sinister! just tune out... he's a geriatric
skeptic sleuth wannabe who thinks he passed the Triple 9 society entrance
and has stalked me to every group on usenet for 6 years.
 
B

BruceS

says Bruce the Penne & Teller fanatic who LOST a mindreading test against me
and has pestered me ever since!


http://tinyurl.com/1stMindreadingTest
OK, here it is:

Trial 1 was a miss, but you changed the protocol after that, so I'll
skip it.

A: Original question "Will I find a property in the Southeast to buy
before March, 2011?"
Trial 5
Your guesses: 5, including the right one.

That makes 7 "hits" and 4 "misses" out of the 11 trials.
...about a 5.5% chance of
doing at least that well.






BruceS makes his own Home Brew in Trailer Parks! (and usually posts pissed!)


He owns a Porche outright! by still owing most of his house mortgage!
and pays it off with mostly between work contracts of
CAD MACROS!!!!


Meanwhile... WESTERN MINING CORPORATION, DRILLEX, MINEPRO
and B.G.C. 5 of the biggest Mining Companies in Australia are
all running my database software.


Herc
--
I've been quite clear that I did not live in a trailer park
when I was a "young lad". I lived in one years ago, as an adult.
BruceS (aus.tv)





BTW! this isn't the last you'll hear on Bruce about me...
now his slander gets real sinister! just tune out... he's a geriatric
skeptic sleuth wannabe who thinks he passed the Triple 9 society entrance
and has stalked me to every group on usenet for 6 years.

Thank you, Graham. I think you've demonstrated your mental illness
better than I could. As for your claims about me, I find them amusing
for the most part, so I'll let the gross inaccuracies go on this one.
 
G

grahamcooper7

Thank you, Graham. I think you've demonstrated your mental illness

better than I could. As for your claims about me, I find them amusing

for the most part, so I'll let the gross inaccuracies go on this one.




The only MENSA-ERSQUE faculty you exhibit is perpetually twisting
all of your assertions into obscure Boulderdash and splitting hairs
on the factual claims about you in some game of ambiguity in the
reverse fashion.

I guess "BUYING A PORCHE OUTRIGHT!" while claiming unemployment benefits
and still paying off your mortgage could do that!

Meanwhile I have $XX,XXX international wires to work on today..

Herc
 
B

BruceS

As this is completely OT here, I've responded in a more appropriate ng.
Graham, you know where. Nobody else here cares.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top