[REBOL] Re: another sug*estion? /soft seeking ...
From: al:bri:xtra at: 29-Nov-2000 10:44
Petr Krenzelok wrote:
> I am not sure If I am alone missing the so called soft-seeking capability in REBOL?
What's the point?
> Let's assume the following series:
> blk: [1 2 3 6 7 8 9]
> find blk 4 returns currently none, but there are cases, when you want to return the
nearest value ...
> e.g. I have block of files built from dates:
> 20001101 2001102 2001105 ...
> the problem is - we don't download data on weekends. Then my user selects he wants
report starting at 1.1.2000, ending at 30.11.2000. But what if 1.1.2000 is a weekend
day? The search in block will not be succesfull ...
> If some kind of find/soft would exists, it could return the nearest value found ...
(the same behavior for /reverse seeking)
> The problem is our series can contain mixture of various datatypes ....
> So, is it even achievable?
> Hope someone understands what I want to express :-)
I've had a similar problem in generating reports on student attendance, and needing to
"miss out" weekends and public holidays. Here's how I do it.
Terms: [ ; 4 terms in New Zealand school year.
Holidays: [ ; Only these holidays are the ones that matter.
Term: make block! length? Terms
foreach [Start End] Terms [
append/only Term map exclude
iota Start End Holidays
func [Date [date!]] [
if any [
exit ; return unset! - so weekends aren't included.
'Term then ends up with only the dates that matter for student attendance.
Similarly for your reporting interval. What matters is that the dates from 1.1.2000 to
30.11.2000 are the ones reported. So:
Dates: iota 1/Jan/2000 30/Nov/2000
generates a block containing every date of interest. Then:
union Dates Report_Dates
gives the dates of interest.
I hope that helps! BTW, 'iota should be on my site.
Around here somewhere...