File: range

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (74 lines) | stat: -rw-r--r-- 1,256 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
option:symbols=" "

parleft=(
dd=$(reply$i)
c=!char 1 of $dd
!if $c=+ or $c=-
  dd=!char 2 to -1 of $dd
!endif
!if $computeanswer!=yes and \
	  ( + isin $dd or - isin $dd or * isin $dd or ^ isin dd \
	  or $parleft isin $dd or ( . isin $dd and / isin $dd ) )
  test=NaN nocompute
  !exit
!else
  reply$i=!rawmath $(reply$i)
  test=$[$(reply$i)]
!endif


m_reply$i=$(reply$i)
!if $wims_read_parm=nocompare
  !if NaN isin $test
    !exit
  !endif
  !exit
!endif

gcnt=!itemcnt $(replygood$i)
!if $gcnt<2
  :badgood
  Text=bad $i
  !exit
!endif
gcnt2=$[floor($gcnt/2)]

!if NaN isin $test or Inf isin $test
  !exit
!endif

diag=no
!for t=1 to $gcnt2
  g1=$(replygood$i[2*$t-1])
  g2=$(replygood$i[2*$t])
  !distribute item $[$g1],$[$g2] into G1,G2
  g1=!lower $g1
  g2=!lower $g2
  !if NaN isin $G1$G2
    !goto badgood
  !endif
  !if inf notin $g1$g2 and $G1>$G2
    !exchange G1,G2
  !endif
  !if $t=1
    !if inf notin $g1$g2
      replyGood$i=$[($G1+($G2))/2]
    !else
      replyGood$i=$g1,$g2
    !endif
  !endif
  !if (inf isin $G1 or $G1<=$test) and (inf isin $G2 or $G2>=$test)
    diag=yes
  !endif
!next t

!if $[$gcnt%2]=1
  replyGood$i=$(replygood$i[-1])
!endif

!if $diag=yes
  diareply$i=good
  !advance freegot
!else
   diareply$i=bad
!endif