[28011] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9375 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 25 14:05:48 2006

Date: Sun, 25 Jun 2006 11:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 25 Jun 2006     Volume: 10 Number: 9375

Today's topics:
        languages with full unicode support <xah@xahlee.org>
    Re: languages with full unicode support <fb@frank-buss.de>
    Re: Need Search::Binary examples <hjp-usenet2@hjp.at>
    Re: nl_langinfo - problem <benmorrow@tiscali.co.uk>
    Re: Regexp problem <jurgenex@hotmail.com>
    Re: Regexp problem <tadmc@augustmail.com>
    Re: Regexp problem <David.Squire@no.spam.from.here.au>
    Re: Saying "latently-typed language" is making a catego <david.nospam.hopwood@blueyonder.co.uk>
    Re: Saying "latently-typed language" is making a catego <cdsmith@twu.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 25 Jun 2006 09:08:56 -0700
From: "Xah Lee" <xah@xahlee.org>
Subject: languages with full unicode support
Message-Id: <1151251736.590910.36050@u72g2000cwu.googlegroups.com>

TGFuZ3VhZ2VzIHdpdGggRnVsbCBVbmljb2RlIFN1cHBvcnQKCkFzIGZhciBhcyBpIGtub3csIEph
dmEgYW5kIEphdmFTY3JpcHQgYXJlIGxhbmd1YWdlcyB3aXRoIGZ1bGwsIGNvbXBsZXRlCnVuaWNv
ZGUgc3VwcG9ydC4gVGhhdCBpcywgdGhleSBhbGxvdyBuYW1lcyB0byBiZSBkZWZpbmVkIHVzaW5n
IHVuaWNvZGUuCih0aGUgSmF2YVNjcmlwdCBlbmdpbmUgdXNlZCBieSBGaXJlRm94IHN1cHBvcnQg
dGhpcykKCkFzIGZhciBhcyBpIGtub3csIGhlcmUncyBmZXcgb3RoZXIgbGFu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jwriipXiipfi
ipniipriipviiJjiiJkg4piF4piGIjsKCn0KCmNsYXNzIFVuaWNvZGVUZXN0IHsKICAgIHB1Ymxp
YyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZykgewogICAgICAgIOaWuSB4MSA9IG5ldyDm
lrkoKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIHgxLnN0cuWMlyApOwogICAgICAgIFN5
c3RlbS5vdXQucHJpbnRsbiggeDEuc3Ry4piFICk7CiAgICB9Cn0KCklmIHlvdSBrbm93IGEgbGFu
ZyB0aGF0IGRvZXMgZnVsbCB1bmljb2RlIHN1cHBvcnQsIHBsZWFzZSBsZXQgbWUga25vdy4KVGhh
bmtzLgoKICAgWGFoCiAgIHhhaEB4YWhsZWUub3JnCiDiiJEgaHR0cDovL3hhaGxlZS5vcmcvCg==



------------------------------

Date: Sun, 25 Jun 2006 18:30:22 +0200
From: Frank Buss <fb@frank-buss.de>
Subject: Re: languages with full unicode support
Message-Id: <4eeycqavp7ld$.1sthhf3vp4w84$.dlg@40tude.net>

Xah Lee wrote:

> Lisps ¡÷ No.

The Common Lisp spec (CLHS) doesn't require that implementations support
Unicode characters, but it doesn't forbid it and some implementations
support it, e.g. http://clisp.cons.org/impnotes.html

-- 
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de


------------------------------

Date: Sun, 25 Jun 2006 15:16:10 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Need Search::Binary examples
Message-Id: <qa2m7e.6cv.ln@teal.hjp.at>

Arvin Portlock wrote:

> I need to extract values from very large but numerically
> sorted arrays. I can think of lots of ways to do it but
> I'd like to try a binary search and prefer to use an exist-
> ing module rather than reinvent the wheel.
> 
> Unfortunately I can't make sense of the documentation
> in Search:Binary (perhaps there's another more appropriate
> module?). Are there any scripts out there that use
> Search::Binary which one can find on the web?

Search::Binary is obviously written to search files, not arrays. But it
can be used to search arrays, too. Some of the generality for searching
files isn't needed for searching arrays (for example, in a file not
every possible position is the start of a record).
I've changed your script to use Search::Binary, and included the
relevant part of the documentation before each line. That's quite a lot
of documentation per line of code, I hope it helps you to make sense
both of the docs and the code.


#!/usr/bin/perl
use warnings;
use strict;

use Search::Binary;

my %books = (
    1   => 'book 1',
    116 => 'book 2',
    433 => 'book 3',
    762 => 'book 4'
);

# The array consists of the sorted keys of %books above.
# Created when raw data is read so no need for expensive
# sort keys.

my @pages = (1, 116, 433, 762);

# For Search::Binary we need the last page of each book, not the first:
# ("whose index value is greater than or equal to $val")
my @lastpages = (115, 432, 761, 999);


# Random numbers are already sorted numerically

my @random_nos = (13, 18, 344, 390, 601);


for my $r (@random_nos) {

    my $lastpos;
    my $pos = binary_search(
                    # The input parameters $min and $max are positions
                    # and represents the extent of the search. Only
                    # records which begin at positions within this range
                    # (inclusive) will be searched.  Moreover, $min must
                    # be the starting position of a record.
                         0, $#lastpages,
                    # "binary_search" implements a generic binary search
                    # algorithm returning the position of the first
                    # record whose index value is greater than or equal
                    # to $val.
                         $r,
                         sub {
                            # During the search the read function will
                            # be called with three arguments: the input
                            # parameters $handle and $val, and a
                            # position.
                            my ($handle, $val, $pos) = @_;

                            # If the position is not "undef", the read
                            # function should read the first whole
                            # record starting at or after the position;
                            # otherwise, the read function should read
                            # the record immediately following the last
                            # record it read.
                            $pos = $lastpos + 1 unless defined($pos);
                            $lastpos = $pos;

                            # The read function needs to return a two
                            # element array consisting of the result of
                            # comparing $val with the index value of the
                            # read record and the position of the read
                            # record. The comparison value must be
                            # positive if $val is strictly greater than
                            # the index value of the read record, 0 if
                            # equal, and negative if strictly less.
                            # Furthermore, the returned position value
                            # must be greater than or equal to the
                            # position the read function was called
                            # with.
                            return ($val <=> $handle->[$pos], $pos)
                         },
                    # The value of $handle is of no consequence to the
                    # binary search algorithm; it is merely passed as a
                    # convenience to the read function.
                         \@lastpages);
    print "page $r is in book $pos with the title '$books{$pages[$pos]}'\n";
}
__END__

        hp

-- 
   _  | Peter J. Holzer    | Man könnte sich [die Diskussion] auch
|_|_) | Sysadmin WSR/LUGA  | sparen, wenn man sie sich einfach sparen
| |   | hjp@hjp.at         | würde.
__/   | http://www.hjp.at/ |   -- Ralph Angenendt in dang 2006-04-15


------------------------------

Date: Sun, 25 Jun 2006 14:17:18 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: nl_langinfo - problem
Message-Id: <uve2n3-4hm.ln1@osiris.mauzo.dyndns.org>


Quoth Adam Smith <adamsmith@econ.com>:
> Ben Morrow wrote:
> 
> > [newsgroups truncated and f'ups set]
> > 
> What is "truncated and f'ups set" and how is this set?

I truncated the list of newsgroups in your article to clpmisc. I also
set the 'Followup-To:' header: how you do this depends on your client. 

> > Quoth Adam Smith <adamsmith@econ.com>:
> > 
> >>UNIX FreeBSD -V 4.9 O/S, i386 arch, Perl -V 5.8.2 Installation
> > 
> > Please don't start a new thread with the same question: continue with
> > the one you had.
> >
> Well, I was adding a significantly new perspective to the question, 
> person who may have bypassed it previously may have an input based on 
> the new realization.

No, you weren't. What you posted was a direct answer to my question.
IIRC you actually posted the same article twice, once as a reply and
once as a new thread: anyone who's going to ignore your reply is also
going to ignore your new thread, they'll just think your trying to force
them to take notice of you. This is not very polite.

> Is there a cuttoff period for this, is it arbitrarily set?

No. Use your common sense.

> Do you recall, 'gopher' and 'veronica' etc?

No, I'm not that old.

> > Please don't cross-post to so many groups: pick one that's most relevant
> > (clpm in this case).
> > 
> ONE! Sounds like a 'religious' mantra, I did not use all perl groups. I 
> choose those that appeared applicable and would have attracted responses 
> from persons with likely know how.

Such as... comp.lang.perl.modules? perl.beginners.cgi? How are those in
any way more relevant than clpmisc?

Since it's likely a system question rather than a perl one (though you
may not have known that), comp.unix.bsd.freebsd.misc or some such may
have been appropriate.

Also, crossposting to alt.* is generally unwelcome here.

> And from the "multitude" of responses received I have not been very 
> successful either. You were the only one responding so far after many days.

Well, a lot of people here simply killfile large cross-posts. They are
almost always trolls like Xah Lee.

> > If you have a valid reason for cross-posting, please set followups.
> > 
> I hope the reasons cited above are actual reasons first and then valid 
> reasons too
> I addressed the set followups issue earlier

No, you said you didn't know how to do it. Ignorance is no excuse, when
answers are so easy to find.

> Is there a "netiquette newsgroup or list" somewhere?

Google for it.

Ben

-- 
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks]  benmorrow@tiscali.co.uk


------------------------------

Date: Sun, 25 Jun 2006 13:52:16 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regexp problem
Message-Id: <kywng.3440$il.404@trnddc03>

Mark Healey wrote:
> On Sat, 24 Jun 2006 06:32:29 +0000, Jürgen Exner wrote:
>
>> Mark Healey wrote:
>>> Here is the line that is giving me problems:
>>>
>>> $Falbum =~ s/$edir\/.\/$Fartist\///;
>>>
>>> The problem is that $Fartist sometimes has grouping characters
>>> "()[]" which screws up the search.
>>>
>>> How do I get it to treat these characters as if they were
>>> "\(\)\[\]"?
>>
>> perldoc -f quotemeta
>
> This doesn't help when I'm using some meta characters in my search
> strings.  I need something that only does it to the variables.

Maybe I'm missing something but is there a problem with
    $Fartist = quotemeta($Fartist);

jue 




------------------------------

Date: Sun, 25 Jun 2006 09:11:15 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regexp problem
Message-Id: <slrne9t6c3.em9.tadmc@magna.augustmail.com>

Mark Healey <dont@like.spammers> wrote:
> On Sat, 24 Jun 2006 06:32:29 +0000, Jürgen Exner wrote:
> 
>> Mark Healey wrote:
>>> Here is the line that is giving me problems:
>>>
>>> $Falbum =~ s/$edir\/.\/$Fartist\///;
>>>
>>> The problem is that $Fartist sometimes has grouping characters "()[]"
>>> which screws up the search.
>>>
>>> How do I get it to treat these characters as if they were "\(\)\[\]"?
>> 
>> perldoc -f quotemeta
> 
> This doesn't help when I'm using some meta characters in my search
> strings.  


Yes it does.


> I need something that only does it to the variables.


quotemeta only does it where you ask it to do it, so ask it to
do it "to the variables":

   $edir = quotemeta $edir;
   $Fartist = quotemeta $Fartist;
   $Falbum =~ s#$edir/./$Fartist/##;  # Look Ma! No backslashes!

or, lookup the \Q that the docs mention:

   $Falbum =~ s#\Q$edir\E/./\Q$Fartist/##;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 25 Jun 2006 15:34:31 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Regexp problem
Message-Id: <e7m6tn$fbg$1@news.ox.ac.uk>

Jürgen Exner wrote:
> Mark Healey wrote:
>> On Sat, 24 Jun 2006 06:32:29 +0000, Jürgen Exner wrote:
>>
>>> Mark Healey wrote:
>>>> Here is the line that is giving me problems:
>>>>
>>>> $Falbum =~ s/$edir\/.\/$Fartist\///;
>>>>
>>>> The problem is that $Fartist sometimes has grouping characters
>>>> "()[]" which screws up the search.
>>>>
>>>> How do I get it to treat these characters as if they were
>>>> "\(\)\[\]"?
>>> perldoc -f quotemeta
>> This doesn't help when I'm using some meta characters in my search
>> strings.  I need something that only does it to the variables.
> 
> Maybe I'm missing something but is there a problem with
>     $Fartist = quotemeta($Fartist);

Is this a reference to the great Petomane?

:)

DS


------------------------------

Date: Sun, 25 Jun 2006 15:45:21 GMT
From: David Hopwood <david.nospam.hopwood@blueyonder.co.uk>
Subject: Re: Saying "latently-typed language" is making a category mistake
Message-Id: <lcyng.477585$tc.94439@fe2.news.blueyonder.co.uk>

Matthias Blume wrote:
> David Hopwood <david.nospam.hopwood@blueyonder.co.uk> writes:
>>Patricia Shanahan wrote:
>>>Vesa Karvonen wrote:
>>>...
>>>
>>>>An example of a form of informal reasoning that (practically) every
>>>>programmer does daily is termination analysis.  [...]
>>>>Given a program, it may be possible to formally
>>>>prove that it terminates.
>>>
>>>To make the halting problem decidable one would have to do one of two
>>>things: Depend on memory size limits, or have a language that really is
>>>less expressive, at a very deep level, than any of the languages
>>>mentioned in the newsgroups header for this message.
>>
>>I don't think Vesa was talking about trying to solve the halting problem.
>>
>>A type system that required termination would indeed significantly restrict
>>language expressiveness -- mainly because many interactive processes are
>>*intended* not to terminate.
> 
> Most interactive processes are written in such a way that they
> (effectively) consist of an infinitely repeated application of some
> function f that maps the current state and the input to the new state
> and the output.
> 
>    f : state * input -> state * output
> 
> This function f itself has to terminate, i.e., if t has to be
> guaranteed that after any given input, there will eventually be an
> output.  In most interactive systems the requirements are in fact much
> stricter: the output should come "soon" after the input has been
> received.
> 
> I am pretty confident that the f for most (if not all) existing
> interactive systems could be coded in a language that enforces
> termination.  Only the loop that repeatedly applies f would have to be
> coded in a less restrictive language.

This is absolutely consistent with what I said. While f could be coded in
a system that *required* termination, the outer loop could not.

As I mentioned in a follow-up, event loop languages such as E enforce this
program structure, which would almost or entirely eliminate the need for
annotations in a type system that proves termination of some subprograms.

-- 
David Hopwood <david.nospam.hopwood@blueyonder.co.uk>


------------------------------

Date: Sun, 25 Jun 2006 11:30:23 -0600
From: Chris Smith <cdsmith@twu.net>
Subject: Re: Saying "latently-typed language" is making a category mistake
Message-Id: <MPG.1f087618d92b2bef9896fd@news.altopia.net>

Chris Uppal wrote:
> It seems to me that most (all ?  by definition ??)  kinds of reasoning where we
> want to invoke the word "type" tend to have a form where we reduce values (and
> other things we want to reason about) to equivalence classes[*] w.r.t the
> judgements we wish to make, and (usually) enrich that structure with
> more-or-less stereotypical rules about which classes are substitutable for
> which other ones. So that once we know what "type" something is, we can
> short-circuit a load of reasoning based on the language semantics, by
> translating into type-land where we already have a much simpler calculus to
> guide us to the same answer.
> 
> (Or representative symbols, or...  The point is just that we throw away the
> details which don't affect the judgements.)

One question: is this more specific than simply saying that we use 
predicate logic?  A predicate divides a set into two subsets: those 
elements for which the predicate is true, and those for which it is 
false.  If we then apply axioms or theorems of the form P(x) -> Q(x), 
then we are reasoning from an "equivalence class", throwing away the 
details we don't care about (anything that's irrelevant to the 
predicate), and applying stereotypical rules (the theorem or axiom).  I 
don't quite understand what you mean by substituting classes.

-- 
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9375
***************************************


home help back first fref pref prev next nref lref last post