Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I get a layer ID by its position ? [Script-Fu]
#3
Oh thanks a lot !!
I'm beginner in Script-fu (Scheme) and carefully studied GIMP doc, and in the tutorial about the lists I see no mention of this function ! Big Grin 
They only speak about the use of car / cdr and compounds ... Angry (Which seemed so strange and absurdly complex...)


Quote:3.3.8. Accessing Other Elements In A List

OK, great, we can get the first element in a list, as well as the rest of the list, but how do we access the second, third or other elements of a list? There exist several "convenience" functions to access, for example, the head of the head of the tail of a list (caadr), the tail of the tail of a list (cddr), etc.

The basic naming convention is easy: The a's and d's represent the heads and tails of lists, so

Code:
(car (cdr (car x) ) )


could be written as:

Code:
(cadar x)


To get some practice with list-accessing functions, try typing in the following (except all on one line if you're using the console); use different variations of car and cdr to access the different elements of the list:

     
Code:
 (let* (
                (x  '( (1 2 (3 4 5) 6)  7  8  (9 10) )
                )
             )
             ; place your car/cdr code here
       )

     

Try accessing the number 3 in the list using only two function calls. If you can do that, you're on your way to becoming a Script-Fu Master!

Angry

So ... thanks again, all becomes so easy now ! ^^

Note : I really need that the script automatically use other layers ... it's part of the main purpose of my script (purpose of automating tasks, you know Tongue)
Reply


Messages In This Thread
RE: How can I get a layer ID by its position ? [Script-Fu] - by Nival - 07-22-2024, 04:05 AM

Forum Jump: