cino hilliard on Wed, 01 Apr 2009 22:06:58 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

character input to functions


Hi,
 
(12:14:16) gp > \v
                  GP/PARI CALCULATOR Version 2.3.4 (released)
           i686 running cygwin (ix86/GMP-4.2.1 kernel) 32-bit version
 compiled: Jul 12 2008, gcc-3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
                (readline v5.2 enabled, extended help available)
 
When keying input with and without quotes for functions such as I get
error with numeric followed by alpha.
 
g(n) = n
(14:33:02) gp > g(abc123)
abc123
 
and
 
(14:34:01) gp > g("123abc")
123abc
 
but
 
(14:33:48) gp > g(123abc)
  ***   too many parameters in user-defined function call: g(123abc)
                                                                                      ^----
I searched the list and found no posts.
 
I want to be able to input alpha-numeric data without the quotes. Here is an
example in gcc.
 
// alphanumeric.c
#include <stdio.h>
#include <string.h>

int diffdigits(char*);
int main(int argc, char * argv[])
{
  char n[60];
  strcpy(n,argv[1]);
  printf("%s\n",n);
  printf("%d\n",diffdigits(n));
  return(0);
}
int diffdigits(char* n) //Return 1 if all digits of n are different otherwise return 0
            {
            int i,j,ln;
            ln = strlen(n)-1;
              for(i=0;i<ln;i++)
                for(j=i+1;j<=ln;j++)
                 if(n[i]==n[j])return(0);
              return(1);
            }

f:\pari\gpfiles>alphanumeric abcdefghijklmnopqrstuvwxyz1234567890
abcdefghijklmnopqrstuvwxyz1234567890
1
 
f:\pari\gpfiles>alphanumeric 1234567890abcdefghijklmnopqrstuvwxyz
1234567890abcdefghijklmnopqrstuvwxyz
1
 
f:\pari\gpfiles>alphanumeric 1234567890abcdefghijklmnopqrstuvwxyz0
1234567890abcdefghijklmnopqrstuvwxyz0
0
 
 
I realize this is not a bug and I think I know why it happens. I am just
wondering if there is a way to do such input without quotes.  
 
Thanks,
Cino hilliard