![]() |
[QUOTE=science_man_88;251651]well it will return 1 for aredisjoint([],[]) it would also do that if only one is empty as we know the empty set is not disjoint from any set.[/QUOTE]
What's the problem? |
[QUOTE=CRGreathouse;251663]What's the problem?[/QUOTE]
if we take away the if statement on the outside then it tries to find the first element of a 0 element set since that's impossible it would skip to the end and return 1 regardless if they are the same or the fact that [] is a subset of every set. |
[QUOTE=science_man_88;251665]if we take away the if statement on the outside then it tries to find the first element of a 0 element set[/QUOTE]
No it doesn't. How many times does for(i=1,#A, ...) execute? |
[QUOTE=CRGreathouse;251667]No it doesn't. How many times does for(i=1,#A, ...) execute?[/QUOTE]
that doesn't matter because the check I have inside checks with indexes if it's not an index it won't be checked which means if i take away the if it can only return 1. |
[QUOTE=science_man_88;251665]if we take away the if statement on the outside then it tries to find the first element of a 0 element set since that's impossible it would skip to the end and return 1 regardless if they are the same or the fact that [] is a subset of every set.[/QUOTE]
So? If one or both of the sets are empty, they _are_ disjoint. Disjoint means "no common element". If one of them is empty, how can there be a common element? |
[QUOTE=axn;251670]So? If one or both of the sets are empty, they _are_ disjoint. Disjoint means "no common element". If one of them is empty, how can there be a common element?[/QUOTE]
I was told the empty is part of every set unless that's false [],[] can only return 0 because they have something in common [],set or set,[] have the same reason to return 0 but my code can't work with 0 elements unless I have that outer statement if the statement isn't there it returns 1 (true) that all these are disjoint but everything I've been told makes that a bad result. |
[QUOTE=science_man_88;251671]I was told the empty is part of every set [/quote]
Empty set is a _subset_ of every set. It is not an _element_ of every set. "Part of" is not a mathematically meaningful term. [QUOTE=science_man_88;251671]unless that's false [],[] can only return 0 because they have something in common [],set or set,[] have the same reason to return 0 but my code can't work with 0 elements unless I have that outer statement if the statement isn't there it returns 1 (true) that all these are disjoint but everything I've been told makes that a bad result.[/QUOTE] Please restate the definition of disjoint sets before proceeding any further. You've hit a conceptual "wrong turn" here. |
This is the empty set (as we're representing it with PARI vectors): []
This is a set containing the empty set as a member: [[]] This is another set containing the empty set as a member: [1, 2, 3, 4, 5, [], 6] aredisjoint([], [[]]) should return 1 because they are disjoint: the first set has no members and so there are no common members. aredisjoint([1, 2, 3, 4, 5, [], 6], [[]]) should return 0 because they aren't disjoint: [] is a member of both. |
[QUOTE=CRGreathouse;251708]This is the empty set (as we're representing it with PARI vectors): []
This is a set containing the empty set as a member: [[]] This is another set containing the empty set as a member: [1, 2, 3, 4, 5, [], 6] aredisjoint([], [[]]) should return 1 because they are disjoint: the first set has no members and so there are no common members. aredisjoint([1, 2, 3, 4, 5, [], 6], [[]]) should return 0 because they aren't disjoint: [] is a member of both.[/QUOTE] point taken. |
ispower
[CODE](11:29)>?ispower
ispower(x,{k},{&n}): if k > 0 is given, return true (1) if x is a k-th power, false (0) if not. If k is omitted, return the maximal k >= 2 such that x = n^k is a perfect power, or 0 if no such k exist. If n is present, and the function returns a non-zero result, set n to the k-th root of x. (11:31)>ispower(4,,2) *** expected character: '&': ispower(4,,2) ^-- (11:31)>ispower(4,,&2) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2) ^-- (11:31)>ispower(4,,{&2}) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2) ^-- (11:31)>ispower(4,,{&2}) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2) ^-- (11:32)>ispower(4,,{2&}) *** syntax error, unexpected ')': ispower(4,,2&) ^- (11:32)>ispower(4,,&2) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2) ^-- (11:32)>ispower(4,2,&2) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,2,&2) ^-- (11:32)>ispower(4,,&2) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2) ^-- (11:32)>ispower(4,,2) *** expected character: '&': ispower(4,,2) ^-- (11:32)>ispower(4,,&) *** syntax error, unexpected ')', expecting KENTRY: ispower(4,,&) ^- (11:33)>ispower(4,,&"2") *** syntax error, unexpected KSTRING, expecting KENTRY: ispower(4,,&"2") ^-- (11:33)>ispower(4,,&2) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2) ^-- (11:33)>ispower(4,,{2}) *** expected character: '&': ispower(4,,2) ^-- (11:33)>ispower(4,,&{2}) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2) ^-- (11:33)>ispower(4,,&}) *** unexpected closing brace. (11:33)>ispower(4,,&} *** unexpected closing brace. (11:33)>ispower(4,,&2} *** unexpected closing brace. (11:33)>ispower(4,,&2) *** syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2) ^-- (11:34)>ispower(4,,{2}) *** expected character: '&': ispower(4,,2) ^-- (11:34)>ispower(4,,2) *** expected character: '&': ispower(4,,2) ^-- (11:34)>ispower(4,,2)[/CODE] |
[CODE]? n=0
%12 = 0 ? ispower(1024,,&n) %13 = 10 ? n %14 = 2[/CODE] You must pass a variable as the third parameter so that the function can pass back the "base". |
| All times are UTC. The time now is 23:02. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.