loop example..
[1/4] from: mgkiourt:otenet:gr at: 4-Oct-2001 11:44
I want to convert a numerical score to a letter grade e.g. the following scale
10-9="A"
8.9-7="B"
6.9-5="C"
Could you please provide any code?
Thanks.Mike
[2/4] from: al::bri::xtra::co::nz at: 4-Oct-2001 21:06
Mike wrote:
> I want to convert a numerical score to a letter grade e.g. the following
scale
> 10-9="A"
> 8.9-7="B"
> 6.9-5="C"
> Could you please provide any code?
>> Mark: 4
== 4
>> Grade: any [
[ if 9 <= Mark ["A"]
[ if 7 <= Mark ["B"]
[ if 5 <= Mark ["C"]
[ "Something Else"
[ ]
== "Something Else"
Or:
>> Mark: 4
== 4
>> Grades: [
[ 9 "A"
[ 7 "B"
[ 5 "C"
[ ]
== [
9 "A"
7 "B"
5 "C"
]
>> foreach [Minimum Grade] Grades [
[ if Minimum <= Mark [break/return Grade]
[ ]
== none
>> Mark: 9
== 9
>> foreach [Minimum Grade] Grades [
[ if Minimum <= Mark [break/return Grade]
[ ]
== "A"
Any one want to offer a more esoteric solution? :-)
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[3/4] from: deadzaphod:flyingparty at: 4-Oct-2001 2:10
> Any one want to offer a more esoteric solution? :-)
how about this?
mark: 4
scale: [ 10 "A" 9 "A" 8 "B" 7 "B" 6 "C" 5 "C" 4 "D" 3 "D" 2 "F" 1 "F" 0
F
]
select scale to-integer mark
Cal
[4/4] from: joel:neely:fedex at: 4-Oct-2001 1:29
Hey, folks,
Cal Dixon wrote:
> > Any one want to offer a more esoteric solution? :-)
>
> how about this?
>
> mark: 4
> scale: [ 10 "A" 9 "A" 8 "B" 7 "B" 6 "C" 5 "C" 4 "D" 3 "D" 2 "F" 1 "F" 0
> "F" ]
> select scale to-integer mark
>
As long as we can assume that the breaks are on integer boundaries,
this could simplify to
pick "FFFDDCCBBAA" 1 + to-integer mark
but, as usual, the more we optimize, the more we lose flexibility.
-jn-
--
Why are there interstate highways in Hawaii?
-- Lora Canney
joel#dot#neely#at#fedex#FIX#PUNCTUATION#dot#com