Not much to this, just something that popped up on a little throwaway project.
I've come up with a design for a printable baseball schedule for <team of your choice>. Not to dwell on the specifics, it takes a team's schedule for given year and produces an SVG (and subsequently PDF) with opposing teams, dates, times (for upcoming games), wins and losses (for games that are completed).
Amongst the parameters are team, year, page size, and time zone (A4 or Letter, time zone—relative to the fan, not the team). I only share them amongst friends (so many rights issues), so I have a wee list that I keep up to date:
BOS 2025 _ letter
BOS 2025 +1:00 a4
MIL 2025 -4:00 letter
NYM 2025 _ letter
PHI 2025 +3:00 a4
...
I have a FOREACH loop that builds a PDF to each specification,
foreach [team year zone paper] list [
build-schedule-for team year zone paper
]
This is fine, but as has been mentioned elsewhere, when a function starts to accumulate arguments, it may be better to rethink how it is called. Thus the idea to consolidate arguments in a map. Here's a Rebol 3 function to this end:
mapify: func [
spec [block!]
/local out
][
out: copy #[]
foreach word spec [
if all [
word? :word
value? :word
][
put out :word get :word
]
]
out
]
This cleans up calls from both the loop, and from standalone usage.
foreach [team year zone paper] list [
build-schedule-for mapify [
team year zone paper
]
]
build-schedule-for #[
team BOS
year 2018
zone _
paper letter
]
Perhaps it'd be even more succinct as a block, but the named fields are useful on the function side too: params/team etc. vs. params/1.
I don't know if this has any broader applicability, but I thought I'd jot it down somewhere. I don't like the word 'mapify,' it's descriptive enough though.
To baseball fans—it's a good-looking schedule that presents a season a little differently from the traditional calendar view. If you're curious... ![]()