Skip to content

Commit 8eb60ee

Browse files
committed
Added Racket Programming Language
1 parent 02542e2 commit 8eb60ee

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

racket/clockhands.rkt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(define (clockhands i)
2+
(define t (floor (/ (+ (* 43200 i) 21600) 11)))
3+
(define-values (h m s)
4+
(values (floor (/ t 3600))
5+
(remainder (floor (/ t 60)) 60)
6+
(remainder t 60)))
7+
(printf "~a:~a:~a~n"
8+
(~a (if (= h 0) 12 h) #:width 2 #:align 'right #:left-pad-string "0")
9+
(~a m #:width 2 #:align 'right #:left-pad-string "0")
10+
(~a s #:width 2 #:align 'right #:left-pad-string "0"))
11+
(when (< i 10) (clockhands (+ i 1))))
12+
13+
(clockhands 0)

racket/hello.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(println "Hello, World!")

racket/test.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function Assert-MatchTests {
2+
param (
3+
[Parameter(Mandatory = $true, ValueFromPipeline)] $TestResult
4+
)
5+
6+
if ($TestResult) {
7+
Write-Error "Output does not match expected results."
8+
}
9+
}
10+
11+
$Error.clear()
12+
racket -f "$PSScriptRoot\clockhands.rkt" |
13+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
14+
Assert-MatchTests &&
15+
racket -f "$PSScriptRoot\hello.rkt" &&
16+
racket -f "$PSScriptRoot\triple_imperative.rkt" |
17+
Compare-Object (Get-Content "$PSScriptRoot\..\test\triple_expected") |
18+
Assert-MatchTests &&
19+
ForEach-Object 'foo';
20+
21+
if ($Error -or !$?) {
22+
"*** RACKET TESTS FAILED ***"
23+
}
24+
else {
25+
"RACKET TESTS PASSED"
26+
}
27+
28+

racket/triple_imperative.rkt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(for* ([c (in-range 1 41)]
2+
[b (in-range 1 c)]
3+
[a (in-range 1 b)]
4+
#:when (= (+ (sqr a) (sqr b)) (sqr c)))
5+
(printf "~v, ~v, ~v~n" a b c))

0 commit comments

Comments
 (0)