Post Reply 
Type control
02-22-2015, 03:42 PM (This post was last modified: 02-22-2015 03:56 PM by salvomic.)
Post: #1
Type control
hi,
why the IF ELSE control for type control in this program works, but it doesn't works in a non CAS program?
Code:

#cas
multinom(args):=
// multinom(n,{list k_i})
BEGIN
local n, k, argv,argc;
argv:=[args];
argc:=size(argv);
IF argc !=2 THEN
return "Input: integer n, {list k}"; 
ELSE
n:=argv(1);
k:=argv(2);
IF (type(k) != DOM_LIST) THEN return "2nd argument must be a list"; ELSE
 n:= ip(n); k:= ip(k);
 return  n!/∏LIST(k!);
END; // if inner

END; // if out

END;
#end

If I try
Code:

EXPORT Multinomd(n,k,p)
BEGIN
...
IF ((type(k) != DOM_LIST) OR (type(k) != DOM_LIST)) THEN return "2nd and 3rd argument must be a list"; ELSE
...
END;
type(k) control won't be executed, here.
If I use

Code:

EXPORT Multinomd(args)
BEGIN
local argv,argc;
argv:=[args];
argc:=size(argv);
IF argc !=3 THEN
return "Input: integer n, {list k}, {list p}"; 
ELSE
n:=argv(1);
k:=argv(2);
p:=argv(3);
IF ((type(k) != DOM_LIST) OR (type(k) != DOM_LIST)) THEN return "2nd and 3rd argument must be a list"; ELSE
...

END;
the program doesn't work at all, giving "Error: Bad argument value" (I think the logical error is in "argv:= [args]"...: why? this approach works well in the #cas / #end version...

I must control in a 3 arguments if 2nd and 3rd are lists, otherwise return to the user the message that they *must* be lists.

Thank you!

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Type control - salvomic - 02-22-2015 03:42 PM
RE: Type control - Han - 02-22-2015, 04:37 PM
RE: Type control - salvomic - 02-22-2015, 04:46 PM
RE: Type control - Joe Horn - 02-22-2015, 08:47 PM
RE: Type control - salvomic - 02-22-2015, 08:52 PM
RE: Type control - Joe Horn - 02-23-2015, 04:17 AM
RE: Type control - salvomic - 02-23-2015, 08:31 AM
RE: Type control - toml_12953 - 02-23-2015, 04:52 PM
RE: Type control - salvomic - 02-23-2015, 05:01 PM
RE: Type control - Joe Horn - 02-23-2015, 11:40 PM
RE: Type control - salvomic - 02-23-2015, 04:51 PM
RE: Type control - Han - 02-23-2015, 05:10 PM
RE: Type control - salvomic - 02-23-2015, 05:40 PM
RE: Type control - Han - 02-23-2015, 07:18 PM
RE: Type control - salvomic - 02-23-2015, 07:29 PM
RE: Type control - salvomic - 03-12-2015, 09:59 AM
RE: Type control - Han - 03-13-2015, 03:04 PM
RE: Type control - salvomic - 03-13-2015, 03:18 PM
RE: Type control - Han - 03-13-2015, 06:14 PM
RE: Type control - salvomic - 03-13-2015, 06:29 PM
RE: Type control - Han - 03-13-2015, 06:34 PM
RE: Type control - salvomic - 03-13-2015, 06:44 PM
RE: Type control - salvomic - 03-13-2015, 10:39 PM
RE: Type control - Han - 03-14-2015, 09:49 AM
RE: Type control - salvomic - 03-14-2015, 10:00 AM
RE: Type control - Angus - 02-24-2015, 06:28 AM
RE: Type control - salvomic - 02-24-2015, 06:34 AM
RE: Type control - Joe Horn - 02-25-2015, 05:52 AM



User(s) browsing this thread: 1 Guest(s)