Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Temperature-conversion/CLU/temperature-conversion.clu
Normal file
38
Task/Temperature-conversion/CLU/temperature-conversion.clu
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
kelvin = proc (k: real) returns (real)
|
||||
return(k)
|
||||
end kelvin
|
||||
|
||||
celsius = proc (k: real) returns (real)
|
||||
return(k - 273.15)
|
||||
end celsius
|
||||
|
||||
rankine = proc (k: real) returns (real)
|
||||
return(k * 9./5.)
|
||||
end rankine
|
||||
|
||||
fahrenheit = proc (k: real) returns (real)
|
||||
return(rankine(k) - 459.67)
|
||||
end fahrenheit
|
||||
|
||||
conv = struct[letter: char, func: proctype (real) returns (real)]
|
||||
|
||||
convs = sequence[conv]$[
|
||||
conv${letter: 'K', func: kelvin},
|
||||
conv${letter: 'C', func: celsius},
|
||||
conv${letter: 'F', func: fahrenheit},
|
||||
conv${letter: 'R', func: rankine}
|
||||
]
|
||||
|
||||
start_up = proc ()
|
||||
pi: stream := stream$primary_input()
|
||||
po: stream := stream$primary_output()
|
||||
|
||||
stream$puts(po, "Enter temperature in Kelvin: ")
|
||||
k: real := real$parse(stream$getl(pi))
|
||||
|
||||
for c: conv in sequence[conv]$elements(convs) do
|
||||
stream$putc(po, c.letter)
|
||||
stream$puts(po, " ")
|
||||
stream$putl(po, f_form(c.func(k), 6, 2))
|
||||
end
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue