Recursive functions to find property

How can I write a recursive function to find a specific property such as 'bend' and once I find the first instance of the property I return the value and stop searching.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

...

fn findProperty node prop:#bend =
(
	local found = off, result
	for p in getPropNames node while found where (found = (p == prop)) do result = (getProperty node prop)
	result
)

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.