Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
20ff5ac6
Commit
20ff5ac6
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2003-07-29 14:20:20 by cvscast] Empty log message
Original author: cvscast Date: 2003-07-29 14:20:20+00:00
parent
743ae321
Changes
1
Hide whitespace changes
Inline
Side-by-side
driver/examples.ml
View file @
20ff5ac6
...
...
@@ -352,6 +352,43 @@ let doc : Xhtml =
bold [doc];;
let [x] = bold [doc] in print_xml x;;
"
;
"reference"
,
"(* In CDuce the expression
\"
ref T exp
\"
returns a reference *)
(* to the result of
\"
exp
\"
and has type
\"
ref T
\"
provided that *)
(*
\"
exp
\"
is of type
\"
T
\"
. References come equipped with three *)
(* operators:
\"
:=
\"
(assignment),
\"
!
\"
(dereferencing), and
\"
;
\"
*)
(* (sequencing). *)
let stack = ref [Int*] []
let fun push(x : Int) : [] =
stack := [x !!stack]
let fun pop ([] : []) : Int =
match !stack with [x ;y] -> stack := y; x | _ -> raise
\"
Empty stack
\"
(* In [ pattern ;y] the variable y captures the rest of the *)
(* sequence. It is equivalent to [pattern y::_*] *)
(* *)
(* Since sequences are encoded by pairs, we could write *)
(* the following [deprecated] equivalent definitions *)
(*
let fun push(x : Int) : [] =
stack := (x, !stack)
let fun pop ([] : []) : Int =
match !stack with (x, y) -> stack := y; x | _ -> raise
\"
Empty stack
\"
*)
;;
push 1;;
push 2;;
push 3;;
pop [];;
pop [];;
pop [];;
pop [];;
"
;
]
let
present
=
"<ul><li><a href=
\"
/cgi-bin/cduce?example=xml
\"
>XML elements.</a>
XML elements.
...
...
@@ -377,4 +414,6 @@ The good old XML bibliography example.
Syntactic sugar for projection.
</li><li><a href=
\"
/cgi-bin/cduce?example=xtransform
\"
>Tree transformations.</a>
How to perform XSLT-like transformations.
</li><li><a href=
\"
/cgi-bin/cduce?example=reference
\"
>References.</a>
Mutable values.
</li></ul>"
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment