File: introExample55.tex

package info (click to toggle)
sollya 8.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,592 kB
  • sloc: ansic: 124,655; yacc: 7,543; lex: 2,440; makefile: 888; cpp: 77
file content (74 lines) | stat: -rw-r--r-- 2,725 bytes parent folder | download | duplicates (2)
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
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> match exp(x) with 
      sin(x)    : ("Sine of x")
      atan(x^2) : ("Arctangent of square of x")
      default   : ("Something else")
      exp(x)    : ("Exponential of x");
Something else
> 
> match atan(x^2) with 
      sin(x)          : ("Sine of x")
      atan(default^2) : ("Arctangent of the square of something")
      default         : ("Something else");
Arctangent of the square of something
> 
> match atan(exp(x)^2) with 
      sin(x)          : ("Sine of x")
      atan(default^2) : ("Arctangent of the square of something")
      default         : ("Something else");
Arctangent of the square of something
> 
> match exp("Hello world") with 
      exp(default)    : ("A miracle has happened")
      default         : ("Something else");
Warning: at least one of the given expressions or a subexpression is not correct
ly typed
or its evaluation has failed because of some error on a side-effect.
Warning: the evaluation of the expression to be matched in a match... with const
ruct yields error due to a syntax error or an error on a side-effect.
The effect or return value of the match... with construct may be meaningless.
Something else
> 
> match error with
      @NaN@           : ("Not A Number")
      [@NaN@, @NaN@]  : ("Interval of Not A Numbers")
      error           : ("Error")
      default         : ("Something else");
Error
> 
> match [@NaN@, @NaN@] with
      @NaN@           : ("Not A Number")
      [@NaN@, @NaN@]  : ("Interval of Not A Numbers")
      error           : ("Error")
      default         : ("Something else");
Interval of Not A Numbers
> 
> match @NaN@ with
      @NaN@           : ("Not A Number")
      [@NaN@, @NaN@]  : ("Interval of Not A Numbers")
      error           : ("Error")
      default         : ("Something else");
Not A Number
> 
> match exp(17) with
      @NaN@           : ("Not A Number")
      [@NaN@, @NaN@]  : ("Interval of Not A Numbers")
      error           : ("Error")
      default         : ("Something else");
Something else
> 
> match exp("This is wrong") with
      @NaN@           : ("Not A Number")
      [@NaN@, @NaN@]  : ("Interval of Not A Numbers")
      error           : ("Error")
      default         : ("Something else");
Warning: at least one of the given expressions or a subexpression is not correct
ly typed
or its evaluation has failed because of some error on a side-effect.
Warning: the evaluation of the expression to be matched in a match... with const
ruct yields error due to a syntax error or an error on a side-effect.
The effect or return value of the match... with construct may be meaningless.
Error
> 
\end{Verbatim}
\end{minipage}\end{center}