bug-apl
[Top][All Lists]

## Re: exercise 2019/02

 From: Hans-Peter Sorge Subject: Re: exercise 2019/02 Date: Wed, 15 Apr 2020 15:15:39 +0200 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0

```Hi,

∇
[1]   gm←0 65 70 80 90
[2]   gl←'FDCBA'
[3]   r←,¨gl[+/[1]gm ∘.≤ g]
∇

m,find_grade m←5 2⍴0 64  65 69  70 79  80 89  90 100
0  64 F F
65  69 D D
70  79 C C
80  89 B B
90 100 A A

Regards
Hans-Peter

Am 14.04.20 um 17:40 schrieb Otto Diesenbacher-Reinmüller:
```
```Hi APLers,

"Write a function that, given an array of integer testscores in the
inclusive range 0–100, returns anidentically-shaped array of the
corresponding lettergrades according to the table to the left.Hint:
You may want to investigate the intervalindex function ⍸."(from the exercise)
┌────────┐
│ 0  64 F│
│65  69 D│
│70  79 C│
│80  89 B│
│90 100 A│
└────────┘

⍝ so - ⍸ is not applicable as Dyalog-only, let's try without it.

⍝ create the score card:

table ← 1 3 ⍴ 0 64 'F'
table ← table ⍪ 65 69 'D'
table ← table ⍪ 70 79 'C'
table ← table ⍪ 80 89 'B'
table ← table ⍪ 90 100 'A'

z←({(iscore≥⍺)∧(iscore≤⍵)}/table[;1 2])/table[;3]
∇

∇

findGrade 2 2 ⍴ 50 72 91 88
F C
A B

for sure, it would be better, to live without the *external* getGrade
function. But trying to incorporate the getGrade as a lambda, I
couldn't solve the nested "⍵"s and nested lambdas.

Any hint?

br & many thanks - Otto

```
```
```