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
ed7717ce
Commit
ed7717ce
authored
Jul 10, 2007
by
Pietro Abate
Browse files
[r2003-11-26 20:08:23 by beppe] programmed count in tail recursive way
Original author: beppe Date: 2003-11-26 20:08:23+00:00
parent
9a27d4c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/cql/q6.cd
View file @
ed7717ce
(*********function *********)
let fun count([Any*]->Int)
let fun count
_bad
([Any*]->Int)
[] -> 0
| [_;t] -> 1+count(t);;
(* tail recursive definition *)
let fun count(x : [Any*]) : Int =
let tr_count((Int,[Any*]) -> Int)
| (n,[]) -> n
| (n,[_;t]) -> tr_count(n+1,t)
in tr_count(0,x)
(***************************)
(*****************************************************************
...
...
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