Comment detail

指定された日の存在する週 (Nested Flatten)

Factor です。日付の出力部分がもっとなんとかなる気がするのですが。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
USING: kernel calendar sequences math.parser io ;

: write-date ( timestamp -- )
    dup timestamp-year number>string write "/" write
    dup timestamp-month number>string write "/" write
    dup timestamp-day number>string write "(" write
    day-of-week day-abbreviations3 nth write ")\n" write ;

: week-days ( year month day -- )
    make-date monday [ swap +day write-date ] curry 5 swap each ;

! example
2008 2 13 week-days
! 2008/2/11(Mon)
! 2008/2/12(Tue)
! 2008/2/13(Wed)
! 2008/2/14(Thu)
! 2008/2/15(Fri)

Index

Feed

Other

Link

Pathtraq

loading...