Using a separate function for rounding (from Dyalog book with re
formatting), thus usable in other contexts.
∇R← N round V;S
⍝ N: number of decimals
⍝ V: value to be rounded
S←10⋆N         ⍝ Scale
R←(⌊.5+V×S)÷S  ⍝ Result

∇R←gdist M; G;F;S;P
⍝ R: Result
⍝ M: numerical grades
G ← 'ABCDF'  ⍝ G: character grades
F ← +/G∘.=M  ⍝ F: Frequencies
S ← +/F      ⍝ S: Sum of freqs
P ← 100×F÷S  ⍝ P: Percentages
R←G,F,(⍪1 round P)

IMHO, sometimes I prefer single letter variables with minimum documentation
makes it easy to follow. Also when In a function I do not mind spreading
the code on multi-lines since usually it is tuck away.

HiH.

Regards,

Ala'a

P.S: I did not code more than what was specified, I think I got this from
Forth more than any other language.
P.P.S: I'm sending the message to the list. I mistakenly replied to the
original email.

Reply via email to