diff options
author | Lars G Thorsen <[email protected]> | 2010-01-26 10:13:35 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-01-26 18:55:11 +0100 |
commit | df88b47cdafcc2e04452456942ea572a7b72e2f2 (patch) | |
tree | 36da537a36b45ff406acb8e714dde97bbe31e7af /system/doc/extensions/list_comprehensions.erl | |
parent | 39ff2b44d130179d3ce722a9b3c07d27bfb72a2a (diff) | |
download | otp-df88b47cdafcc2e04452456942ea572a7b72e2f2.tar.gz otp-df88b47cdafcc2e04452456942ea572a7b72e2f2.tar.bz2 otp-df88b47cdafcc2e04452456942ea572a7b72e2f2.zip |
OTP-8343 The documentation is now possible to build in an open source
environment after a number of bugs are fixed and some features
are added in the documentation build process.
- The arity calculation is updated.
- The module prefix used in the function names for bif's are
removed in the generated links so the links will look like
http://www.erlang.org/doc/man/erlang.html#append_element-2
instead of
http://www.erlang.org/doc/man/erlang.html#erlang:append_element-2
- Enhanced the menu positioning in the html documentation when a
new page is loaded.
- A number of corrections in the generation of man pages (thanks
to Sergei Golovan)
- Moved some man pages to more apropriate sections, pages in
section 4 moved to 5 and pages in 6 moved to 7.
- The legal notice is taken from the xml book file so OTP's
build process can be used for non OTP applications.
Diffstat (limited to 'system/doc/extensions/list_comprehensions.erl')
-rw-r--r-- | system/doc/extensions/list_comprehensions.erl | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/system/doc/extensions/list_comprehensions.erl b/system/doc/extensions/list_comprehensions.erl deleted file mode 100644 index 21ac562aa5..0000000000 --- a/system/doc/extensions/list_comprehensions.erl +++ /dev/null @@ -1,118 +0,0 @@ --module(t). --author('[email protected]'). - -%%-export([test/2]). --compile(export_all). - -%% Odd numbers. - -%%foo(L) -> [ X || X <- L, (X > X-1) == (X /= X-1) ]. - -bar(L) -> [ X || X <- L, integer(X), gt(X, 3) ]. - -bar(L, M) -> [ Y || X <- L, integer(X), gt(X, 3), - Y <- M, float(Y), gt(X, Y) - ]. - -baz(L) -> [ X || X <- L, atom(X) ]. - -buz(L, Min) -> [ X || Min > 3, X <- L, X >= Min ]. - -gt(X, Y) when X > Y -> true; -gt(X, Y) -> false. - -%% Turn a list into a set. -make_set([]) -> []; -make_set([H|T]) -> - [H|[ - Y || Y <- make_set(T), - Y =/= H - ]]. - -%% Return the Pythagorean triangles with sides -%% of total length less than N -pyth(N) -> - [ {A,B,C} || - A <- lists:seq(1,N), - B <- lists:seq(1,N), - C <- lists:seq(1,N), - A+B+C =< N, - A*A+B*B == C*C - ]. - -%% Cut the search space a bit.. -pyth2(N) -> - [ {A,B,C} || - A <- lists:seq(1,N), - B <- lists:seq(1,N-A+1), - C <- lists:seq(1,N-A-B+2), - A+B+C =< N, - A*A+B*B == C*C ]. - -%% Return the Cartesian product -cp() -> - [ {X,Y} || - X <- a(), - Y <- b() - ]. - -cp(A,B) when list(A),list(B) -> - [ {X,Y} || - X <- A, - Y <- B - ]. - -%a() -> 1/0. -a() -> [a,b]. -b() -> [1,2,3]. - -%% Return all permutations of a list -perms([]) -> [[]]; -perms(L) -> [ [H|T] || H <- L, T <- perms(L--[H]) ]. - -%% Quick sort -sort([X|Xs]) -> - sort([ Y || Y <- Xs, Y < X ]) ++ - [X] ++ - sort([ Y || Y <- Xs, Y >= X ]); -sort([]) -> []. - -%% Vector addition -vecAdd(Xs,Ys) -> - [ X+Y || {X,Y} <- zip(Xs,Ys) ]. - -zip([X|Xs],[Y|Ys]) -> [{X,Y}|zip(Xs,Ys)]; -zip([],[]) -> []. - -qsort([X|Xs]) -> - qsort(lt(X,Xs)) - ++ [X] ++ - qsort(ge(X,Xs)); -qsort([]) -> []. - -lt(X,[H|T]) when X>H -> [H|lt(X,T)]; -lt(X,[_|T]) -> lt(X,T); -lt(_,[]) -> []. - -ge(X,[H|T]) when X=<H -> [H|ge(X,T)]; -ge(X,[_|T]) -> ge(X,T); -ge(_,[]) -> []. - -test(1,N) -> statistics(runtime),test1(N),statistics(runtime); -test(2,N) -> statistics(runtime),test2(N),statistics(runtime); -test(3,N) -> statistics(runtime),test3(N),statistics(runtime). - -test1(0) -> true; -test1(N) -> - sort([21,12,45,1,3,87,55,77,11,20,6,99,91,13,14,15,66,62,69,71,67,82,83,84,87,86,85]), - test1(N-1). - -test2(0) -> true; -test2(N) -> - qsort([21,12,45,1,3,87,55,77,11,20,6,99,91,13,14,15,66,62,69,71,67,82,83,84,87,86,85]), - test2(N-1). - -test3(0) -> true; -test3(N) -> - lists:sort([21,12,45,1,3,87,55,77,11,20,6,99,91,13,14,15,66,62,69,71,67,82,83,84,87,86,85]), - test3(N-1). |