Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Permutations - Perl or just Javascript embedded ?

Reply
Thread Tools

Permutations - Perl or just Javascript embedded ?

 
 
Telemach
Guest
Posts: n/a
 
      02-28-2008

Yesterday I was thinking all day long about what to use for
permutations and still can't figure out a solution. Situation is
this :

I found great small javascript function that does permutations but
this is quite an unusual one.
Every single digit is assigned to 3 or 4 letters so for example
permutations of number 23
could look like this :

ad
ae
af
bd
be
bf
cd
ce
cf

javascipt code is very simple and it looks like too simple to
understand by me (Perl newbie)
because there is no direct loop, just calling a sub from inside this
same sub

I'm having troubles in understanding this code and then rewriting in
Perl so my question is this :
would it be easier to use some javascript module for Perl and paste
javascipt code inside perl script or rewriting this but with help of
permutation modules ?

Problem is that there are 3 or 4 letters per digit and user can input
whatever long number string.

- Telemach -


 
Reply With Quote
 
 
 
 
Joost Diepenmaat
Guest
Posts: n/a
 
      02-28-2008
Telemach <(E-Mail Removed)> writes:

> I found great small javascript function that does permutations but
> this is quite an unusual one.


I can't really make sense of your description. If the code is that
simple it's probably short enough to post it here.

> javascipt code is very simple and it looks like too simple to
> understand by me (Perl newbie)
> because there is no direct loop, just calling a sub from inside this
> same sub


Yes, recursion. If you've never seen it before it may take a little
getting used to, I guess. Perl can do this just fine:

# this is an extremely silly example

function rec {
my $i = shift;
if ($i <= 0) {
return 0;
}
else {
return $i + rec($i-1);
}
}

> I'm having troubles in understanding this code and then rewriting in
> Perl so my question is this :
> would it be easier to use some javascript module for Perl and paste
> javascipt code inside perl script or rewriting this but with help of
> permutation modules ?


Using a javascript module for something that sounds as simple as this is
probably complicating the matter too much. You can translate most
javascript code fairly easily to perl.

> Problem is that there are 3 or 4 letters per digit and user can input
> whatever long number string.


I don't know what you're talking about.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded <divs> with events: How to prevent the parent div's eventfrom being fired when the embedded div's event is fired? Num GG Javascript 2 11-17-2008 08:56 PM
Embedded vs. Non-embedded Tests Trans Ruby 11 09-05-2007 11:22 AM
Embedded languages based on early Ada (from "Re: Preferred OS, processor family for running embedded Ada?") Colin Paul Gloster VHDL 48 04-10-2007 10:31 AM
How to display images embedded in e-mail as embedded, not attachments Jim Firefox 4 12-11-2004 05:36 AM
Databind an embedded control in an embedded datagrid Thomas Dodds ASP .Net Datagrid Control 0 07-26-2004 08:20 PM



Advertisments