syllabus.js
// A Syllabus management class.
// Author: Matthew Might
// Site: http://matt.might.net/
function Syllabus (initYear,initMonth,initDate,topics,fixed) {
this.initYear = initYear ;
this.initMonth = initMonth - 1 ; // [1..12] -> [0..1]
this.initDate = initDate ;
this.topics = topics || [] ;
this.fixed = fixed || {} ;
this.createInitDate = function () {
var d = new Date() ;
d.setFullYear(this.initYear, this.initMonth, this.initDate) ;
// toQuasiLexicalDateString: String of the form "YYYY-[M]M-[D]D"
d.toQuasiLexicalDateString = function () {
return this.getFullYear() + "-" + (this.getMonth() + 1) + "-" + (this.getDate())
} ;
// nextDay: Increment this date to the next event day.
d.nextDay = function (days) {
this.setDate(this.getDate() + 1) ;
var max = 7 ;
while ((!days[this.getDay()]) && (max > 0)) {
this.setDate(this.getDate() + 1) ;
--max ;
}
} ;
return d ;
} ;
var eventDays = {} ;
this.setEventDay = function (dayOfWeek) {
if (dayOfWeek == "Sun") dayOfWeek = 0 ;
else if (dayOfWeek == "Mon") dayOfWeek = 1 ;
else if (dayOfWeek == "Tue") dayOfWeek = 2 ;
else if (dayOfWeek == "Wed") dayOfWeek = 3 ;
else if (dayOfWeek == "Thu") dayOfWeek = 4 ;
else if (dayOfWeek == "Fri") dayOfWeek = 5 ;
else if (dayOfWeek == "Sat") dayOfWeek = 6 ;
else if (dayOfWeek == "S") dayOfWeek = 0 ;
else if (dayOfWeek == "M") dayOfWeek = 1 ;
else if (dayOfWeek == "T") dayOfWeek = 2 ;
else if (dayOfWeek == "W") dayOfWeek = 3 ;
else if (dayOfWeek == "H") dayOfWeek = 4 ;
else if (dayOfWeek == "F") dayOfWeek = 5 ;
else if (dayOfWeek == "S") dayOfWeek = 6 ;
eventDays[dayOfWeek] = true ;
} ;
this.getEvents = function () {
var topics = this.topics.slice() ; // clone
var fixed = this.fixed ;
var events = [] ;
for (var d = this.createInitDate() ; topics.length > 0; d.nextDay(eventDays)) {
var topic ;
if (fixed[d.toQuasiLexicalDateString()]) {
topic = fixed[d.toQuasiLexicalDateString()] ;
} else {
topic = topics.shift() ;
}
events.push({ "date": d.toDateString(),
"topic": topic }) ;
}
return events ;
} ;
return this ;
}
Demo
With syllabus.js included, the following code:
var Topics = [
"Overview of static analysis" ,
"Syntax and semantics" ,
"Introduction to the lambda calculus" ,
"Small-step semantics and a-normal form (ANF)" ,
"Partial order theory" ,
"Abstract interpretation of small-step semantics" ,
"Continuation-passing style (CPS)",
"<i>k</i>-CFA by abstract interpretation" ,
"Big-step semantics" ,
"Constraint-based analyses (0CFA by constraints)" ,
"Intraprocedural analyses for imperative languages (I)" ,
"Intraprocedural analyses for imperative languages (II)" ,
"Interprocedural analysis for imperative languages" ,
"Static single-assignment form (SSA)" ,
"Alias analyses (Steensgard, Andersen)" ,
"Abstract garbage collection" ,
"Context sensitivity; flow sensitivity" ,
"Must-* analyses" ,
"Abstract interpretation (Galois theory)" ,
"Type-based analyses" ,
"Dependence analysis and automatic parallelization" ,
"Escape analysis" ,
"Predicate-/proposition-based abstractions" ,
"Numeric- and array-bounds analysis" ,
"Shape analysis" ,
"Case study: Analysis of unrestricted ANSI C (I)" ,
"Case study: Analysis of unrestricted ANSI C (II)"
] ;
var Fixed = {
"2009-1-20": "<b>TBD: Matt @ POPL</b>" ,
"2009-1-22": "<b>TBD: Matt @ POPL</b>" ,
"2009-3-17": "<b>Spring break</b>" ,
"2009-3-19": "<b>Spring break</b>"
} ;
var S = new Syllabus(2009,1,13,Topics,Fixed) ;
S.setEventDay("Tue") ;
S.setEventDay("Thu") ;
var Events = S.getEvents() ;
while (Events.length > 0) {
var e = Events.shift() ;
document.write("<tr><td>"+e.date+"</td><td>"+e.topic+"</td></tr>") ;
} generates the entries within this table:
| Date | Topic |
Twitter: @mattmight
Instagram: @mattmight
LinkedIn: matthewmight
Mastodon: @mattmight@mathstodon.xyz
Sub-reddit: /r/mattmight