newest: func [
{Returns the target with the most recent modification. Targets must be
file! or URL! values. If multiple targets have the same timestamp, the
last one found will be considered the newest.}
targets [any-block!]
; /local newest-date tgt-date result
/local result
][
; Take 1
; newest-date: 1-Jan-0000
; foreach target targets [
; if greater-or-equal? tgt-date: modified? target newest-date [
; newest-date: tgt-date
; result: target
; ]
; ]
; result
; Take 2 - No optimization for checking timestamps multiple times
; but much clearer.
result: first targets
foreach target next targets [
result: newer target result
]
result
]