cino hilliard on Thu, 02 Apr 2009 19:08:34 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
RE: character input to functions |
Hi Bill, Thanks for the reply. > Date: Wed, 1 Apr 2009 23:25:22 +0200 > From: Bill.Allombert@math.u-bordeaux1.fr > To: pari-users@list.cr.yp.to > Subject: Re: character input to functions > > On Wed, Apr 01, 2009 at 03:00:12PM -0500, cino hilliard wrote: > > > > I want to be able to input alpha-numeric data without the quotes. Here is an > > example in gcc. > > An example of what ? Just trying to show by example that input in C can be eg., abcd1234 or 1234abcd gp only accepts abcd1234. > This is a terrible idea. It depends on who is spending the money to do the keypunching. > > ? install("strtoGENstr",r,"myfunc") > ? myfunc(121312AAZA) > %2 = "121312AAZA" This does not do what I want or I do not know how to apply it to existing functions. It doesn't matter anyway since it is being discontinued. > > Now, what do you really want to do ? Exactly what I said. I want to input without having to do the 4 extra keystrokes for quotes for each number. Suppose in the dessert I stumble upon an old and fragial scroll of thousands of numbers in base 32. I have a base(b1,b2,n) that converts n base r1 to r2. I want to determine if the base 32 numbers are prime or not. Now depending, on the starting number, This works. g(n) = isprime(eval(base(32,10,n))). gp > g(123) %26 = 1 gp > g(ab12345) %29 = 0 (10:50:38) gp > g(12345ab) *** too many parameters in user-defined function call: g(12345ab) ^--- So we put n in quotes. (10:52:33) gp > g("12345ab") %30 = 0 Yep. That works. I guess I could pay my assistent to simply type in the quotes so we would not get the error. Or I could make him think on each number: "To quote or not to quote." This is a terible idea(Sorry Willie). Because thinking will get errors on input. The input should be rote for maximum accuracy. Then the creative juices abound. Why can't Pari accept all inputs without quotes? A possible workaround is preceeding each number with an x or other letter, and parse it out in the function. We preserve the rote dictum this way with fewer keystrokes. gx(n) = n=mid(Str(n),2,length(Str(n))-1);isprime(y=eval(base(32,10,n))) Consider, 4i9lkip9grstc5if164po5v72me827226jslap462585q7h0000000000000000008b (11:38:12) gp > g(4i9lkip9grstc5if164po5v72me827226jslap462585q7h00000 00000000000008b) *** too many parameters in user-defined function call: g(4 *** i9lkip9grstc5if164po ^-------------------- (11:38:02) gp > gx(x4i9lkip9grstc5if164po5v72me827226jslap462585q7h00000 00000000000008b) %84 = 1 So out of the 10000 or so duotrigesimal numbers, I do not have to waste 4 keystrokes for quotes on my solar powered laptop with the Pari calculater installed. However, even the x will be costly after a while. Cheers and Roebuck, Cino Hilliard |