Skip to content

Instantly share code, notes, and snippets.

@feupeu
Last active October 29, 2015 18:19

Revisions

  1. feupeu revised this gist Oct 29, 2015. 1 changed file with 18 additions and 31 deletions.
    49 changes: 18 additions & 31 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,18 @@
    (define cal-start (new-time 2015 10 1 0 0)) ; Start of the calendar
    (define cal-end (new-time 2015 10 31 0 0)) ; End of the calendar

    (define time0 (new-time 2015 10 28 8 15)) ; PP first day start
    (define time1 (new-time 2015 10 28 16 30)) ; PP first day end

    (define time2 (new-time 2015 10 29 8 15)) ; PP second day start
    (define time3 (new-time 2015 10 29 16 30)) ; PP second day end

    (define time4 (new-time 2015 10 30 8 15)) ; PP third day start
    (define time5 (new-time 2015 10 30 16 30)) ; PP third day end

    (define time6 (new-time 2015 10 28 12 0)) ; first day lunch start
    (define time7 (new-time 2015 10 28 12 30)) ; first day lunch end

    (define time8 (new-time 2015 10 29 13 0)) ; second day lunch start
    (define time9 (new-time 2015 10 29 13 30)) ; second day lunch end

    (define time10 (new-time 2015 10 30 16 30)) ; third day lunch start
    (define time11 (new-time 2015 10 30 17 30)) ; third day lunch end

    (define app1 (new-appointment "PP - first day" time0 time1))
    (define app2 (new-appointment "PP - second day" time2 time3))
    (define app3 (new-appointment "PP - third day" time4 time5))

    (define app4 (new-appointment "Lunch" time6 time7))
    (define app5 (new-appointment "Lunch" time8 time9))
    (define app6 (new-appointment "Lunch" time10 time11))

    (define cal0 (new-calendar (list app4 app5 app6) '()))
    (define cal1 (new-calendar (list app1 app2 app3) cal0))
    (define (calendars-overlap? cal1 cal2)
    (ormap
    (lambda (app)
    (calendars-overlap-step app (cal-part cal2 APPOINTMENTS))
    )
    (cal-part cal1 APPOINTMENTS)
    )
    )

    (define (calendars-overlap-step app apps)
    (if [empty? apps]
    #f
    (or
    (appointments-overlap? app (car apps))
    (calendars-overlap-step app (cdr apps))
    )
    )
    )
  2. feupeu created this gist Oct 29, 2015.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    (define cal-start (new-time 2015 10 1 0 0)) ; Start of the calendar
    (define cal-end (new-time 2015 10 31 0 0)) ; End of the calendar

    (define time0 (new-time 2015 10 28 8 15)) ; PP first day start
    (define time1 (new-time 2015 10 28 16 30)) ; PP first day end

    (define time2 (new-time 2015 10 29 8 15)) ; PP second day start
    (define time3 (new-time 2015 10 29 16 30)) ; PP second day end

    (define time4 (new-time 2015 10 30 8 15)) ; PP third day start
    (define time5 (new-time 2015 10 30 16 30)) ; PP third day end

    (define time6 (new-time 2015 10 28 12 0)) ; first day lunch start
    (define time7 (new-time 2015 10 28 12 30)) ; first day lunch end

    (define time8 (new-time 2015 10 29 13 0)) ; second day lunch start
    (define time9 (new-time 2015 10 29 13 30)) ; second day lunch end

    (define time10 (new-time 2015 10 30 16 30)) ; third day lunch start
    (define time11 (new-time 2015 10 30 17 30)) ; third day lunch end

    (define app1 (new-appointment "PP - first day" time0 time1))
    (define app2 (new-appointment "PP - second day" time2 time3))
    (define app3 (new-appointment "PP - third day" time4 time5))

    (define app4 (new-appointment "Lunch" time6 time7))
    (define app5 (new-appointment "Lunch" time8 time9))
    (define app6 (new-appointment "Lunch" time10 time11))

    (define cal0 (new-calendar (list app4 app5 app6) '()))
    (define cal1 (new-calendar (list app1 app2 app3) cal0))