Jump to content

Recommended Posts

Posted
yes yes i know ... he is already angry i guess :sweat:

 

Nawww, sarcasm, and strict direction is how you know he likes you. :wink:

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    15

  • SOliver

    8

  • yajis_narif

    8

  • BlackBox

    3

Popular Days

Top Posters In This Topic

Posted Images

Posted
You big bully! Do your little girls know you're such a meany to new kids!? :lol: LoL

Psh, they are mean to me. spank.gif

 

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.

Posted
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::lol::lol: lmfao

Posted
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.

Posted

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?

Posted

thank you so much SOliver

it worked it did solve the problem i really apriciate your help :thumbsup:

 

and thank you alantj i hope SLW210 didn't got angry :D

Posted

Always happy to not help. :)

 

I completely misunderstood what you were asking. Good think SOliver stepped and comprehended your issue.

Posted
thank you so much SOliver

it worked it did solve the problem i really apriciate your help :thumbsup:

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.

Posted
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 .

Posted
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.
Posted
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. smiley_cheering.gif

Posted
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.

Posted
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.

Posted
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 :whistle:

 

vl-every seems rather peculiar; I suppose there will be some fairly prominent cases for it's use though.

Posted

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

Posted
(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)

Posted
Surely listing the 'a' and 'b' is redundant.

 

(mapcar '(lambda ( a b ) (mapcar '+ a b)) ptinlist li)

LoL, wow. I'm even more horrible. embarrassed_smiley.gif

 

Today is NOT my day for coding.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...