为什么我的 Racket 程序没有给我任何输出?
Why my Racket program does not give me any output?
我编写了这段用于转换测量值的代码。但是,当我 运行 使用命令 (fce cm mm 5)
时,我没有看到任何输出和任何错误。
#lang racket
(define eq equal?)
(define (fce jednotka jednotka2 cislo)
(cond
((eq jednotka "mm") (mm cislo jednotka2))
((eq jednotka "cm") (cm cislo jednotka2))
((eq jednotka "m") (m cislo jednotka2))
((eq jednotka "km") (km cislo jednotka2))))
(define (mm c j)
(cond
((eq j "cm") (format "~a mm = ~a ~a" c (* c 0.1) j))
((eq j "m") (format "~a mm = ~a ~a" c (* c 0.001) j))
((eq j "km") (format "~a mm = ~a ~a" c (* c 0.000001) j))))
(define (cm c j)
(cond
((eq j "mm") (format "~a mm = ~a ~a" c (* c 0.1) j))
((eq j "m") (format "~a mm = ~a ~a" c (* c 0.001) j))
((eq j "km") (format "~a mm = ~a ~a" c (* c 0.000001) j))))
(define (m c j)
(cond
((eq j "cm") (format "~a mm = ~a ~a" c (* c 0.1) j))
((eq j "mm") (format "~a mm = ~a ~a" c (* c 0.001) j))
((eq j "km") (format "~a mm = ~a ~a" c (* c 0.000001) j))))
(define (km c j)
(cond
((eq j "cm") (format "~a mm = ~a ~a" c (* c 0.1) j))
((eq j "m") (format "~a mm = ~a ~a" c (* c 0.001) j))
((eq j "km") (format "~a mm = ~a ~a" c (* c 0.000001) j))))
您忘记引用字符串,并且您正在比较 过程。你应该这样做:
(fce "cm" "mm" 5)
虽然逻辑看起来不对。上面的打印:
"5 mm = 0.5 mm"
您需要在每个帮助程序中计算出正确的转换和显示消息。
我编写了这段用于转换测量值的代码。但是,当我 运行 使用命令 (fce cm mm 5)
时,我没有看到任何输出和任何错误。
#lang racket
(define eq equal?)
(define (fce jednotka jednotka2 cislo)
(cond
((eq jednotka "mm") (mm cislo jednotka2))
((eq jednotka "cm") (cm cislo jednotka2))
((eq jednotka "m") (m cislo jednotka2))
((eq jednotka "km") (km cislo jednotka2))))
(define (mm c j)
(cond
((eq j "cm") (format "~a mm = ~a ~a" c (* c 0.1) j))
((eq j "m") (format "~a mm = ~a ~a" c (* c 0.001) j))
((eq j "km") (format "~a mm = ~a ~a" c (* c 0.000001) j))))
(define (cm c j)
(cond
((eq j "mm") (format "~a mm = ~a ~a" c (* c 0.1) j))
((eq j "m") (format "~a mm = ~a ~a" c (* c 0.001) j))
((eq j "km") (format "~a mm = ~a ~a" c (* c 0.000001) j))))
(define (m c j)
(cond
((eq j "cm") (format "~a mm = ~a ~a" c (* c 0.1) j))
((eq j "mm") (format "~a mm = ~a ~a" c (* c 0.001) j))
((eq j "km") (format "~a mm = ~a ~a" c (* c 0.000001) j))))
(define (km c j)
(cond
((eq j "cm") (format "~a mm = ~a ~a" c (* c 0.1) j))
((eq j "m") (format "~a mm = ~a ~a" c (* c 0.001) j))
((eq j "km") (format "~a mm = ~a ~a" c (* c 0.000001) j))))
您忘记引用字符串,并且您正在比较 过程。你应该这样做:
(fce "cm" "mm" 5)
虽然逻辑看起来不对。上面的打印:
"5 mm = 0.5 mm"
您需要在每个帮助程序中计算出正确的转换和显示消息。