This file is indexed.

/usr/share/mozart/examples/sampler/oz.oz is in mozart-doc 1.4.0-8ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
%%%
%%% Authors:
%%%   Christian Schulte <schulte@ps.uni-sb.de>
%%%   Gert Smolka <smolka@ps.uni-sb.de>
%%%
%%% Copyright:
%%%   Christian Schulte, 1998
%%%   Gert Smolka, 1998
%%%
%%% Last change:
%%%   $Date: 2003-05-06 16:11:48 +0200 (Tue, 06 May 2003) $ by $Author: glynn $
%%%   $Revision: 15483 $
%%%
%%% This file is part of Mozart, an implementation
%%% of Oz 3
%%%    http://www.mozart-oz.org
%%%
%%% See the file "LICENSE" or
%%%    http://www.mozart-oz.org/LICENSE.html
%%% for information on usage and redistribution
%%% of this file, and for a DISCLAIMER OF ALL
%%% WARRANTIES.
%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%% Functional Programming

declare
fun {MAP L F}
   case L
   of nil then nil
   [] H|T then {F H}|{MAP T F}
   end
end


declare L F O in 
{Inspect O}
O={MAP L F}

L = _|_|_

L = _|_|7|_

F = fun {$ X} X*X end

L = [1 2 _ _ ~5]

declare
fun {MAPC L F}
   case L
   of nil then nil
   [] H|T then thread {F H} end|{MAPC T F}
   end
end


%%%%%%%%%%%%%%%%%%%%%%%%%% Finite Domains


declare L X Y Z in L=[X Y Z]
{FD.dom 1#10 L}
{Inspect L}

2*Y=:Z

X<:Y

Z<:7

X\=:1

declare
proc {Q L}
   [X Y Z] = L
in
   {FD.dom 1#19 L}
   3*X+Y =: Z
   X >: 2
   {FD.distribute ff L}
end

{Inspect {SearchOne Q}}

{Inspect {SearchAll Q}}

{ExploreOne Q}



%%%%%%%%%%%%%%%%%%%%%%%%%% Constraint Programming


% see sampler-constraints.oz


%%%%%%%%%%%%%%%%%%%%%%%%%%% Logic Programming

declare
proc {LENGTH L N}
   dis L=nil N=0
   []  H R M in
      L=H|R N=s(M)
   then
      {LENGTH R M}  
   end
end



declare L N in 
{Inspect L}
{Inspect N}


{LENGTH L N}


N = s(s(_))


L = _|_|_|_


N = s(s(s(0)))


L = 1|2|3|nil


{ExploreOne proc {$ X} 
	       L N in 
	       X=L#N 
	       {LENGTH L N} 
	    end}



%%%%%%%%%%%%%%%%%%%%%%%%%% Object-oriented Programming

%%% a sequential object

declare
class Counter
   from BaseObject
   attr val:0
   meth inc
      val <- @val + 1
   end
   meth inspect
      {Inspect counter(@val)} 
   end
end
C = {New Counter inspect}

{C inc}

{C inspect}

%%% a concurrent object

declare
class DCounter from Counter
   prop locking
   meth set(X)
      lock
	 val <- X 
	 {self inspect}
      end
   end
   meth dec
      lock 
	 val <- @val-1
	 {self inspect}
      end
   end
   meth inc
      lock
	 Counter,inc
	 {self inspect}
      end
   end
end

declare X 
D = {New DCounter set(X)} 

{D dec}

{D inc}

X=56



%%%%%%%%%%%%%%%%%% Real Time Programming


{Delay 3000}
{Inspect 'fired after 3 seconds'}


declare
proc {DoWithDelay Xs T P}
   case Xs of X|Xr
   then {P X} {Delay T} {DoWithDelay Xr T P}
   else skip
   end
end

{DoWithDelay [this is a nice list] 1000 Inspect}


%%%%%%%%%%%%%%%%%% Animation


declare
class TimeCounter from DCounter Time.repeat end
D = {New TimeCounter inspect}

{D setRepAction(inc)}

{D go}

{D setRepAction(dec)}

{D setRepDelay(200)}

{D setRepDelay(1000)}

{D stop}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% create a window with a canvas and a frame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

declare 
Window = {New Tk.toplevel tkInit(title:'Demo Window')}
Canvas = {New Tk.canvas tkInit(parent:Window
			       relief:sunken
			       borderwidth:1
			       background:white
			       width:400 height:400)}
{Tk.send pack(Canvas)}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% deiconify very simple things
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

{Window tkWM(iconify)}

{Window tkWM(deiconify)}


declare
proc {DrawCircle X Y R}
   {Canvas tk(create oval X-R Y-R X+R Y+R)}
end

{DrawCircle 100 100 20}

{DrawCircle 200 200 10}

declare
proc {SetMouseAction A}
   {Canvas tkBind(event: '<1>' action:A
		  args:[int(x) int(y)])}
end

{SetMouseAction proc {$ X Y} {DrawCircle X Y 40} end}

{Canvas tk(delete all)}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A text object
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

declare
BigFont = {New Tk.font tkInit(weight:bold size:18)}
class Text from Tk.canvasTag
   meth init(X Y T)
      Tk.canvasTag,tkInit(parent:Canvas)
      {Canvas tk(crea text X Y anchor:w
		 text:T tag:self font:BigFont)}
   end
end
T={New Text init(10 100 "Oz is nice")}

{T tk(move 3 3)}

{T tkClose}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% An animated text object
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

declare
class AnimatedText from Text Time.repeat
   meth up   {self setRepAction(tk(move 0 ~2))} end
   meth down {self setRepAction(tk(move 0 2))}  end
   meth fast {self setRepDelay(100)}            end
   meth slow {self setRepDelay(1000)}           end
end
A={New AnimatedText init(20 20 "Oz is parallel")}

{A down}
{A go}
{A fast}
{A slow}
{A up}
{A down}		
{A stop}
{A go}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Buttons
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

declare
Frame = {New Tk.frame tkInit(parent:Window)}
{Tk.send pack(Frame)}
proc {NewButton Object Message}
   {Tk.send pack({New Tk.button
	     tkInit(parent:Frame font:BigFont text:Message
		    action: proc {$} {Object Message} end)}
	    side:left)}
end

{NewButton A stop}
{NewButton A go}
{NewButton A up}
{NewButton A down}
{NewButton A fast}
{NewButton A slow}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Images
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

declare
Images={TkTools.images
	['x-oz://doc/demo/applets/images/trucks/truck-right.ppm']}
TruckImage = Images.'truck-right'
class Truck from Tk.canvasTag Time.repeat
   meth init(Position)
      {self tkInit(parent:Canvas)}
      {Canvas tk(crea image 1 Position
		 image:  TruckImage
		 anchor: sw
		 tags:   self)}
      {self setRepAll(delay:100 number:150)}
      thread {self forward} end
   end
   meth forward
      {self setRepAction(tk(move 2 0))}
      {self setRepFinal(backward)}
      {self go}
   end
   meth backward
      {self setRepAction(tk(move ~2 0))}
      {self setRepFinal(forward)}
      {self go}
   end
end
T={New Truck init(400)}


{T stop}

{T go}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Open Programming
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

declare
T={New AnimatedText init(250 20 "Oz is open")}
{T down} {T go}

declare
class InternetController
   from Open.socket Open.text
   meth getCommand
      {self write(vs:'command? ')}
      case {String.toAtom {Filter {self getS($)} Char.isAlpha}}
      of quit then {self close} {T stop} {T tkClose}
      elseof M then {T M} {self getCommand}
      end
   end
end
IC={New InternetController server(port:{Inspect portNumber($)})}
{IC getCommand}