31 Dec, 2008, Tyche wrote in the 21st comment:
Votes: 0
I kind of solved it this way:

the cdr of ((((1 2)(3 4))((5 6)(7 8)))(((9 10)(11 12))((13 14)(15 16)))) is (((9 10)(11 12))((13 14)(15 16)))
the car of (((9 10)(11 12))((13 14)(15 16))) is ((9 10)(11 12))
the cdr of ((9 10)(11 12)) is (11 12)
the car of (11 12) is 11

Maybe that's backwards?
31 Dec, 2008, quixadhal wrote in the 22nd comment:
Votes: 0
Tyche is correct, it's 11. And yes, it's mostly just counting parens correctly. I could have used the "super paren" to make it more interesting I guess. ((1 2)(3 4]

At least it wasn't prolog.
Yes.
31 Dec, 2008, David Haley wrote in the 23rd comment:
Votes: 0
Actually, I think I'm correct – stick it into an interpreter :-)

$ clisp
i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
——+—— ooooo 8oooooo ooo8ooo ooooo 8

Welcome to GNU CLISP 2.44.1 (2008-02-23) <http://clisp.cons.org/>;

Copyright © Bruno Haible, Michael Stoll 1992, 1993
Copyright © Bruno Haible, Marcus Daniels 1994-1997
Copyright © Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright © Bruno Haible, Sam Steingold 1999-2000
Copyright © Sam Steingold, Bruno Haible 2001-2008

Type :h and hit Enter for context help.

[1]> (cadadr '((((1 2)(3 4))((5 6)(7 8)))(((9 10)(11 12))((13 14)(15 16)))))
((13 14) (15 16))
[2]>


Nah. :tongue:

Because of how you're nesting pairs within pairs and all that, you need to be careful with how you remove parentheses.

Let me show an example where you guys go wrong with your cdr:

Quote
the cdr of ((9 10)(11 12)) is (11 12)


In fact, the cdr is ((11 12)). Going back to the interpreter:

[5]> (cdr '((9 10)(11 12)))
((11 12))


In this case, the cdr is defined as the list containing the tail of the argument. The tail of the argument is the list containing the single element (11 12), and therefore, the cdr is ((11 12)).

Had you actually made your structures cons'es, you would have been correct:

[8]> (cdr (cons '(9 10) '(11 12)))
(11 12)


In this case, the cdr returns the second element of the pair, and not the list containing the tail.



EDIT: oh, and Prolog isn't that bad at all, really… I actually kind of like it (after having gotten used to it of course).
31 Dec, 2008, David Haley wrote in the 24th comment:
Votes: 0
Giving an example of cons vs. non-cons:

$ lisp
CMU Common Lisp CVS 19d 19d-release (19D), running on binarygoblin
With core: /usr/lib/cmucl/lisp.core
Dumped on: Fri, 2007-10-19 07:07:02-04:00 on binarygoblin
For support see http://www.cons.org/cmucl/support.html Send bug reports to the debian BTS.
or to pvaneynd@debian.org
type (help) for help, (quit) to exit, and (demo) to see the demos

Loaded subsystems:
Python 1.1, target Intel x86
CLOS based on Gerd's PCL 2004/04/14 03:32:47
* (cdr '(1 2))

(2)
* (cdr (cons 1 2))

2
31 Dec, 2008, quixadhal wrote in the 25th comment:
Votes: 0
Heh, well… I guess I can't save myself since I only exempted syntax errors, not usage errors.
I forgot that those wrapped the results in a list. :)
31 Dec, 2008, David Haley wrote in the 26th comment:
Votes: 0
It could be a notational issue. I know of some notations that strictly enforce pair notation for everything except function calls, so the list 1 2 3 is represented not as (1 2 3) but as (1 (2 3)), and the list 1 2 3 4 is (1 (2 (3 4))). In that notation, where everything is a cons, car/cdr are taken to work as you were expecting. But I believe that this is a fairly old notation, from back when car/cdr actually meant what their names mean, and more recent notations allow arbitrary-length lists – in that case the cdr is the list containing all elements other than the first.
31 Dec, 2008, Skol wrote in the 27th comment:
Votes: 0
Back to the OP, maybe make a different function, get_pc_world(), same function with a bool for !IS_NPC (or however Smaug does it).
Or, just change get_char_world to something like:
get_char_world(CHAR_DATA *ch, argument, bool is_npc), though that'd require you to change all instances of the function.
31 Dec, 2008, David Haley wrote in the 28th comment:
Votes: 0
I think it makes sense to add a new function called get_pc_world or something like that. I don't think it would be correct to force the choice of NPC or not, because often you want the character whose name is 'x' regardless of PC/NPC status.
31 Dec, 2008, Skol wrote in the 29th comment:
Votes: 0
Yeah it's a pretty 'singular' use it seems.
02 Jan, 2009, Sharmair wrote in the 30th comment:
Votes: 0
Skol said:
Back to the OP, maybe make a different function, get_pc_world(), same function with a bool for !IS_NPC (or however Smaug does it).
Or, just change get_char_world to something like:
get_char_world(CHAR_DATA *ch, argument, bool is_npc), though that'd require you to change all instances of the function.

SMAUG (and maybe other code bases) already has a way of getting only players with get_char_world (and
like functions). If you use the syntax '0.name' it will return a player with the name.
02 Jan, 2009, Skol wrote in the 31st comment:
Votes: 0
Ah, so there's Zeno's answer right?
02 Jan, 2009, Zeno wrote in the 32nd comment:
Votes: 0
Sharmair said:
Skol said:
Back to the OP, maybe make a different function, get_pc_world(), same function with a bool for !IS_NPC (or however Smaug does it).
Or, just change get_char_world to something like:
get_char_world(CHAR_DATA *ch, argument, bool is_npc), though that'd require you to change all instances of the function.

SMAUG (and maybe other code bases) already has a way of getting only players with get_char_world (and
like functions). If you use the syntax '0.name' it will return a player with the name.


I think, but the function checks partial matches. So what if I have a mob named 0.mailman.bot and a player named Mai?
03 Jan, 2009, Sharmair wrote in the 33rd comment:
Votes: 0
Zeno said:
I think, but the function checks partial matches. So what if I have a mob named 0.mailman.bot and a player named Mai?

If you use 0.Mai it will only match a player with the name Mai or possibly a player with a name Mai will
prefix into (only if Mai is not found - but this issue you would have anyway). If you use any periods in
a name, you probably will have to use the number-dot-name syntax to match all the time (other then
using vnum). Like in your case you would probably have to use something like '1.0.mailman.bot', otherwise
the number_argument() will break the original down to 0 number and mailman.bot name, which would
not match your mob.

In case I am not clear on what I mean by the number-dot-name syntax, I mean like what you would use
if you had a bad encounter with a mob and died a few times. To get your stuff from more then one
corpse, you would use 'get all corpse', ' get all 2.corpse', 'get all 3.corpse' etc.
03 Jan, 2009, Baiou wrote in the 34th comment:
Votes: 0
Ok I kind of jumped into this late, but let me see if I can help.

I could be wrong but it looks like you're checking to see if the current character is NPC and not checking the result of get_char_world… Assuming the roster is the target you're looking for, and it is of type CHAR_DATA, then you'd have to check IS_NPC against roster after calling get_char_world.
03 Jan, 2009, Zeno wrote in the 35th comment:
Votes: 0
Baiou said:
Ok I kind of jumped into this late, but let me see if I can help.

I could be wrong but it looks like you're checking to see if the current character is NPC and not checking the result of get_char_world… Assuming the roster is the target you're looking for, and it is of type CHAR_DATA, then you'd have to check IS_NPC against roster after calling get_char_world.


Not sure what you're trying to say. I already said what I need to do in the first post and it's the opposite of IS_NPC.
03 Jan, 2009, Baiou wrote in the 36th comment:
Votes: 0
yes, you want to use !IS_NPC but not with 'ch'… you want to use it with what is returned by get_char_world. get_char_world is usually used in this way…

victim = get_char_world( ch, "puff" );


Using that scenario, you should be checking whether or not 'victim' is an NPC, instead of checking if 'ch' is or isn't.
03 Jan, 2009, Zeno wrote in the 37th comment:
Votes: 0
Quote
yes, you want to use !IS_NPC but not with 'ch


Which is what I already said…
Zeno said:
Although it's pointless to check !IS_NPC on ch.


Quote
Using that scenario, you should be checking whether or not 'victim' is an NPC, instead of checking if 'ch' is or isn't.

That wasn't the question I asked in the first post, which is why the topic was started. I know how to assign it to CHAR_DATA and the sort.
03 Jan, 2009, Baiou wrote in the 38th comment:
Votes: 0
I apologize. I read from first post to last and there was mentioning of mobs showing up when used and I didn't see that resolved. Like I said, I jumped in late. Was just trying to help.
20.0/38