Re: Euphoria 4.0.1
- Posted by mattlewis (admin) Mar 14, 2011
- 2492 views
petelomax: I quite agree with what you are saying. In fact, if you see my initial posts I said that that was the only way to do it. The problem comes when you try to expand the function to a business level (with several sequences or rather atoms), where you are forced to loop through each element of the sequences, and you are faced with a situation where you cannot loop though the sequences because some may arbitrarily and unknowingly be single elements.
Yes, algorithms often require checking to see whether you have a sequence or an atom. This is inherent in the nature of euphoria objects. If you look at published euphoria code, you'll find many examples. In a previous post, I used the standard library function sum() as a way to abstract this very issue:
public function sum(object a) atom b if atom(a) then return a end if b = 0 for i = 1 to length(a) do if atom(a[i]) then b += a[i] else b += sum(a[i]) end if end for return b end function
Sorry, I'm really not trying to beat a dead horse, but claims like "euphoria doesn't do what is says it does" need to be substantiated or proven false (or opened as a ticket, so we can fix a bug!). There's a big difference between that sort of statement and, "That's an interesting feature, but it's not really very useful to me in this context."
Matt