BlackBox Posted May 3, 2011 Posted May 3, 2011 yes yes i know ... he is already angry i guess Nawww, sarcasm, and strict direction is how you know he likes you. :wink: Quote
alanjt Posted May 3, 2011 Posted May 3, 2011 You big bully! Do your little girls know you're such a meany to new kids!? LoL Psh, they are mean to me. On a side note, funny story with my oldest (4yo): Me: stop picking your nose. Her: I'm not picking, I'm scratching. Me: If your finger is in your nose, you are picking it. Stop digging for gold! Her: I'm not digging for gold, I'm digging for boogers. Quote
BlackBox Posted May 3, 2011 Posted May 3, 2011 Psh, they are mean to me. [ATTACH]27357[/ATTACH] On a side note, funny story with my oldest (4yo): Me: stop picking your nose. Her: I'm not picking, I'm scratching. Me: If your finger is in your nose, you are picking it. Stop digging for gold! Her: I'm not digging for gold, I'm digging for boogers. Priceless ... :lol: lmfao Quote
SOliver Posted May 3, 2011 Posted May 3, 2011 i'm not that good with the lambda function but doeas this loop into the list actually this code worked but it return one list of all coordinates actually the first list is a list of four coordinate and the second list is a list of four points too i want to add the first four coordinate to eatch points of the secons list and return a list of 4 list in it i'm sorry i'm not that good in english ^^ Mapcar (carry out task on entire list and return new list) takes two parameters [sic] or more depending on the number of lists you want to respectively iterate through. The first is basically an inline function and the second is a list. That in mind when you use mapcar(carry... entire...) you are effectively for each item in this list (second param) carry out this function. the main difference between foreach and mapcar is that mapcar retains the list structure passed to it - unless you pass more than one list in which case it probably (never tested) returns a list at the length of the largest list passed in the mapcar arguement. In this case the second mapcar call returns the list manipulated values from the lCoord list as a list...... Before I use the word list too much, the first mapcar returns the list of each list created from lCoord li..... using the translate function. (setq k -1) (while (< (setq k(1+ k)) Lins) (setq j -1) ;Added line--- (setq nvList nil) ;------------ (while ( < (setq j(1+ j)) Lcord) (setq tran (translate (nth k ptinslist)(nth j li))) (setq nvlist (append nvlist (list tran))) ) (setq all (append all (list nvlist)) ) The above needed a line to clean the nvList at the start of each sub-iteration. Quote
alanjt Posted May 3, 2011 Posted May 3, 2011 I'm feeling lost to your request. Could you post a larger list of coordinates so we have a better idea of what's going on? Quote
yajis_narif Posted May 3, 2011 Author Posted May 3, 2011 thank you so much SOliver it worked it did solve the problem i really apriciate your help and thank you alantj i hope SLW210 didn't got angry Quote
alanjt Posted May 3, 2011 Posted May 3, 2011 Always happy to not help. I completely misunderstood what you were asking. Good think SOliver stepped and comprehended your issue. Quote
SOliver Posted May 3, 2011 Posted May 3, 2011 thank you so much SOliver it worked it did solve the problem i really apriciate your help You're welcome yajis_narif As an ending note: a lot of lisp programmers frown upon the use of while loop iterators that mimic for loop functionality from other languages - In this case I also am of that belief, however; don't be discouraged from it's use. Situations arise where you may want to terminate the iteration of a list once certain criteria has been met - in these cases rock on with the while loop iteration. Quote
SOliver Posted May 3, 2011 Posted May 3, 2011 Always happy to not help. I completely misunderstood what you were asking. Good think SOliver stepped and comprehended your issue. Hehe I'm not sure if I comprehended the question or just covered every eventuality; either way we got there in the end . Quote
alanjt Posted May 3, 2011 Posted May 3, 2011 You're welcome yajis_narif As an ending note: a lot of lisp programmers frown upon the use of while loop iterators that mimic for loop functionality - In this case I also am of that belief, however; don't be discouraged from it's use. Situations arise where you may want to terminate the iteration of a list once certain criteria has been met - in these cases rock on with the while loop iteration. It's just a lot more effort for a similar payoff from mapcar, mapcar+lambda or foreach and creating a new list of items. Quote
alanjt Posted May 3, 2011 Posted May 3, 2011 Hehe I'm not sure if I comprehended the question or just covered every eventuality; either way we got there in the end . That's all that matters. Quote
SOliver Posted May 3, 2011 Posted May 3, 2011 It's just a lot more effort for a similar payoff from mapcar, mapcar+lambda or foreach and creating a new list of items. In most cases that is the case although if you're iterating through a large list, let's say a thousand items, and the criteria is met on item five; it makes sense to be able to say (setq i (length listInQuestion)) instead of having to continue the iteration anyway. The foreach function in any language (particularly php grrr...) is my pet hate. I'd sooner cut off my hands than use it unless it's the last choice. Quote
alanjt Posted May 3, 2011 Posted May 3, 2011 In most cases that is the case although if you're iterating through a large list, let's say a thousand items, and the criteria is met on item five; it makes sense to be able to say True, that will stop if a once a criteria is met, the iteration stops. Of course, I'd take the VL route and use vl-some or vl-every. Quote
SOliver Posted May 3, 2011 Posted May 3, 2011 True, that will stop if a once a criteria is met, the iteration stops. Of course, I'd take the VL route and use vl-some or vl-every. Something new every day. I've never used the vl-some function before. It appears that would usually be the best port of call unless you need the list item index, which I suppose in most cases you could use vl-position to get (then again there may be more than on instance of the same item). On saying that I might just be overly protective of my beloved for loop vl-every seems rather peculiar; I suppose there will be some fairly prominent cases for it's use though. Quote
alanjt Posted May 3, 2011 Posted May 3, 2011 vl-position is only good to check an item directly in a list, beyond that, you would need to apply functions to the list using vl-some, vl-every, vl-member-if, etc. eg. (vl-position "A" '("A" "B" "C")) --> 0 Quote
Lee Mac Posted May 3, 2011 Posted May 3, 2011 (mapcar '(lambda (a b) (apply 'mapcar (cons '+ (list a b)))) ptinlist li ) Surely listing the 'a' and 'b' is redundant. (mapcar '(lambda ( a b ) (mapcar '+ a b)) ptinlist li) Quote
alanjt Posted May 3, 2011 Posted May 3, 2011 Surely listing the 'a' and 'b' is redundant. (mapcar '(lambda ( a b ) (mapcar '+ a b)) ptinlist li) LoL, wow. I'm even more horrible. Today is NOT my day for coding. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.