From ulf.wiger@REDACTED Wed Dec 1 09:57:31 2004 From: ulf.wiger@REDACTED (Ulf Wiger (AL/EAB)) Date: Wed, 1 Dec 2004 09:57:31 +0100 Subject: emulate target node names on a workstation Message-ID: <37FB7AA6F5F9814FB634A7BF4C35A6F54029B8@ESEALNT442.al.sw.ericsson.se> I just thought I'd mention that I sent a set of patches to OTP (based on OTP R10B_0) that make it possible to run several Erlang nodes on the same machine using the convention 'erl -sname @'. This wasn't possible before, unless perhaps if the part happened to be unique for all nodes involved. My patch makes epmd aware of the whole node name -- not just the first half. I've attached an archive with a set of diffs (for epmd_srv.c, epmd.h, epmd_int.h, net_kernel.erl, erl_epmd.[eh]rl, inet_tcp_dist.erl). If anyone wants copies of the full source, please email me. Note that I've only dealt with the Erlang parts -- not C nodes et al. Here's a chance to contribute. ;-) AFAIK, the new epmd is backward compatible, but the part known to epmd will default to the original host name (this is done since older erlang nodes don't pass the part when they register with epmd.) Using this feature also requires a custom inetrc file. This is all described in the ERTS User Guide. (At AXD 301, we've used a mapping layer on top of the node names to allow for them changing depending on environment. While there may be some additional point to doing this, it has occured to me that the Erlang node name is a logical abstraction in itself, and should be sufficient in most cases. Using the node names directly would cut down on the amount of glue code needed in the system. Note, though, that we're not pushing this as a priority item. OTP may choose to include it, or not. We don't care that much. I still think it's a nice idea, though. Finally - fair warning: this was my first "significant" c hack in 12-13 years -- absolutely no warranty! :-) /Uffe <> -------------- next part -------------- A non-text attachment was scrubbed... Name: epmd_diffs.tgz Type: application/octet-stream Size: 2888 bytes Desc: not available URL: From bjorn@REDACTED Wed Dec 1 10:04:09 2004 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 01 Dec 2004 10:04:09 +0100 Subject: parallel LC In-Reply-To: <37FB7AA6F5F9814FB634A7BF4C35A6F54029B5@ESEALNT442.al.sw.ericsson.se> References: <37FB7AA6F5F9814FB634A7BF4C35A6F54029B5@ESEALNT442.al.sw.ericsson.se> Message-ID: "Ulf Wiger (AL/EAB)" writes: [...] > which happens to work just like (the undocumented) lists:zip([1,2,3,4], [a,b,c,d]) in Erlang. lists:zip/2 and friends are documented in OTP-R10B-1. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From ulf.wiger@REDACTED Wed Dec 1 10:22:37 2004 From: ulf.wiger@REDACTED (Ulf Wiger (AL/EAB)) Date: Wed, 1 Dec 2004 10:22:37 +0100 Subject: parallel LC Message-ID: <37FB7AA6F5F9814FB634A7BF4C35A6F54029B9@ESEALNT442.al.sw.ericsson.se> > lists:zip/2 and friends are documented in OTP-R10B-1. > > /Bjorn OK, great... but then the "Erlang/OTP R10B documentation" link at http://www.erlang.org/doc.html doesn't point to OTP R10B_1. /Uffe From ulf.wiger@REDACTED Wed Dec 1 11:11:18 2004 From: ulf.wiger@REDACTED (Ulf Wiger (AL/EAB)) Date: Wed, 1 Dec 2004 11:11:18 +0100 Subject: risky_shell Message-ID: <37FB7AA6F5F9814FB634A7BF4C35A6F54029BA@ESEALNT442.al.sw.ericsson.se> Am I just blind, or is the command-line flag -risky_shell undocumented? The stdlib release notes for OTP R10B_1 mention that there is a possibility to start the Erlang shell in parallel with the rest of the system, but there's no explanation of how this is done (fortunately, there's always the source code... :-) Perhaps at least the release notes could mention the name of the flag that makes this possible, if you don't want the 'erl' documentation in ERTS to mention it? The idea behind re-introducing this "bug" was that it is sometimes very important to be able to trace on the application start sequence. One convenient way of doing this is to simply enter calls to e.g. dbg in the shell. /Uffe From bjarne@REDACTED Wed Dec 1 11:59:34 2004 From: bjarne@REDACTED (=?Windows-1252?Q?Bjarne_D=E4cker?=) Date: Wed, 1 Dec 2004 11:59:34 +0100 Subject: Joe's promotion Message-ID: <001701c4d794$e4f660a0$b10e69d4@segeltorp> Hello A year ago, Joe successfully defended his thesis "Making reliable distributed systems in the presence of software errors" and on December 19 this year, he received his diploma (together with > 200 other new doctors) at a formal occassion in the town hall in Stockholm. Some photos from this happening can be view at http://www.cs-lab.org/joes_promotion/ Bjarne -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Wed Dec 1 12:57:16 2004 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 1 Dec 2004 12:57:16 +0100 (MET) Subject: New test release of EDoc - feedback wanted In-Reply-To: <41AC8056.70303@csd.uu.se> References: <37FB7AA6F5F9814FB634A7BF4C35A6F54029B4@ESEALNT442.al.sw.ericsson.se> <41AC8056.70303@csd.uu.se> Message-ID: On Tue, 30 Nov 2004, Richard Carlsson wrote: > Ulf Wiger (AL/EAB) wrote: > > > > How do the syntax_tools and xmerl archives in that > > same location compare with the ones in OTP R10B? > > The R10B version did not have the new verbatim-quoting > (at least not officially and in the current form), nor > the improved scanning, nor proper try-expression support. Wow - I obviously did not read the question properly. Sorry. At least I answered the part about the syntax tools (scanning and try-expressions). The quoting stuff is in EDoc. The xmerl tarball is just there for completeness. It should not differ from the OTP R10B version. /yxskaft Richard Carlsson (richardc@REDACTED) (This space intentionally left blank.) E-mail: Richard.Carlsson@REDACTED WWW: http://user.it.uu.se/~richardc/ "Having users is like optimization: the wise course is to delay it." -- Paul Graham From matthias@REDACTED Wed Dec 1 13:01:15 2004 From: matthias@REDACTED (Matthias Lang) Date: Wed, 1 Dec 2004 13:01:15 +0100 Subject: Joe's promotion In-Reply-To: <001701c4d794$e4f660a0$b10e69d4@segeltorp> References: <001701c4d794$e4f660a0$b10e69d4@segeltorp> Message-ID: <16813.45707.741223.507816@antilipe.corelatus.se> Bjarne D?cker writes: > on December 19 this year, he received his diploma (together > with > 200 other new doctors) at a formal occassion in the town > hall in Stockholm. And on the 26th. January 2005, Joe invented the time machine which allowed him to accomplish the above ;-) (Maybe it was the 19th. of November) Matthias From tobbe@REDACTED Wed Dec 1 13:15:34 2004 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 01 Dec 2004 13:15:34 +0100 Subject: Joe's promotion In-Reply-To: <001701c4d794$e4f660a0$b10e69d4@segeltorp> References: <001701c4d794$e4f660a0$b10e69d4@segeltorp> Message-ID: <41ADB5E6.4040507@nortelnetworks.com> Nice photos! I wonder what Joe told Jan Uddenfeldt... /Tobbe Bjarne D?cker wrote: > Hello > > A year ago, Joe successfully defended his > thesis "Making reliable distributed systems > in the presence of software errors" and on > December 19 this year, he received his > diploma (together with > 200 other new > doctors) at a formal occassion in the town > hall in Stockholm. > > Some photos from this happening can > be view at > > http://www.cs-lab.org/joes_promotion/ > > Bjarne > > > From erlang@REDACTED Wed Dec 1 13:55:33 2004 From: erlang@REDACTED (Peter-Henry Mander) Date: Wed, 1 Dec 2004 12:55:33 +0000 Subject: Joe's promotion In-Reply-To: <16813.45707.741223.507816@antilipe.corelatus.se> References: <001701c4d794$e4f660a0$b10e69d4@segeltorp> <16813.45707.741223.507816@antilipe.corelatus.se> Message-ID: <20041201125533.3add6ba3.erlang@manderp.freeserve.co.uk> Hang on, it {must have been,will be} Bjarne who invent{ed,s} the time machine... How does English grammar express this tense? Pete. On Wed, 1 Dec 2004 13:01:15 +0100 Matthias Lang wrote: > > > on December 19 this year, he received his diploma (together > > with > 200 other new doctors) at a formal occassion in the town > > hall in Stockholm. > > And on the 26th. January 2005, Joe invented the time machine which > allowed him to accomplish the above ;-) > > (Maybe it was the 19th. of November) > > Matthias -- "The Tao of Programming flows far away and returns on the wind of morning." From joe@REDACTED Wed Dec 1 15:01:13 2004 From: joe@REDACTED (Joe Armstrong) Date: Wed, 1 Dec 2004 15:01:13 +0100 (CET) Subject: Joe's promotion In-Reply-To: <41ADB5E6.4040507@nortelnetworks.com> References: <001701c4d794$e4f660a0$b10e69d4@segeltorp> <41ADB5E6.4040507@nortelnetworks.com> Message-ID: > Nice photos! > > I wonder what Joe told Jan Uddenfeldt... > That Erlang was great and was going to earn oodels of $'s for Ericsson :-) /Joe > /Tobbe > > > Bjarne D?cker wrote: > >> Hello >> A year ago, Joe successfully defended his >> thesis "Making reliable distributed systems >> in the presence of software errors" and on >> December 19 this year, he received his >> diploma (together with > 200 other new >> doctors) at a formal occassion in the town >> hall in Stockholm. >> Some photos from this happening can >> be view at >> http://www.cs-lab.org/joes_promotion/ >> Bjarne >> > > From tobbe@REDACTED Wed Dec 1 15:08:55 2004 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Wed, 01 Dec 2004 15:08:55 +0100 Subject: Joe's promotion In-Reply-To: References: <001701c4d794$e4f660a0$b10e69d4@segeltorp> <41ADB5E6.4040507@nortelnetworks.com> Message-ID: <41ADD077.4030003@nortelnetworks.com> Joe Armstrong wrote: > > >> Nice photos! >> >> I wonder what Joe told Jan Uddenfeldt... >> > > That Erlang was great and was going to earn oodels of $'s for > Ericsson :-) You should have said: "....is earning oodels of $'s for Nortel" ;-) Tobbe > > /Joe > > >> /Tobbe >> >> >> Bjarne D?cker wrote: >> >>> Hello >>> A year ago, Joe successfully defended his >>> thesis "Making reliable distributed systems >>> in the presence of software errors" and on >>> December 19 this year, he received his >>> diploma (together with > 200 other new >>> doctors) at a formal occassion in the town >>> hall in Stockholm. >>> Some photos from this happening can >>> be view at >>> http://www.cs-lab.org/joes_promotion/ >>> Bjarne >>> >> > >>> Bjarne www.cs-lab.org/joes_promotion/ own >>> oodels of $'s for >>> ?A??Ex??@??E,??@H?E???@?E?@??E'??@0?E9??@x?E??A??E???A?E??@I(E???A?E=??@??E >> From carsten@REDACTED Wed Dec 1 15:18:09 2004 From: carsten@REDACTED (Carsten Schultz) Date: Wed, 1 Dec 2004 15:18:09 +0100 Subject: String search in a binary Message-ID: <20041201141808.GB16118@penne.localnet> Hi! I have the following piece of code: extract_contents(Bin) when binary(Bin) -> Str = binary_to_list(Bin), Start = string:str(Str, ""), Len = End-Start-1, <<_:Start/binary, C:Len/binary, _/binary>> = Bin, C. The binary_to_list is bothering me. Is there a short and efficient version doing the same? Thanks, Carsten -- Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin http://carsten.codimi.de/ PGP/GPG key on the pgp.net key servers, fingerprint on my home page. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From magnus.thoang@REDACTED Wed Dec 1 15:56:32 2004 From: magnus.thoang@REDACTED (=?ISO-8859-1?Q?Magnus_Tho=E4ng?=) Date: Wed, 01 Dec 2004 15:56:32 +0100 Subject: String search in a binary In-Reply-To: <20041201141808.GB16118@penne.localnet> References: <20041201141808.GB16118@penne.localnet> Message-ID: <41ADDBA0.5020608@ericsson.com> Carsten Schultz wrote: ... > I have the following piece of code: > > extract_contents(Bin) when binary(Bin) -> > Str = binary_to_list(Bin), > Start = string:str(Str, " End = string:rstr(Str, ""), > Len = End-Start-1, > <<_:Start/binary, C:Len/binary, _/binary>> = Bin, > C. > > The binary_to_list is bothering me. Is there a short and efficient > version doing the same? ... IIRC, the string:str function is a brute-force text search, so you don't gain any performance by using it. You might do something like... extract_contents(Bin) when binary(Bin) -> extract_contents(Bin, 0). extract_contents(Bin, Offset) -> case Bin of <<_:Offset/binary,"> -> extract_body(Rest,0); _ -> extract_contents(Bin, Offset + 1) end. extract_body(Bin, Offset) -> case Bin of <",_/binary>> -> Body; _ -> extract_body(Bin, Offset + 1) end. ...but since you are not parameterizing the start and end strings, you could probably hard-code some clever advancing of the Offset when not hitting the strings. The reason for using case clauses instead of matching with function clauses is simply that (for unknown reasons) the syntax is not allowed in the function head. -- Magnus Tho?ng From bjorn@REDACTED Wed Dec 1 16:25:26 2004 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 01 Dec 2004 16:25:26 +0100 Subject: parallel LC In-Reply-To: <37FB7AA6F5F9814FB634A7BF4C35A6F54029B9@ESEALNT442.al.sw.ericsson.se> References: <37FB7AA6F5F9814FB634A7BF4C35A6F54029B9@ESEALNT442.al.sw.ericsson.se> Message-ID: "Ulf Wiger (AL/EAB)" writes: > OK, great... but then the "Erlang/OTP R10B documentation" > link at http://www.erlang.org/doc.html doesn't point to > OTP R10B_1. We have fixed it now. Thanks for pointing it out! /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From bjorn@REDACTED Wed Dec 1 16:36:14 2004 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 01 Dec 2004 16:36:14 +0100 Subject: crypto and ssl modules under OSX In-Reply-To: <75597826-39B5-11D9-AF62-000A95927CCE@mac.com> References: <75597826-39B5-11D9-AF62-000A95927CCE@mac.com> Message-ID: Actually, we DID get that part correct in R10B (getting rid of -R for Mac OS X). Unfortunately, there is another problem... which I think I have solved now. If my change doesn't break linking on some other platform, it shold appear in R10B-2. /Bjorn Sean Hinde writes: > I have submitted a patch for this more times than I care to remember. > > In addition the correct mechanism is described in Erlang/OTPs very own > README file. > > Please try to get this right for OS X next time. > > Sean > > On 18 Nov 2004, at 11:34, Peter H|gfeldt wrote: > > > > > Just remove the -R switch from the Makefile. In R10B the -R switch is > > not included for OSX (or is it called Darwin?). > > > > /Peter > > > > > > On Wed, 17 Nov 2004, Reto Kramer wrote: > > > >> I'm trying to build the R9C-2 ssl and crypto under OSX 10.3.4. Can > >> some > >> BSD/Mac guru out there help me figure out how to change the ld > >> switches > >> (under OSX, the R option of the -Wl switch is not available). > >> > >> Thanks, > >> - Reto > >> > >> from: otp_src_R9C-2/otp_src_R9C-2/lib/crypto/c_src/Makefile.in > >> > >> $(LIBDIR)/crypto_drv.so: $(OBJS) > >> $(INSTALL_DIR) $(LIBDIR) > >> $(CC) $(LDFLAGS) -L$(SSL_LIBDIR) -Wl,-R$(SSL_LIBDIR) \ > >> -o $@ $^ $(LDLIBS) -lcrypto > >> > >> > >> === Entering application crypto > >> make[3]: Nothing to be done for `opt'. > >> make -f powerpc-apple-darwin7.5.0/Makefile TYPE=opt > >> /usr/bin/install -c -d ../priv/lib/powerpc-apple-darwin7.5.0 > >> gcc -bundle -flat_namespace -undefined suppress -lbundle1.o -L/usr/lib > >> -Wl,-R/usr/lib \ > >> -o ../priv/lib/powerpc-apple-darwin7.5.0/crypto_drv.so > >> ../priv/obj/powerpc-apple-darwin7.5.0/crypto_drv.o -lcrypto > >> ld: unknown flag: -R/usr/lib > >> === Skipping subdir doc/src, it is missing > >> === Leaving application crypto > >> > >> # > >> > > > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From jamesh@REDACTED Wed Dec 1 17:47:38 2004 From: jamesh@REDACTED (James Hague) Date: Wed, 1 Dec 2004 10:47:38 -0600 Subject: Finding unique elements of a list Message-ID: Is there a standard Erlang library function or idiom for removing duplicate items from an unsorted list? Ideally the elements in the final list should be in the order they were passed in, except without duplicates: [3,5,2,2,3] -> [3,5,2]. If order doesn't matter there are some easy options: 1. lists:usort(L) 2. gb_sets:to_list(gb_sets:from_list(L)) If order does matter, then the only thing I've come up with is to build an ets table or gb_set iteratively, adding each element not previously in the table or set to a list of unique items. Is there an obvious library function I'm not seeing? Feels like there should be lists:unique/1. From ulf.wiger@REDACTED Wed Dec 1 18:10:23 2004 From: ulf.wiger@REDACTED (Ulf Wiger (AL/EAB)) Date: Wed, 1 Dec 2004 18:10:23 +0100 Subject: Finding unique elements of a list Message-ID: <37FB7AA6F5F9814FB634A7BF4C35A6F54029C5@ESEALNT442.al.sw.ericsson.se> To my knowledge, there's no such function. Not that I doubt your ability to write one yourself, but here's a suggestion: u(L) -> u(L, []). u([H|T], Acc) -> case lists:member(H,Acc) of true -> u(T, Acc); false -> u(T, [H|Acc]) end; u([], Acc) -> lists:reverse(Acc). Here's another one, shorter, O(1), and, most importantly, cuter (functional purists may retch at will): u2(L) -> T = ets:new(temp,[set]), L1 = lists:filter(fun(X) -> ets:insert_new(T, {X,1}) end, L), ets:delete(T), L1. Works only on newer erlangs (newest R9C and R10, I believe). /Uffe > -----Original Message----- > From: owner-erlang-questions@REDACTED > [mailto:owner-erlang-questions@REDACTED]On Behalf Of James Hague > Sent: den 1 december 2004 17:48 > To: 'erlang-questions@REDACTED' > Subject: Finding unique elements of a list > > > Is there a standard Erlang library function or idiom for > removing duplicate > items from an unsorted list? Ideally the elements in the > final list should > be in the order they were passed in, except without duplicates: > > [3,5,2,2,3] -> [3,5,2]. > > If order doesn't matter there are some easy options: > > 1. lists:usort(L) > 2. gb_sets:to_list(gb_sets:from_list(L)) > > If order does matter, then the only thing I've come up with > is to build an > ets table or gb_set iteratively, adding each element not > previously in the > table or set to a list of unique items. Is there an obvious library > function I'm not seeing? Feels like there should be lists:unique/1. > From carsten@REDACTED Wed Dec 1 18:29:56 2004 From: carsten@REDACTED (Carsten Schultz) Date: Wed, 1 Dec 2004 18:29:56 +0100 Subject: Finding unique elements of a list In-Reply-To: References: Message-ID: <20041201172955.GA23307@penne.localnet> Hi! On Wed, Dec 01, 2004 at 10:47:38AM -0600, James Hague wrote: > Is there a standard Erlang library function or idiom for removing duplicate > items from an unsorted list? Ideally the elements in the final list should > be in the order they were passed in, except without duplicates: > > [3,5,2,2,3] -> [3,5,2]. > > If order doesn't matter there are some easy options: > > 1. lists:usort(L) > 2. gb_sets:to_list(gb_sets:from_list(L)) > > If order does matter, and you do not care for performance, then a quick solution would be unique([]) -> []; unique([H|T]) -> [H|unique(lists:filter(fun(X) -> X =/= H end, T))]. But, yes, this is more reasonable in Haskell and stolen from its library :-) > then the only thing I've come up with is to build an ets table or > gb_set iteratively, adding each element not previously in the table > or set to a list of unique items. Definitely the better option. Sorry, that probably was not really helpful... Greetings, Carsten -- Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin http://carsten.codimi.de/ PGP/GPG key on the pgp.net key servers, fingerprint on my home page. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From jamesh@REDACTED Wed Dec 1 20:21:02 2004 From: jamesh@REDACTED (James Hague) Date: Wed, 1 Dec 2004 13:21:02 -0600 Subject: Finding unique elements of a lis Message-ID: Ulf Wiger wrote: >u2(L) -> > T = ets:new(temp,[set]), > L1 = lists:filter( > fun(X) -> ets:insert_new(T, {X,1}) end, L), > ets:delete(T), > L1. Oooh, that's pretty. My implementation did essentially the same thing, but I didn't use filter. I suggest this function get added to stdlib as lists:unique/1. James From ulf.wiger@REDACTED Wed Dec 1 21:14:27 2004 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 01 Dec 2004 21:14:27 +0100 Subject: Finding unique elements of a list In-Reply-To: <37FB7AA6F5F9814FB634A7BF4C35A6F54029C5@ESEALNT442.al.sw.ericsson.se> References: <37FB7AA6F5F9814FB634A7BF4C35A6F54029C5@ESEALNT442.al.sw.ericsson.se> Message-ID: On Wed, 1 Dec 2004 18:10:23 +0100, Ulf Wiger (AL/EAB) wrote: > Here's another one, shorter, O(1), [...] Now wouldn't that have been neat? I meant O(N), of course. /Uffe -- Ulf Wiger From vances@REDACTED Wed Dec 1 21:30:02 2004 From: vances@REDACTED (Vance Shipley) Date: Wed, 1 Dec 2004 15:30:02 -0500 Subject: Finding unique elements of a list In-Reply-To: <37FB7AA6F5F9814FB634A7BF4C35A6F54029C5@ESEALNT442.al.sw.ericsson.se> References: <37FB7AA6F5F9814FB634A7BF4C35A6F54029C5@ESEALNT442.al.sw.ericsson.se> Message-ID: <20041201203002.GA24653@frogman.motivity.ca> On Wed, Dec 01, 2004 at 06:10:23PM +0100, Ulf Wiger (AL/EAB) wrote: } } } Here's another one, shorter, O(1), and, most importantly, } cuter (functional purists may retch at will): } } u2(L) -> } T = ets:new(temp,[set]), } L1 = lists:filter(fun(X) -> ets:insert_new(T, {X,1}) end, L), } ets:delete(T), } L1. Those that retched may prefer this: :) u2(L) -> u2(L, [], gb_sets:empty()). u2([H|T], Acc, S) -> case catch gb_sets:insert(H, S) of {'EXIT', _} -> u2(T, Acc, S); N -> u2(T, [H|Acc], N); end; u2([], Acc, _S) -> lists:reverse(Acc). -Vance From jamesh@REDACTED Wed Dec 1 21:35:55 2004 From: jamesh@REDACTED (James Hague) Date: Wed, 1 Dec 2004 14:35:55 -0600 Subject: dict and set variants Message-ID: stdlib has three modules each for sets and dicts (key/value pairs): sets: sets, ordsets, gb_sets dicts: dict, orddict, gb_trees (and ets, I suppose :) (BTW, notice the naming discrepancy. Most are plural, some aren't.) So, what's the rationale behind three versions of each? This doesn't appear to be explained anywhere. To the best of my knowledge, sets/dict have been superceded by gb_sets/gb_trees (am I alone in thinking that the names gb_sets and gb_trees are horrible?). I'm not sure if there are reasons to use sets/dict any more (should they go away?). ordsets/orddict are lighter-weight modules that just store everything in a big list. Great for small amounts of data, not so good when things get huge. Am I close? From erlang-list@REDACTED Wed Dec 1 22:40:53 2004 From: erlang-list@REDACTED (Dominic Williams) Date: Wed, 01 Dec 2004 22:40:53 +0100 Subject: Finding unique elements of a list In-Reply-To: References: Message-ID: <41AE3A65.8000200@dominicwilliams.net> FWIW, the version I have in my own lib is: unique(List) -> lists:reverse( lists:foldl( fun(X,Acc) -> accumulate_unless(lists:member(X,Acc),X,Acc) end, [], List)). accumulate_unless(true, _X, Acc) -> Acc; accumulate_unless(false, X, Acc) -> [X|Acc]. Regards, Dominic Williams http://www.dominicwilliams.net ---- From matthias@REDACTED Thu Dec 2 10:50:45 2004 From: matthias@REDACTED (Matthias Lang) Date: Thu, 2 Dec 2004 10:50:45 +0100 Subject: dict and set variants In-Reply-To: References: Message-ID: <16814.58741.791545.541634@antilipe.corelatus.se> James Hague writes: > stdlib has three modules each for sets and dicts (key/value pairs): > > sets: sets, ordsets, gb_sets > dicts: dict, orddict, gb_trees (and ets, I suppose :) > > (BTW, notice the naming discrepancy. Most are plural, some aren't.) > > So, what's the rationale behind three versions of each? There isn't any, it's just various people letting code escape from the lab before it got cleaned up and then writing some half-hearted documentation before going on to something more interesting. My favourite is this bit in the 'ordsets' documentation: "An ordered list is more efficient than an unordered list." -------------------- Anyone care to extend and correct this table? implementation insert find traverse:random/in-order ---------------------------------------------------------------------- sets hash? 1 ? 1 ? N /not-possible ordsets sorted list N N N /N list list 1 N N /not-possible gb_sets tree lg N lg N N ? /N lg N ets hash 1 1 N /N 'N' means O(N), 'lg N' means O(log N), etc. I haven't tried to indicate whether the bound is worst-case or on-average because, in general, I don't know. I think a random traverse of a gb_set is O(N), but the documentation doesn't actually promise that, so maybe it's O(log N). (Keep in mind that the overhead isn't shown above and that it often does matter. There's little point using a tree when your set has ten members.) Matthias From thomasl_erlang@REDACTED Thu Dec 2 11:22:42 2004 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 2 Dec 2004 02:22:42 -0800 (PST) Subject: Finding unique elements of a list In-Reply-To: Message-ID: <20041202102242.38694.qmail@web41902.mail.yahoo.com> Here is a straightforward version with good O(.): first sort the list, then drop consecutive duplicates. Complexity is given by the sort (assuming unit cost of comparing elements). O(N log N), presumably? unique(Xs) -> rem_dups(lists:sort(Xs)). rem_dups([X|Xs]) -> [X|drop(X, Xs)]; rem_dups([]) -> []. drop(X, [X|Xs]) -> drop(X, Xs); drop(X, Ys) -> rem_dups(Ys). The code above seems to work, but could be optimized further; which is left as an exercise to the reader. Best, Thomas __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From ulf.wiger@REDACTED Thu Dec 2 11:34:34 2004 From: ulf.wiger@REDACTED (Ulf Wiger (AL/EAB)) Date: Thu, 2 Dec 2004 11:34:34 +0100 Subject: Finding unique elements of a list Message-ID: <37FB7AA6F5F9814FB634A7BF4C35A6F54029CC@ESEALNT442.al.sw.ericsson.se> > From: Vance Shipley [mailto:vances@REDACTED] > Those that retched may prefer this: :) > > u2(L) -> > u2(L, [], gb_sets:empty()). > u2([H|T], Acc, S) -> > case catch gb_sets:insert(H, S) of > {'EXIT', _} -> > u2(T, Acc, S); > N -> > u2(T, [H|Acc], N); > end; > u2([], Acc, _S) -> > lists:reverse(Acc). This has the desireable property that the elements of the list are not duplicated (since inserting them in a heap-based structure only means copying the pointer. My ets-based version would duplicate all elements in the final list, which could of course be very costly if the elements are large. /Uffe From carsten@REDACTED Thu Dec 2 12:10:37 2004 From: carsten@REDACTED (Carsten Schultz) Date: Thu, 2 Dec 2004 12:10:37 +0100 Subject: Finding unique elements of a list In-Reply-To: <20041202102242.38694.qmail@web41902.mail.yahoo.com> References: <20041202102242.38694.qmail@web41902.mail.yahoo.com> Message-ID: <20041202111036.GA24436@penne.localnet> Hi Thomas! On Thu, Dec 02, 2004 at 02:22:42AM -0800, Thomas Lindgren wrote: > > Here is a straightforward version with good O(.): > first sort the list, then drop consecutive duplicates. Please read the original question and also note the existence of lists:usort :-) Take care, Carsten -- Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin http://carsten.codimi.de/ PGP/GPG key on the pgp.net key servers, fingerprint on my home page. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From carsten@REDACTED Thu Dec 2 12:22:26 2004 From: carsten@REDACTED (Carsten Schultz) Date: Thu, 2 Dec 2004 12:22:26 +0100 Subject: Finding unique elements of a list In-Reply-To: <37FB7AA6F5F9814FB634A7BF4C35A6F54029C5@ESEALNT442.al.sw.ericsson.se> References: <37FB7AA6F5F9814FB634A7BF4C35A6F54029C5@ESEALNT442.al.sw.ericsson.se> Message-ID: <20041202112225.GB24436@penne.localnet> Hi Uffe! On Wed, Dec 01, 2004 at 06:10:23PM +0100, Ulf Wiger (AL/EAB) wrote: > Here's another one, shorter, O(1), and, most importantly, > cuter Hmm... > (functional purists may retch at will): I have just learned a new word ;-) Ok, since you asked for it... > u2(L) -> > T = ets:new(temp,[set]), > L1 = lists:filter(fun(X) -> ets:insert_new(T, {X,1}) end, L), > ets:delete(T), > L1. The documentation of lists:filter does not say anything about the order in which the predicate function is called for the various list elements. It does not even state if it is called several times if an element appears several times. This is nasty. But nastyness and cuteness go together often enough, so who cares. Take care, Carsten -- Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin http://carsten.codimi.de/ PGP/GPG key on the pgp.net key servers, fingerprint on my home page. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From magnus.thoang@REDACTED Thu Dec 2 12:53:27 2004 From: magnus.thoang@REDACTED (=?ISO-8859-1?Q?Magnus_Tho=E4ng?=) Date: Thu, 02 Dec 2004 12:53:27 +0100 Subject: String search in a binary In-Reply-To: <41ADDBA0.5020608@ericsson.com> References: <20041201141808.GB16118@penne.localnet> <41ADDBA0.5020608@ericsson.com> Message-ID: <41AF0237.7070508@ericsson.com> Magnus Tho?ng wrote: > IIRC, the string:str function is a brute-force text search, so you don't > gain any performance by using it. > ... Ooops. This was not true. Some testing reveals that traversing a list (as in string:str/2) is faster than traversing a binary in the way I suggested... Sorry :-) -- Magnus Tho?ng From thomasl_erlang@REDACTED Thu Dec 2 15:35:11 2004 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 2 Dec 2004 06:35:11 -0800 (PST) Subject: Finding unique elements of a list In-Reply-To: <16814.61552.715963.431243@harpo.it.uu.se> Message-ID: <20041202143511.98326.qmail@web41906.mail.yahoo.com> --- Sven-Olof Nystr|m wrote: > Also, the original poster required that the > order of the input > list should be preserved. Besides that, nice try :-) Yes, I somehow forgot that requirement ... sorry about that :-) Oh well. Best, Thomas __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail From heinrich@REDACTED Thu Dec 2 15:33:27 2004 From: heinrich@REDACTED (Heinrich Venter) Date: Thu, 2 Dec 2004 16:33:27 +0200 Subject: Http_response funny Message-ID: Hi I am using http:request (inets 4.0) to do a SOAP request. The status line has a type of "100 Continue". I get an error because the function http_response:status_continue returns only ok when the httpc_handler:handle_response case statements expect something like {ok, ""} Simply replacing the ok with {ok, ""} breaks rest of the resonses because now the next status line is deemed as part of the body of the "100 Continue" response. Stil looking for a solution to this. Any one seen this before? -]-[einrich Click here for more information. http://asp1.rocketseed.com/RocketSeed/mail/433a32353a3839353032313a33303639373a2d323a313831 Bought to you by Launchpad. http://asp1.rocketseed.com/RocketSeed/mail/433a32353a3839353032313a33303639373a2d323a313438 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: MTk2LjMwLjc5LjE1NQ== Type: image/gif Size: 557 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: MTk2LjMwLjc5LjE1NQ== Type: image/gif Size: 16459 bytes Desc: not available URL: From thomasl_erlang@REDACTED Thu Dec 2 16:30:57 2004 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 2 Dec 2004 07:30:57 -0800 (PST) Subject: Finding unique elements of a list In-Reply-To: <16815.11933.395850.484405@harpo.it.uu.se> Message-ID: <20041202153057.64471.qmail@web41901.mail.yahoo.com> --- Sven-Olof Nystr|m wrote: > Removing duplicates with sort assumes that < is a > total > ordering. Unfortunately it is not: We have neither 1 > < 1.0 nor 1.0 < 1 > Thus, trying to remove the duplicates of a list of > floats and integers > will give strange results. > > 3> tl:unique([1,1.0,1,1.0]). > [1,1.00000,1,1.00000] As far as I can tell from lists.erl, sort seems to use ==/2 to actually get a total ordering; since 1 == 1.0, we get the effect of "mixed" floats and integers. Perhaps someone closer acquainted with sort can tell us the real story. Rewriting drop/2 of my original program to use ==/2 instead of pattern matching yields [1.00000] for the example above, eliminating all duplicates (as far as ==/2 is concerned). At this point, those of a legalistic bent may perk up and begin to ask what defines a "unique" element ... :-) Moral of the story: stay away from floats? Best, Thomas __________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail From ulf.wiger@REDACTED Thu Dec 2 17:17:58 2004 From: ulf.wiger@REDACTED (Ulf Wiger (AL/EAB)) Date: Thu, 2 Dec 2004 17:17:58 +0100 Subject: risky_shell Message-ID: <37FB7AA6F5F9814FB634A7BF4C35A6F54029D3@ESEALNT442.al.sw.ericsson.se> > -----Original Message----- > From: peppe@REDACTED [mailto:peppe@REDACTED] > We have not documented the details because we don't want > people to use this flag and, like you, become dependent on > the old shell startup behaviour. So don't push me or I'll > take away this flag of yours! :-) I thought my suggestion to mention the name of the flag in the release notes only was quite reasonable. (-: > The old parallell startup behaviour *could* be useful to > start tracing early. *Is* useful. Feel free to provide a list of *more* useful ways to accomplish the same thing. ;-) (I believe this was the main reason why you agreed to put it back in...) > But since it is indeed parallell and the time to start > the shell process depends on e.g. io speed, it must be an > unpredictable way to start tracing an application start > sequence. Indeed. Depending on how quickly the situation occurs that you want to trace, it can be difficult to get the commands entered quickly enough. People here have learned to keep such commands in a text editor window, and then select a bunch of lines at a time, and copy and paste into the erlang shell. Also, a system the size of the AXD 301 doesn't start *that* quickly. Code loading alone takes nearly one minute (actually, this happens before even the old shell appears, when embedded loading is used), and loading the Mnesia database from disk takes another minute (and we have code that makes sure that no "interesting" applications start before Mnesia is done loading). For many of the sequences that one might want to trace on, there's plenty of time. OK, I didn't really mean to push you to make the feature "documented" in the sense that it would encourage people to depend on it. Tracing early on a system *is* difficult, and there is no single good way to do it. I welcome initiatives to relieve people of the challenge of pasting in shell commands quickly enough to catch the bug, but not so quickly that they break something. (-: In the meantime, one might even want to have a "tricky fault finding" tutorial, where anything goes, of course with all the appropriate disclaimers. If I may, there are some documented functions where users are *strongly discouraged* from even using them at all. I think this is appropriate. Some examples perhaps: "erlang:bump_reductions(Reductions) [...]This BIF might be removed in a future version of the Beam machine without prior warning. It is unlikely to be implemented in other Erlang implementations. If you think that you must use it, encapsulate it your own wrapper module, and/or wrap it in a catch." "erlang:suspend_process(Pid) Suspends the process Pid. This BIF is intended for debugging only." "[application:]set_env(Application, Par, Val) -> ok [...] Use this function only if you know what you are doing, that is, on your own applications. It is very application and configuration parameter dependent when and how often the value is read by the application, and careless use of this function may put the application in a weird, inconsistent, and malfunctioning state. " /Uffe From peppe@REDACTED Thu Dec 2 18:51:28 2004 From: peppe@REDACTED (UAB L/K Peter Andersson) Date: Thu, 02 Dec 2004 18:51:28 +0100 Subject: risky_shell References: <37FB7AA6F5F9814FB634A7BF4C35A6F54029D3@ESEALNT442.al.sw.ericsson.se> Message-ID: <41AF5620.A085B982@erix.ericsson.se> [...] > > I thought my suggestion to mention the name of the flag in the > release notes only was quite reasonable. (-: > Fair enough, but I'd rather not mention it at all. ;-) > > The old parallell startup behaviour *could* be useful to > > start tracing early. > > *Is* useful. > Feel free to provide a list of *more* useful ways to > accomplish the same thing. ;-) > (I believe this was the main reason why you agreed to > put it back in...) > Maybe the application could start in two steps: First start a tracer process (which evaluates a trace config file, for example), then initiate the main application start sequence. You could maybe use the -s flag to call a main tracer start function (again which perhaps evaluates a trace config file). That should switch on tracing right after erts & kernel, but before your own applications start. If it's not possible for you to have tracing start automatically, but need the option to call these functions manually from the shell, I agree there's no simple straightforward way to sync your application with the shell. I thought the reason you insisted we put the old behaviour back was that it was not feasible for you to change the way you are tracing today in AXD-301, not that this was necessarily the most useful way to accomplish it. With my statement I wanted to say to everyone else: "please find other ways to start tracing of your applications than go experimenting with the old error prone shell start behaviour, which may even give you unpredictable results". Not documenting the flag in question is of course a way of saying the same thing. [...] > > OK, I didn't really mean to push you to make the feature > "documented" in the sense that it would encourage people > to depend on it. > [...] I see your point. I could - and maybe I should - have documented the flag as one of those *strongly discouraged* things. But you know, reintroducing an error (even under somewhat controlled forms) isn't something to be proud of. I thought I could get away with not saying anything to anyone, except you. Then you, of all people, give me away! You'll never get another undocumented flag from me again! :-) /Peppe From heinrich@REDACTED Thu Dec 2 18:59:12 2004 From: heinrich@REDACTED (Heinrich Venter) Date: Thu, 2 Dec 2004 19:59:12 +0200 Subject: Inets 4.0 and HTTP/1.1 "100 Continue" responses Message-ID: It looks like I have managed to fix the problem with the 100 Continue response lines It's a bit messy and I certainly wouldn't recommend any one else use it until the powers that be ok'd it. I am only going to post the bits I changed The idea is that if the "100 Continue" response is recognised, the Body is re-parsed from scratch. I am not sure if all the extra response handling in the parsing case is neccesary. I also don't know if the behavior of the header "expect=100-continue" will stil be correct. -]-[einrich -- httpc_handler.erl handle_response(State = #state{request = Request = #request{id = ID, from = Client}, session = Session, status_line = StatusLine, headers = Headers, body = Body}) -> case lists:member(ID, State#state.canceled) of true -> handle_pipeline( State#state{canceled = lists:delete(ID, State#state.canceled)}); false -> case http_response:result({StatusLine, Headers, Body}, Request, Session) of {ok, ""} -> % redirect handle_pipeline(State); %% Added this {ok, continue} -> {Module, Function, Args} = {http_response, parse, [State#state.max_header_size]}, Data = State#state.body, Method = (State#state.request)#request.method, case Module:Function([Data | Args]) of {ok, Result} -> handle_http_msg(Result, State); {_, whole_body, _} when Method == head -> handle_response(State#state{body = <<>>}); NewMFA -> http_transport:setopts(Session#tcp_session.scheme, Session#tcp_session.socket, [{active, once}]), {noreply, State#state{mfa = NewMFA}} end; %% End addition {ok, Msg} -> http_response:send(Client, Msg), handle_pipeline(State); {stop, Msg} -> http_response:send(Client, Msg), {stop, normal, State} end end. -- http_response.erl %%% RFC2616, Section 10.1.1 %%% Note: %%% - Only act on the 100 status if the request included the %%% "Expect:100-continue" header, otherwise just ignore this response. status_continue(Req = #http_request_h{expect="100-continue"}, Session) -> {_, Body} = Req#request.content, http_transport:send(Session#tcp_session.scheme, Session#tcp_session.socket, Body), {ok, continue}; status_continue(_Req, _Session) -> error_logger:info_msg("Found Continue"), {ok, continue}. Look 4 Help - Click here for more info http://asp1.rocketseed.com/RocketSeed/mail/433a32353a3839353138393a33303639373a2d323a313933 http://asp1.rocketseed.com/RocketSeed/mail/433a32353a3839353138393a33303639373a2d323a313836 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: MTk2LjMwLjc5LjE1NQ== Type: image/gif Size: 19652 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: MTk2LjMwLjc5LjE1NQ== Type: image/gif Size: 556 bytes Desc: not available URL: From parault2@REDACTED Thu Dec 2 19:59:33 2004 From: parault2@REDACTED (Pat29) Date: Thu, 2 Dec 2004 19:59:33 +0100 Subject: newby questions Message-ID: <005f01c4d8a1$0fe66c30$3c6efea9@BLUESKY> Hello, It's my last post about this subject because i solved my problem even it's certainely not the best solution. Use REPOS1.0 to test some Windows configurations with a modified start.bat rem set EJABBERD_CONFIG_PATH=../../../other_apps/ejabberd/src/win32/ejabberd.cfg set EJABBERD_CONFIG_PATH=../../../other_apps/ejabberd/ejabberd.cfg set MNESIA_DIR='"%TMP%/mnesia"' rem To allow more than 1000 opened sockets: set ERL_MAX_PORTS=32000 rem JEAI set JEAI_PATH=../../../other_apps/j-eai set JEAI_CONFIG_PATH=%JEAI_PATH%/priv/ejabberd-jeai.cfg set CREATE_JEAI_DEMO_USERS=true rem explorer index.html start index.html cd erlang\erts-5.3-Windows\bin rem in case of boot problem werl -init_debug echo %EJABBERD_SO_PATH% start werl -gs backend_comm port %* -pa "%EJABBERD_SO_PATH%" -pa "%JEAI_PATH%/yaws/ebin" -mnesia dir %MNESIA_DIR% -yaws embedded 'true' WINXP PRO SP2 -------------------- repos:check() and repos:start(wings) passed but other tests which use sockets failed. Erlang (BEAM) emulator version 5.3.6.3 [source] [threads:0] Eshell V5.3.6.3 (abort with ^G) 1> repos:check(). =INFO REPORT==== 30-Nov-2004::06:08:03 === {"eunit.erl(80)","Running unit tests in module [repos_check]"} =INFO REPORT==== 30-Nov-2004::06:08:03 === {"eunit.erl(118)","Running test repos_check:xmerl_test/0 - passed."} =INFO REPORT==== 30-Nov-2004::06:08:06 === {"eunit.erl(118)","Running test repos_check:ssl_test/0 - passed."} =INFO REPORT==== 30-Nov-2004::06:08:07 === {"eunit.erl(118)","Running test repos_check:crypto_test/0 - passed."} =INFO REPORT==== 30-Nov-2004::06:08:12 === {"eunit.erl(118)","Running test repos_check:gs_test/0 - passed."} {4, 0, [{repos_check,{gs_test,0}}, {repos_check,{crypto_test,0}}, {repos_check,{ssl_test,0}}, {repos_check,{xmerl_test,0}}], []} =INFO REPORT==== 30-Nov-2004::06:08:12 === {"eunit.erl(77)","Test finished\n"} =INFO REPORT==== 30-Nov-2004::06:08:12 === {"eunit.erl(123)","Summary: 4 passed, 0failed"} WINXP PRO SP1 with some KBs ------------------------------------ Like WINXP PRO SP2. WIN2000 PRO ---------------- All test passed but repos:start(wings) failed (OpenGL not installed). WINXP PRO without any SP and KBs ---------------------------------------- All test passed and the ping pong example given in the Getting Start worked fine. Now i can enjoy fully with Erlang/OTP. Thanks again for all peoples for your helps. Pat. From ernie.makris@REDACTED Thu Dec 2 20:25:14 2004 From: ernie.makris@REDACTED (ernie.makris@REDACTED) Date: Thu, 02 Dec 2004 19:25:14 +0000 Subject: qlc debug statements Message-ID: <120220041925.1393.41AF6C1A0001D7CC0000057122070029539C079D050E03D20A07029D0A@comcast.net> Hello fellow erlangers, I was playing around with qlc against an ets table and saw the following debug statements being printed: prep match_spec 2 Opt = {qlc_opt,false,false,-1} I looked inside qlc.erl and found: prep_qlc_lc({single_v1, QFun, CodeF, Qdata0, _, MS, PosFun}, Opt, GOpt) -> %% Filter optional: [?qual_data(QNum, GoI_G, SI_G, {gen, LE_fun}) | Filter] = Qdata0, #prepared{qh = LE0} = Prep = eval_le(LE_fun, GOpt), LuV = find_const_positions(LE0, PosFun, Opt), case LE0 of #qlc_table{trav_MS = true} when MS =/= no_match_spec, LuV =/= false -> io:format("prep match_spec 0 Opt = ~p~n", [Opt]), io:format(" lookup values ~p~n", [LuV]), io:format(" match spec ~p~n", [MS]), LE = LE0#qlc_table{lu_vals = LuV, ms = MS}, may_create_simple(Opt, Prep#prepared{qh = LE}); #qlc_table{} when LuV =/= false -> io:format("prep match_spec 1 Opt = ~p~n", [Opt]), io:format(" lookup values ~p~n", [LuV]), Prep1 = Prep#prepared{qh = LE0#qlc_table{lu_vals = LuV}}, Qdata = [?qual_data(QNum, GoI_G, SI_G, {gen, Prep1}) | Filter], prep_qlc(QFun, CodeF, Qdata, Opt); #qlc_table{trav_MS = true} when MS =/= no_match_spec -> io:format("prep match_spec 2 Opt = ~p~n", [Opt]), may_create_simple(Opt, Prep#prepared{qh = LE0#qlc_table{ms = MS}}); #qlc_list{l = []} -> io:format("pre match_spec empty list~n"), may_create_simple(Opt, Prep); #qlc_list{ms = no_match_spec} when MS =/= no_match_spec -> io:format("pre match_spec list no_match_spec~n"), may_create_simple(Opt, Prep#prepared{qh = LE0#qlc_list{ms = MS}}); #qlc_list{} when MS =/= no_match_spec -> io:format("pre match_spec list match_spec~n"), ListMS = #qlc_list{l = Prep, ms = MS}, may_create_simple(Opt, #prepared{qh = ListMS, is_cached = true}); _ -> io:format("pre match_spec qlc~n"), Qdata = [?qual_data(QNum, GoI_G, SI_G, {gen, Prep}) | Filter], prep_qlc(QFun, CodeF, Qdata, Opt) end; Can this be removed in the next version? Thanks Ernie From sean.hinde@REDACTED Thu Dec 2 23:32:15 2004 From: sean.hinde@REDACTED (Sean Hinde) Date: Thu, 2 Dec 2004 22:32:15 +0000 Subject: crypto and ssl modules under OSX In-Reply-To: References: <75597826-39B5-11D9-AF62-000A95927CCE@mac.com> Message-ID: <04B471F6-44B2-11D9-A09D-000A95927CCE@mac.com> Hi Bjorn, I hope your change gets rid of the undocumented -lbundle1.o and reverts to using the mechanism in the README - namely -bundle, and using the cc program to link rather than ld Quote from README: If you develop linked in drivers (shared library) you need to link using "cc" and the flags "-bundle -flat_namespace -undefined suppress". You also include "-fno-common" in CFLAGS when compiling. Use ".so" as the library suffix. Sean On 1 Dec 2004, at 15:36, Bjorn Gustavsson wrote: > Actually, we DID get that part correct in R10B (getting rid of -R > for Mac OS X). > > Unfortunately, there is another problem... which I think I have > solved now. If my change doesn't break linking on some other platform, > it shold appear in R10B-2. > > /Bjorn > > Sean Hinde writes: > >> I have submitted a patch for this more times than I care to remember. >> >> In addition the correct mechanism is described in Erlang/OTPs very own >> README file. >> >> Please try to get this right for OS X next time. >> >> Sean >> >> On 18 Nov 2004, at 11:34, Peter H|gfeldt wrote: >> >>> >>> Just remove the -R switch from the Makefile. In R10B the -R switch is >>> not included for OSX (or is it called Darwin?). >>> >>> /Peter >>> >>> >>> On Wed, 17 Nov 2004, Reto Kramer wrote: >>> >>>> I'm trying to build the R9C-2 ssl and crypto under OSX 10.3.4. Can >>>> some >>>> BSD/Mac guru out there help me figure out how to change the ld >>>> switches >>>> (under OSX, the R option of the -Wl switch is not available). >>>> >>>> Thanks, >>>> - Reto >>>> >>>> from: otp_src_R9C-2/otp_src_R9C-2/lib/crypto/c_src/Makefile.in >>>> >>>> $(LIBDIR)/crypto_drv.so: $(OBJS) >>>> $(INSTALL_DIR) $(LIBDIR) >>>> $(CC) $(LDFLAGS) -L$(SSL_LIBDIR) -Wl,-R$(SSL_LIBDIR) \ >>>> -o $@ $^ $(LDLIBS) -lcrypto >>>> >>>> >>>> === Entering application crypto >>>> make[3]: Nothing to be done for `opt'. >>>> make -f powerpc-apple-darwin7.5.0/Makefile TYPE=opt >>>> /usr/bin/install -c -d ../priv/lib/powerpc-apple-darwin7.5.0 >>>> gcc -bundle -flat_namespace -undefined suppress -lbundle1.o >>>> -L/usr/lib >>>> -Wl,-R/usr/lib \ >>>> -o ../priv/lib/powerpc-apple-darwin7.5.0/crypto_drv.so >>>> ../priv/obj/powerpc-apple-darwin7.5.0/crypto_drv.o -lcrypto >>>> ld: unknown flag: -R/usr/lib >>>> === Skipping subdir doc/src, it is missing >>>> === Leaving application crypto >>>> >>>> # >>>> >>> >> > > -- > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From richardc@REDACTED Fri Dec 3 01:30:12 2004 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 03 Dec 2004 01:30:12 +0100 Subject: Jungerl edoc/syntax_tools Message-ID: <41AFB394.4030200@csd.uu.se> I've finally updated the versions of edoc and syntax_tools in the jungerl (the code is the same that you can find at http://user.it.uu.se/~richardc/edoc/). /Richard From ok@REDACTED Fri Dec 3 01:52:38 2004 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 3 Dec 2004 13:52:38 +1300 (NZDT) Subject: Finding unique elements of a list Message-ID: <200412030052.iB30qc3u392567@atlas.otago.ac.nz> If you want to remove duplicate elements from a list but otherwise preserve the order of the elements, so that, e.g., remove_dups([3,1,4,1,5,9,2,6,5,3,5,8,9]) -> [3,1,4,5,9,2,6,8] then there is an O(N.lgN) method which goes like this: (1) pair each element with its position number in the list O(N) (2) sort the list of pairs (using whole pairs as keys) O(N.lgN) (3) remove adjacent duplicates O(N) (4) switch the {Elem,Posn} pairs to {Posn,Elem} pairs O(U) where 1 <= U <= N, U is the number of unique elements (5) sort the list of {Posn,Elem} pairs O(U.lgU) (6) strip off the positions, {Posn,Elem} -> Elem In Haskell notation, to keep this message short, remove_dups :: Ord a => [a] -> [a] remove_dups xs = [x | (_,x) <- sort (remdups (sort (zip xs [1..])))] where remdups [] = [] remdups ((x,n) : xns) = (n,x) : remdup2 xns x remdup2 ((y,_) : xns) x | y == x = remdup2 xns x remdup2 xns _ = remdups xns This is a little over twice as slow as simply sorting the elements and removing adjacent duplicates, so it's only something you would use if the original order of the elements mattered. From thomas.xa.johnsson@REDACTED Fri Dec 3 08:45:49 2004 From: thomas.xa.johnsson@REDACTED (Thomas Johnsson XA (LN/EAB)) Date: Fri, 3 Dec 2004 08:45:49 +0100 Subject: Finding unique elements of a list Message-ID: In other functional languages I've used (Haskell, (Lazy) ML,..), I've often used the following variation of quicksort when representing sets as sorted lists without duplicates: (This is Erlang syntax, not Haskell..:-) mkset([M|Xs]) -> mkset([X||X<-Xs,XM]); mkset([]) -> []. Cute, if I may say so myself (:-), but unfortunately O(n^2) when the argument already is a sorted list :-( Erlang has lists:usort, which presumably does the same thing, hopefully more efficiently. (?) -- Thomas From hasse@REDACTED Fri Dec 3 09:02:01 2004 From: hasse@REDACTED (Hans Bolinder) Date: Fri, 3 Dec 2004 09:02:01 +0100 Subject: qlc debug statements In-Reply-To: <120220041925.1393.41AF6C1A0001D7CC0000057122070029539C079D050E03D20A07029D0A@comcast.net> References: <120220041925.1393.41AF6C1A0001D7CC0000057122070029539C079D050E03D20A07029D0A@comcast.net> Message-ID: <16816.7545.356360.485212@gargle.gargle.HOWL> > I was playing around with qlc against an ets table and saw the > following debug statements being printed: > > prep match_spec 2 Opt = {qlc_opt,false,false,-1} > Can this be removed in the next version? It will be fixed in R10B-2 which is due within a couple of weeks. Thanks for pointing it out. Best regards, Hans Bolinder, Erlang/OTP From bjorn@REDACTED Fri Dec 3 10:01:06 2004 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 03 Dec 2004 10:01:06 +0100 Subject: crypto and ssl modules under OSX In-Reply-To: <04B471F6-44B2-11D9-A09D-000A95927CCE@mac.com> References: <75597826-39B5-11D9-AF62-000A95927CCE@mac.com> <04B471F6-44B2-11D9-A09D-000A95927CCE@mac.com> Message-ID: Sean Hinde writes: > Hi Bjorn, > > I hope your change gets rid of the undocumented -lbundle1.o and > reverts to using the mechanism in the README - namely -bundle, and > using the cc program to link rather than ld No, sorry. Our Makefiles must work on all platforms (including other Unixes, Windows, VxWorks and other embedded system). Currently, the Makefiles use the C compiler for compiling and ld for linking. Starting to use the C compiler for linking will probably not work for some platform, so that is not an option. The best way to solve the problem would of course be to choose whether to use gcc or ld for linking on a platform-by-platform basis, but that would require changes to configure.in and many Makefiles in source code and a lot of time for testing. This is not something we can do for a patch release. Maybe for R11B, if it gets high enough priority. /Bjorn > > Quote from README: > > If you develop linked in drivers (shared library) you need to link > using "cc" and the flags "-bundle -flat_namespace -undefined > suppress". You also include "-fno-common" in CFLAGS when > compiling. Use ".so" as the library suffix. > > Sean > > > On 1 Dec 2004, at 15:36, Bjorn Gustavsson wrote: > > > Actually, we DID get that part correct in R10B (getting rid of -R > > for Mac OS X). > > > > Unfortunately, there is another problem... which I think I have > > solved now. If my change doesn't break linking on some other platform, > > it shold appear in R10B-2. > > > > /Bjorn > > > > Sean Hinde writes: > > > >> I have submitted a patch for this more times than I care to remember. > >> > >> In addition the correct mechanism is described in Erlang/OTPs very own > >> README file. > >> > >> Please try to get this right for OS X next time. > >> > >> Sean > >> > >> On 18 Nov 2004, at 11:34, Peter H|gfeldt wrote: > >> > >>> > >>> Just remove the -R switch from the Makefile. In R10B the -R switch is > >>> not included for OSX (or is it called Darwin?). > >>> > >>> /Peter > >>> > >>> > >>> On Wed, 17 Nov 2004, Reto Kramer wrote: > >>> > >>>> I'm trying to build the R9C-2 ssl and crypto under OSX 10.3.4. Can > >>>> some > >>>> BSD/Mac guru out there help me figure out how to change the ld > >>>> switches > >>>> (under OSX, the R option of the -Wl switch is not available). > >>>> > >>>> Thanks, > >>>> - Reto > >>>> > >>>> from: otp_src_R9C-2/otp_src_R9C-2/lib/crypto/c_src/Makefile.in > >>>> > >>>> $(LIBDIR)/crypto_drv.so: $(OBJS) > >>>> $(INSTALL_DIR) $(LIBDIR) > >>>> $(CC) $(LDFLAGS) -L$(SSL_LIBDIR) -Wl,-R$(SSL_LIBDIR) \ > >>>> -o $@ $^ $(LDLIBS) -lcrypto > >>>> > >>>> > >>>> === Entering application crypto > >>>> make[3]: Nothing to be done for `opt'. > >>>> make -f powerpc-apple-darwin7.5.0/Makefile TYPE=opt > >>>> /usr/bin/install -c -d ../priv/lib/powerpc-apple-darwin7.5.0 > >>>> gcc -bundle -flat_namespace -undefined suppress -lbundle1.o > >>>> -L/usr/lib > >>>> -Wl,-R/usr/lib \ > >>>> -o ../priv/lib/powerpc-apple-darwin7.5.0/crypto_drv.so > >>>> ../priv/obj/powerpc-apple-darwin7.5.0/crypto_drv.o -lcrypto > >>>> ld: unknown flag: -R/usr/lib > >>>> === Skipping subdir doc/src, it is missing > >>>> === Leaving application crypto > >>>> > >>>> # > >>>> > >>> > >> > > > > -- > > Bj?rn Gustavsson, Erlang/OTP, Ericsson AB > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From erik.ej.reitsma@REDACTED Fri Dec 3 10:27:53 2004 From: erik.ej.reitsma@REDACTED (Erik Reitsma EJ (RY/ETM)) Date: Fri, 3 Dec 2004 10:27:53 +0100 Subject: Finding unique elements of a list Message-ID: <440A2703A54A8F4FB2AC2AE34F27129D05495B02@ESEALNT889.al.sw.ericsson.se> So what you are saying is, that it is a simple one-liner? remove_dups(L) -> [F||{_,F}<-lists:sort(lists:foldl(fun({H,K},[{_,H}|_]=OL) -> OL; ({H,K},[{K1,H1}|T]) -> [{K,H},{K1,H1}|T]; ({H,K},[]) -> [{K,H}] end,[],lists:sort(element(1,lists:foldl(fun(E,{ResN,CountN}) -> {[{E,CountN}|ResN],CountN+1} end,{[],0},L)))))]. or, not on one line: remove_dups(L) -> [F||{_,F}<- lists:sort( lists:foldl( fun({H,K},[{_,H}|_]=OL) -> OL; ({H,K},[{K1,H1}|T]) -> [{K,H},{K1,H1}|T]; ({H,K},[]) -> [{K,H}] end, [], lists:sort( element( 1, lists:foldl( fun(E,{ResN,CountN}) -> {[{E,CountN}|ResN],CountN+1} end, {[],0}, L) ) ) ) ) ]. :) > If you want to remove duplicate elements from a list but otherwise > preserve the order of the elements, so that, e.g., > > remove_dups([3,1,4,1,5,9,2,6,5,3,5,8,9]) -> [3,1,4,5,9,2,6,8] > > then there is an O(N.lgN) method which goes like this: > (1) pair each element with its position number in the list > O(N) > (2) sort the list of pairs (using whole pairs as keys) > O(N.lgN) > (3) remove adjacent duplicates > O(N) > (4) switch the {Elem,Posn} pairs to {Posn,Elem} pairs > O(U) where 1 <= U <= N, U is the number of unique elements > (5) sort the list of {Posn,Elem} pairs > O(U.lgU) > (6) strip off the positions, {Posn,Elem} -> Elem *Erik. > From ingela@REDACTED Fri Dec 3 11:18:11 2004 From: ingela@REDACTED (Ingela Anderton) Date: Fri, 3 Dec 2004 11:18:11 +0100 Subject: Inets 4.0 and HTTP/1.1 "100 Continue" responses References: Message-ID: <16816.15715.204225.428616@gargle.gargle.HOWL> Heinrich Venter wrote: > It looks like I have managed to fix the problem with the 100 Continue > response lines Well not really! However I will fix it for the next open source release. > The idea is that if the "100 Continue" response is recognised, the Body > is re-parsed from scratch. I am not sure if all the extra response > handling in the parsing case is neccesary. > I also don't know if the behavior of the header "expect=100-continue" > will stil be correct. I do not agree with this idea! When you receive a 100-continue response the body should be sent if the request had a expect:100-continue header and then we wait for the next response from the server or if not we ignore this response and wait for the next response. > %%% RFC2616, Section 10.1.1 > %%% Note: > %%% - Only act on the 100 status if the request included the > %%% "Expect:100-continue" header, otherwise just ignore this response. > status_continue(Req = #http_request_h{expect="100-continue"}, Session) > -> > {_, Body} = Req#request.content, > http_transport:send(Session#tcp_session.scheme, > Session#tcp_session.socket, Body), > {ok, continue}; > > status_continue(_Req, _Session) -> > error_logger:info_msg("Found Continue"), > {ok, continue}. You are however right that this function did not have a correct return value. In fact this could not ever have worked as intended as the first argument is not of type http_request_h! (I think it might be an unfortunate mistake made when evolving the the old unsupported client). Alas testing is of the nature that it can always be improved! -- /Ingela Ericsson AB - OTP team From peppe@REDACTED Thu Dec 2 16:33:02 2004 From: peppe@REDACTED (UAB L/K Peter Andersson) Date: Thu, 02 Dec 2004 16:33:02 +0100 Subject: risky_shell References: <37FB7AA6F5F9814FB634A7BF4C35A6F54029BA@ESEALNT442.al.sw.ericsson.se> Message-ID: <41AF35AE.9EF07908@erix.ericsson.se> Uffe, The release note says: "The possibility to start the erlang shell in parallell with the rest of the system has been reintroduced for backwards compatibility. Note that this old behaviour is error prone and should not be used unless for some reason necessary." By being able to access the system from the shell early during startup, it is easy to crash the system by mistake (since you can't tell what state the system is in). We consider this an error and so in R10 we sync the shell process with init so that it doesn't start until the system is in a safe state. You (i.e. AXD-301) requested we reintroduce the parallell pre-R10 behaviour (not as default, but to be activated by means of a flag). We really didn't want to do this, but agreed because you insisted. Our condition was that we could keep this an *undocumented* "feature" for AXD-301 use only, hopefully (to be removed later when we'd implemented better support for "early tracing"). You agreed you'd use this on your own risk. ;-) We have not documented the details because we don't want people to use this flag and, like you, become dependent on the old shell startup behaviour. So don't push me or I'll take away this flag of yours! :-) The old parallell startup behaviour *could* be useful to start tracing early. But since it is indeed parallell and the time to start the shell process depends on e.g. io speed, it must be an unpredictable way to start tracing an application start sequence. /Peppe "Ulf Wiger (AL/EAB)" wrote: > > Am I just blind, or is the command-line flag -risky_shell undocumented? > > The stdlib release notes for OTP R10B_1 mention that there is a possibility to start the Erlang shell in parallel with the rest of the system, but there's no explanation of how this is done (fortunately, there's always the source code... :-) > > Perhaps at least the release notes could mention the name of the flag that makes this possible, if you don't want the 'erl' documentation in ERTS to mention it? > > The idea behind re-introducing this "bug" was that it is sometimes very important to be able to trace on the application start sequence. One convenient way of doing this is to simply enter calls to e.g. dbg in the shell. > > /Uffe From keymon@REDACTED Fri Dec 3 12:49:45 2004 From: keymon@REDACTED (Hector Rivas Gandara) Date: Fri, 03 Dec 2004 12:49:45 +0100 Subject: invalid data on distribution channel, offending packet Message-ID: <41B052D9.8030108@wanadoo.es> Hi, I'm working with EI library, using it in C++, but I have some problems: I'm using ei_rpc function family, and I'm trying to call this funcion in the erlang node: -module(replyserv). -export[imprime/1]). imprime(X) -> io:format("print: ~w~n",[X]), {echo, X}. I send the rpc (using ei_rpc_to or ei_rpc), but it does not call the function (No print), and fails in ei_rpc_from (if using ei_rpc_to), printint the following message in the erlang console: Got invalid data on distribution channel, offending packet is: <<112,131,104,4,97,6,103,100,0,24,112,101,112,105,116,111,64,116,114,97,110,116,111,114,46,108,102,99,105,97,46,112,114,105,0,0,0,3,0,0,0,0,0,100,0,0,100,0,3,114,101,120,131,104,2,103,100,0,24,112,101,112,105,116,111,64,116,114,97,110,116,111,114,46,108,102,99,105,97,46,112,114,105,0,0,0,3,0,0,0,0,0,104,5,100,0,4,99,97,108,108,100,0,9,114,101,112,108,121,115,101,114,118,100,0,7,105,109,112,114,105,109,101,131,108,0,0,0,1,100,0,4,72,111,108,97,106,100,0,4,117,115,101,114>> Setting the EI_TRACELEVEL=100 the output is: ei_xconnect: Fri Dec 3 12:38:48 2004: -> CONNECT attempt to connect to pepita ei_epmd_r4_port: Fri Dec 3 12:38:48 2004: -> PORT2_REQ alive=pepita ip=192.168.41.68 ei_epmd_r4_port: Fri Dec 3 12:38:48 2004: <- PORT2_RESP result=0 (ok) ei_epmd_r4_port: Fri Dec 3 12:38:48 2004: port=46537 ntype=77 proto=0 dist-high=5 dist-low=5 ei_xconnect: Fri Dec 3 12:38:49 2004: -> CONNECT connected to remote recv_status: Fri Dec 3 12:38:49 2004: <- RECV_STATUS (ok) recv_challenge: Fri Dec 3 12:38:49 2004: <- RECV_CHALLENGE (ok) node = pepita@REDACTED, version = 5, flags = 254, challenge = -1457110599 send_challenge_reply: Fri Dec 3 12:38:49 2004: -> SEND_CHALLENGE_REPLY (ok) challenge = -1143731390, digest = 81600edc recv_challenge_ack: Fri Dec 3 12:38:49 2004: <- RECV_CHALLENGE_ACK (ok) digest = 7c0557fb ei_xconnect: Fri Dec 3 12:38:49 2004: -> CONNECT (ok) remote = pepita -> REG_SEND From: #Pid To: rex {#Pid, {call, replyserv, imprime, [hola], user}} <-- failed ei_rpc_from --> What does that mean? Where is the problem? I've only found a reference a google, and the binary stream seems to be the serialized message. I also get that message **sometimes** with simple send/receive, but that is not deterministic: If I change the name of a variable, it works :? -- Saudos H?ctor From sean.hinde@REDACTED Fri Dec 3 13:59:40 2004 From: sean.hinde@REDACTED (Sean Hinde) Date: Fri, 3 Dec 2004 12:59:40 +0000 Subject: crypto and ssl modules under OSX In-Reply-To: References: <75597826-39B5-11D9-AF62-000A95927CCE@mac.com> <04B471F6-44B2-11D9-A09D-000A95927CCE@mac.com> Message-ID: <31DE51EA-452B-11D9-A09D-000A95927CCE@mac.com> On 3 Dec 2004, at 09:01, Bjorn Gustavsson wrote: > Sean Hinde writes: > >> Hi Bjorn, >> >> I hope your change gets rid of the undocumented -lbundle1.o and >> reverts to using the mechanism in the README - namely -bundle, and >> using the cc program to link rather than ld > > No, sorry. > > Our Makefiles must work on all platforms (including other Unixes, > Windows, VxWorks and other embedded system). Currently, the Makefiles > use the C compiler for compiling and ld for linking. > > Starting to use the C compiler for linking will probably not work > for some platform, so that is not an option. > > The best way to solve the problem would of course be to choose whether > to use > gcc or ld for linking on a platform-by-platform basis, but that would > require changes to configure.in and many Makefiles in source code and > a lot of > time for testing. I don't understand this - there is already an explicit rule done in configure.in for darwin. You already have a DED_LD substitution for precisely this purpose. The patch is trivial: --- configure.in.orig Fri Dec 3 10:17:19 2004 +++ configure.in Fri Dec 3 10:18:13 2004 @@ -1162,8 +1162,9 @@ darwin*) # Mach-O linker: a shared lib and a loadable # object file is not the same thing. - DED_LDFLAGS="-bundle -flat_namespace -undefined suppress -lbundle1.o" + DED_LDFLAGS="-bundle -flat_namespace -undefined suppress" DED_CFLAGS="$DED_CFLAGS -fno-common" + DED_LD="$CC" ;; *) # assume GNU linker and ELF So long as DED_LD is used for linking the various drivers then nothing will be broken - everything else will use the default value of ld. I provided a complete patch set sometime ago to do just this. Equally I don't get the reluctance to tidy up or make any changes to the build procedure. You have a set of Officially Supported platforms, which you presumably can and do test every night in a fully automated way. Unsupported platforms are just that - if you break the build for some ancient version of some weird and wonderful UNIX toolchain as part of a tidy up then the community will provide patches if they care enough. If it becomes broken and no-one notices then that suggests that no-one is using that platform anyway. I see this in action most releases - the *BSD crew submit patches, and Redhat Latest always seems to break something. No-one minds too much, or if they do they either provide a fix it or use a supported platform. You guys should be able to make more use of the open source community, and support of "non-supported" platforms would seem to be a good start. Sean From ingela@REDACTED Fri Dec 3 14:09:41 2004 From: ingela@REDACTED (Ingela Anderton) Date: Fri, 3 Dec 2004 14:09:41 +0100 Subject: Inets 4.0 and HTTP/1.1 "100 Continue" responses References: Message-ID: <16816.26005.832595.884704@gargle.gargle.HOWL> Heinrich Venter wrote: > >When you receive a 100-continue response the body should be sent if the > request had a > >expect:100-continue header and then we wait for the next response from > the server > Do I understand correctly that the received Body is sent back to the > server? If this is the correct behavior, then my suggested change would > be wrong for this case. No, not the received body. The body of the request that was not sent in the first place, instead the client sent an except header so that the server will send a 100-continue response if it will accept the request. This can be handy if the client has a big body that it wants to send and it does not want to send it if the server will reject the request. In this case the next response will not be sent by the server until it receives the body from the client.... > >or if not we ignore this response and wait for the next response. > Agreed, but here is the snag. What I saw in live tests is the Body of a > 100-continue response actually contained the next complete received > response, which was a 200. The reason for this is simply that the > buffer received from the socket contained more than one complete > response (100 and 200). ...however in the case that the server sends a 100-continue and there was no expect-header the next response will come right away. > The assumption that every response will have its own socket event seems > to be wrong. If the 100-continue (and its supposedly empty Body) is I have made no such assumption! (However I missed to think about the condition mentioned above) -- /Ingela Ericsson AB - OTP team From joe@REDACTED Fri Dec 3 14:37:27 2004 From: joe@REDACTED (Joe Armstrong) Date: Fri, 3 Dec 2004 14:37:27 +0100 (CET) Subject: Finding unique elements of a list In-Reply-To: <20041202102242.38694.qmail@web41902.mail.yahoo.com> References: <20041202102242.38694.qmail@web41902.mail.yahoo.com> Message-ID: The optimization leads to (with renaming) unique(Xs) -> remove_consequative(lists:sort(Xs)). remove_consequative([H,H|T]) -> remove_consequative([H|T]); remove_consequative([H|T]) -> [H|remove_consequative(T)]; remove_consequative([]) -> []. (Now this is the way I wrote this years ago - seems like my brain has an optimizing partical evaluator built-in). << extra prize - can you write a program which automatically transforms the latter program to the former? >> <