Hi, how about
∇find_grade[⎕]∇ ∇ [0] r←find_grade g;gm;gl [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, let's start with the second challenge: 2 making the grade (https://www.dyalog.com/uploads/files/student_competition/2019_problems_phase1.pdf) "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←getGrade iscore z←({(iscore≥⍺)∧(iscore≤⍵)}/table[;1 2])/table[;3] ∇ ∇grades←findGrade scores grades ← getGrade ¨ scores ⍝ apply getGrade to EACH score ∇ 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