| Author |
Message |
|
| etxuwig at etxb.ericsson. |
Posted: Tue Oct 17, 2000 10:52 am |
|
|
|
Guest
|
On Mon, 16 Oct 2000, Ulf Wiger wrote:
>
>Here's my first (and perhaps last) hack of sys_pre_expand.erl.
>It handles at least my very simple test function with a list
>comprehension that is fed a lazy list:
OK, since noone complained too much, here's a hack of lists.erl,
where most functions have been enhanced to operate on both eager
and lazy lists.
The functions that do not accept lazy lists are:
- append() and subtract(), of course, since they rely on BIFs
(append() works for some combinations, see below)
- suffix(), since it was difficult to modify slightly without losing
efficiency
- sort(), merge(), rmerge()
- keymember() and keysearch(), since they are BIFs
- keysort(), keymerge()
I wrote a testsuite called listtest.erl. I've reformatted the output
slightly to make it more readable.
It would be interesting if someone with ready access to estone could
see if the modified functions are now slower for eager lists.
BTW, with these modifications, list comprehensions in the Erlang shell
also work with lazy lists.
/Uffe
PS I just discovered the ??Arg macro syntax. Great for stuff like a
simple test module. (:
1> listtest:run(concise).
"lists:seq(1, 5)" -> [1,2,3,4,5]
"lists:seq(1, 3)" -> [1,2,3]
"seq(1, 5)" -> [1|#Fun<listtest.0.59150742>]
"seq(1, 2)" -> [1|#Fun<listtest.0.59150742>]
"lists:append(Seq15, Seq15)" -> [1,2,3,4,5,1,2,3,4,5]
"lists:append(Seq15, Lzy15)" ->
[1,2,3,4,5,1|#Fun<listtest.0.59150742>]
"lists:append(Lzy15, Lzy15)" ->{'EXIT',badarg}
"lists:append([Seq15, Seq15])" -> [1,2,3,4,5,1,2,3,4,5]
"lists:append([Seq15, Lzy15])" ->
[1,2,3,4,5,1|#Fun<listtest.0.59150742>]
"lists:append([Lzy15, Seq15])" ->{'EXIT',badarg}
"lists:reverse(Seq15)" -> [5,4,3,2,1]
"lists:reverse(Lzy15)" ->{'EXIT',badarg}
"lists:nth(3, Seq15)" -> 3
"lists:nth(3, Lzy15)" -> 3
"lists:nthtail(3, Seq15)" -> [4,5]
"lists:nthtail(3, Lzy15)" -> [4|#Fun<listtest.0.59150742>]
"lists:prefix(Seq13, Seq15)" -> true
"lists:prefix(Seq13, Lzy15)" -> true
"lists:prefix(Lzy13, Seq15)" -> true
"lists:prefix(Lzy15, Seq13)" -> false
"lists:prefix(Seq15, Seq13)" -> false
"lists:prefix(Seq15, Lzy13)" -> false
"lists:last(Seq15)" -> 5
"lists:last(Lzy15)" -> 5
"lists:sum(Seq15)" -> 15
"lists:sum(Lzy15)" -> 15
"lists:min(Seq15)" -> 1
"lists:min(Lzy15)" -> 1
"lists:max(Seq15)" -> 5
"lists:max(Lzy15)" -> 5
"lists:sublist(Seq15, 2, 2)" -> [2,3]
"lists:sublist(Lzy15, 2, 2)" -> [2,3]
"lists:delete(3, Seq15)" -> [1,2,4,5]
"lists:delete(3, Lzy15)" -> [1,2,4|#Fun<listtest.0.59150742>]
"lists:flatten([Seq15, [Seq15]])" -> [1,2,3,4,5,1,2,3,4,5]
"lists:flatten([Seq15, [Lzy15]])" -> [1,2,3,4,5,1,2,3,4,5]
"lists:flatten([Lzy15, [Lzy15]])" -> [1,2,3,4,5,1,2,3,4,5]
"lists:flatten([Lzy15, [Seq15]])" -> [1,2,3,4,5,1,2,3,4,5]
"lists:flatlength([Seq15, [Seq15]])" -> 10
"lists:flatlength([Seq15, [Lzy15]])" -> 10
"lists:flatlength([Lzy15, [Lzy15]])" -> 10
"lists:flatlength([Lzy15, [Seq15]])" -> 10
"lists:keydelete(3, 1, [{N, a} || N <- seq(1, 5)])" ->
[{1,a},{2,a},{4,a},{5,a}]
"lists:keydelete(3, 1, [{N, a} || N <- lists:seq(1, 5)])" ->
[{1,a},{2,a},{4,a},{5,a}]
"lists:keyreplace(3, 1, [{N, a} || N <- seq(1, 5)], 33)" ->
[{1,a},{2,a},33,{4,a},{5,a}]
"lists:keyreplace(3, 1, [{N, a} || N <- lists:seq(1, 5)], 33)" ->
[{1,a},{2,a},33,{4,a},{5,a}]
"lists:keymap(fun(X) -> [X] end, 2, [{N, a} || N <- seq( 1, 5)])" ->
lists:seq(1, 5)])" -> [{1,[a]},{2,[a]},{3,[a]},{4,[a]},{5,[a]}]
"lists:keymap(fun(X) -> [X] end, 2, [{N, a} || N <-
lists:seq(1, 5)])" -> [{1,[a]},{2,[a]},{3,[a]},{4,[a]},{5,[a]}]
"lists:all(fun(N) when integer(N) -> true ;(_) -> false end, Seq15)" -> true
"lists:all(fun(N) when integer(N) -> true ;(_) -> false end, Lzy15)" -> true
"lists:all(fun(N) when N > 1, N < 4 -> true ;(_) -> false end, Seq15)" -> false
"lists:all(fun(N) when N > 1, N < 4 -> true ;(_) -> false end, Lzy15)" -> false
"lists:any(fun(N) when N > 1, N < 4 -> true ;(_) -> false end, Seq15)" -> true
"lists:any(fun(N) when N > 1, N < 4 -> true ;(_) -> false end, Lzy15)" -> true
"lists:map(fun(N) -> N + 1 end, Seq15)" -> [2,3,4,5,6]
"lists:map(fun(N) -> N + 1 end, Lzy15)" -> [2,3,4,5,6]
"lists:flatmap(fun(N) -> [N + 1] end, Seq15)" ->
[2,3,4,5,6]
"lists:flatmap(fun(N) -> [N + 1] end, Lzy15)" ->
[2,3,4,5,6]
"lists:foldl(fun(N, Acc) -> Acc + 1 end, 0, Seq15)" -> 5
"lists:foldl(fun(N, Acc) -> Acc + 1 end, 0, Lzy15)" -> 5
"lists:zf(fun(N) when N>1,N<4 ->{true,[N]} ;(_)-> false end, Seq15)" ->
[[2],[3]]
"lists:zf(fun(N) when N>1,N<4 ->{true, [N]} ;(_)-> false end, Lzy15)" ->
[[2],[3]]
i:1
i:2
i:3
i:4
i:5
"lists:foreach(fun(N) -> io : format("i:~p~n", [N]) end, Seq15)" -> ok
i:1
i:2
i:3
i:4
i:5
i:1
i:2
i:3
i:4
i:5
"lists:foreach(fun(N) -> io:format("i:~p~n",[N]) end, Lzy15)" -> ok
i:1
i:2
i:3
i:4
i:5
"lists:mapfoldl(fun(N, Acc) ->{N + 1, Acc + N} end, 0,Seq15)" ->
{[2,3,4,5,6],15}
"lists:mapfoldl(fun(N, Acc) ->{N + 1, Acc + N} end, 0,Lzy15)" ->
{[2,3,4,5,6],15}
"lists:mapfoldr(fun(N, Acc) ->{N + 1, Acc + N} end, 0,Seq15)" ->
{[2,3,4,5,6],15}
"lists:mapfoldr(fun(N, Acc) ->{N + 1, Acc + N} end, 0,Lzy15)" ->
{[2,3,4,5,6],15}
"lists:takewhile(fun(N) when N < 3 -> true ;(_) -> false end, Seq15)" ->
[1,2]
"lists:takewhile(fun(N) when N < 3 -> true ;(_) -> false end, Lzy15)" ->
[1,2]
"lists:dropwhile(fun(N) when N < 3 -> true ;(_) -> false end, Seq15)" ->
[3,4,5]
"lists:dropwhile(fun(N) when N < 3 -> true ;(_) -> false end, Lzy15)" ->
[3|#Fun<listtest.0.59150742>]
"lists:splitwith(fun(N) when N < 3 -> true ;(_) -> false end, Seq15)" ->
{[1,2],[3,4,5]}
"lists:splitwith(fun(N) when N < 3 -> true ;(_) -> false end, Lzy15)" ->
{[1,2],[3|#Fun<listtest.0.59150742>]}
--
Ulf Wiger tfn: +46 8 719 81 95
Strategic Product & System Management mob: +46 70 519 81 95
Ericsson Telecom AB, Datacom Networks and IP Services
Varuv |
|
|
| Back to top |
|
| etxuwig at etxb.ericsson. |
Posted: Tue Oct 17, 2000 11:12 am |
|
|
|
Guest
|
On Tue, 17 Oct 2000, Robert Virding wrote:
rv>Because of all this I don't really see that much use of lazy
rv>lists apart form as a fun programming exercise. Find me a real
rv>application and try to convert me. Personally I think fifthly
rv>is the real clincher.
Not to say that it wasn't fun, but we started this as an approach to
be able to change data access patterns in existing code without
changing too much code in the process.
We see quite often that people solve their problems by handling large
lists of data. If the data is stored in mnesia or ets, they call
ets:tab2list/1 and then traverse the data as a list. This is a very
bad idea if the tables are large, since Erlang will allocate about
three times as much memory as is needed to actually represent the data
on the process heap.
Our approach, when we come across these patterns, is to rewrite the
iteration so that they step through a table instead of building a
list and then stepping through it. But with thousands of lines of
list-processing code, we'd have to rewrite a ton of function clauses
if we depart from the list syntax. Often, we end up doing an almost
complete rewrite for this reason (*).
We feel that this is a simple extension that gives us much more
flexibility, and allows us to experiment with physical data
representations by changing only a few lines of code -- and without
changing the fundamental nature of what we're doing, which is
iterating over a set of data objects (**).
/Uffe
(*) Of course, these rewrites are usually warranted for other reasons,
but timing is always an issue in production projects. If we can, we'd
like to schedule complete rewrites to some other time than during the
system test phase -- which is a fairly common place to find these
problems.
(**) Also, this is not so easy to address by simply trying to educate
programmers about how to write code, so that we can easily change it;
people tend to use the most intuitive constructs, and we should
encourage this as much as possible. Operating on a list is one of the
most intuitive concepts, so it is used very often.
--
Ulf Wiger tfn: +46 8 719 81 95
Strategic Product & System Management mob: +46 70 519 81 95
Ericsson Telecom AB, Datacom Networks and IP Services
Varuv |
|
|
| Back to top |
|
| richardc at it.uu.se |
Posted: Tue Oct 17, 2000 11:15 am |
|
|
|
Guest
|
On Tue, 17 Oct 2000, Ulf Wiger wrote:
> OK, since noone complained too much, here's a hack of lists.erl,
> where most functions have been enhanced to operate on both eager
> and lazy lists.
Well, your hacked functions give correct output, but do they behave as you
intented? They are all eager, in that if you apply your new `map' on a
lazy list, it forces evaluation of the whole list.
A more generally useful implementation would return a new lazy list, where
the `map' operation is not performed on any element until that element is
requested. Then you can create a list like the following:
lazy_lists:map(fun (X) -> X * 2 end,
lazy_lists:natural_numbers())
(the list of all even nonnegative numbers) and then pass the result to
another function, which can pick as many elements from the list as it
wants, or none at all.
/Richard Carlsson
Richard Carlsson (richardc_at_csd.uu.se) (This space intentionally left blank.)
E-mail: Richard.Carlsson_at_csd.uu.se WWW: http://www.csd.uu.se/~richardc/
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| etxuwig at etxb.ericsson. |
Posted: Tue Oct 17, 2000 11:29 am |
|
|
|
Guest
|
On Tue, 17 Oct 2000, Richard Carlsson wrote:
>
>On Tue, 17 Oct 2000, Ulf Wiger wrote:
>
>> OK, since noone complained too much, here's a hack of lists.erl,
>> where most functions have been enhanced to operate on both eager
>> and lazy lists.
>
>Well, your hacked functions give correct output, but do they behave
>as you intented? They are all eager, in that if you apply your new
>`map' on a lazy list, it forces evaluation of the whole list.
Yes, this is exactly was was intended for the lists.erl module, since
it has to be backwards compatible.
Functions that generate lazy lists would have to go into your
lazy_lists module (is it finished yet). ;)
/Uffe
>A more generally useful implementation would return a new lazy list,
>where the `map' operation is not performed on any element until that
>element is requested. Then you can create a list like the following:
>
> lazy_lists:map(fun (X) -> X * 2 end,
> lazy_lists:natural_numbers())
>
>(the list of all even nonnegative numbers) and then pass the result
>to another function, which can pick as many elements from the list
>as it wants, or none at all.
>
> /Richard Carlsson
--
Ulf Wiger tfn: +46 8 719 81 95
Strategic Product & System Management mob: +46 70 519 81 95
Ericsson Telecom AB, Datacom Networks and IP Services
Varuv |
|
|
| Back to top |
|
| aba3600 at omega.uta.edu |
Posted: Wed Oct 18, 2000 1:52 am |
|
|
|
Guest
|
> > Erlang? I'd love to overload "+" or "-" for a specific kind of input,
> > so that a call is made to my function. The data units I am passing in
> > are 3-element tuples right now, but I can change that.
>
> No, there isn't. (Or rather, yes, there is, it's called "parse
> transforms", and you should really not be doing it.) My advice: implement
> a nice abstract datatype with functions "add(X, Y)", "subtract(X, Y)",
> etc., or if you really feel you want `+' and `-', you can actually call
> your functions "'+'(X, Y)" and "'-'(X, Y)" as long as you use
> single-quoting.
Thanks to everyone who suggested some good ideas here. According to the
group, there are 3 options:
1. Library Calls - I've got this wokring
2. Parse Transformations - My next step, but nobody recomends it
3. Built into Erlang - Not Possible
I have a working data type implemented in library calls, and my goal is to
implement infix function calls. I've done what I call "token level
macros" before in Scheme. With "erl_scan" and "erl_parse" it looks
possible...just a bit complex.
Finally, does anyone have an interst in seeing a link to a Masters Thesis
written in Erlang? It deals with robotics.
Sincerely,
Andy Allen
Recycled Electrons
email: andy_at_recycledelectrons.com
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| rv at bluetail.com |
Posted: Wed Oct 18, 2000 8:02 am |
|
|
|
Guest
|
Andy with Recycled Electrons <aba3600_at_omega.uta.edu> writes:
>
>Finally, does anyone have an interst in seeing a link to a Masters Thesis
>written in Erlang? It deals with robotics.
>
Yes, yes, yes, definitely!
Robert
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| aba3600 at omega.uta.edu |
Posted: Wed Oct 18, 2000 5:09 pm |
|
|
|
Guest
|
> >Finally, does anyone have an interst in seeing a link to a Masters Thesis
> >written in Erlang? It deals with robotics.
>
> Yes, yes, yes, definitely!
>
I'll post the URL around Nov 1, when I defend. I hate to give links to
works in progres.
Sincerely,
Andy Allen
Recycled Electrons
email: andy_at_recycledelectrons.com
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| wuji |
Posted: Fri Sep 14, 2012 6:53 am |
|
|
|
User
Joined: 10 Aug 2012
Posts: 654
|
seems possible for Colon who, according to police, joined three other accomplices accomplices [h2]cheap replica *beep*[/h2] accomplices to rob, and ultimately kill, Marcelo Vera in a botched stickup.Miami-Dade
said the "investigation is still ongoing" but confirmed facts of the crime crime [h4]replica designer *beep*[/h4] crime detailed in Colon's arrest warrant and obtained by the Miami Herald.According
the Herald, Colon met a friend, Stephany Concepcion, 26, and two two jordan 11 two other men identified only as "Big Killer" and "Crazy Dread" before
to rob Vero, an artist known to keep large amounts of cash cash cheap jordan shoes cash in his home.Conception, Vero's former employee, arrived at his house late
the night of Jan. 6, 2006. From the victim's bathroom, she called called jordan concord called Colon and told him the time was right for the robbery,
to the warrant.Conception said she heard shots fired from the other room. room. jordan 11 concords room. When she ran outside, the other men had driven off and
was alone at the scene when police arrived. She was arrested and and cheap designer *beep* and pleaded guilty to second-degree murder. She was sentenced to 15 years
|
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|