https://github.com/sleibrock/racket-friday
Run Racket code only when it's Friday
https://github.com/sleibrock/racket-friday
comedy friday racket racket-lang
Last synced: 2 months ago
JSON representation
Run Racket code only when it's Friday
- Host: GitHub
- URL: https://github.com/sleibrock/racket-friday
- Owner: sleibrock
- License: mit
- Created: 2022-02-16T17:27:44.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-16T22:41:50.000Z (about 3 years ago)
- Last Synced: 2024-12-28T09:33:37.484Z (4 months ago)
- Topics: comedy, friday, racket, racket-lang
- Language: Racket
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
racket-friday
=======Code that only runs when it is Friday. Inspired by [perl-friday](https://github.com/jwilk/perl-friday).
Example of running the `friday.rkt` file.
```
$ racket friday.rkt
on-friday: It's not friday
context....:
...
```Using `on-friday` in practice.
```racket
#lang racket(require "friday.rkt")
(on-friday
(define my-numbers (range 100))
(define filtered (filter odd? my-numbers))
(for-each (lambda (k) (displayln "~a x ~a = ~a" k k (* k k)))
filtered))...
on-friday: it's not friday ; if it isn't friday
1 x 1 = 1
2 x 2 = 4
3 x 3 = 9
... ; if it is friday
```There are too many ways of writing syntactically incorrect code, so I opted to write code that only *runs* when it is Friday. This is a language macro that re-writes your code to run the code when it is Friday, or it produces an error when it is not.
A complete joke... unless you want to implement it in your code. I am not at fault. MIT License for all. Semi-inspired by the legendary `only-once` macro.