Vector or list to Number "conversion" (SOLVED.) - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Vector or list to Number "conversion" (SOLVED.) (/thread-3437.html) |
Vector or list to Number "conversion" (SOLVED.) - Spybot - 03-20-2015 03:38 AM Hi Guys! I'm trying to compare the numeric value of two objects, one is a vector with only one numeric value and the other is a real number; [1/2]==0.5 the Hp Prime returns a zero. I searched this forum and the UG. for a command that takes the [1/2] out of the brackets so I can compare them, but I found nothing. this vector [1/2] is the result of solving an equation using the SOLVE command. what can I do to make the caparison a true statement? Thank you. RE: Vector or list to Number "conversion" - Angus - 03-20-2015 09:46 AM If I define result:=[1/2] and do result(1)==0.5 it works on my emulator. You can access a list or vector by round brackets. First element index 1. RE: Vector or list to Number "conversion" - cyrille de brébisson - 03-20-2015 10:34 AM Hello, Are you in CAS or Home? In home, assuming that your vector is stored in a variable (vec for example), doing EVAL(vec(1))==0.5 will do the trick. Cyrille RE: Vector or list to Number "conversion" - DrD - 03-20-2015 10:59 AM Perhaps a "List" approach might be useful? mat2list([1/2]) == 1/2 => {1} mat2list([1/2, 1/4, 1/2]} == 1/2 => {1, 0, 1} Using the list facility the test applies to one (or more) elements, without referencing a specific element number. -Dale- RE: Vector or list to Number "conversion" - salvomic - 03-20-2015 11:24 AM (03-20-2015 03:38 AM)Spybot Wrote: [size=large] (03-20-2015 09:46 AM)Angus Wrote: If I define rigorously speaking, a vector with only one component is always a vector, non a real... So, TYPE([½])= 4 (matrix or vector), and type([½]) = DOM_LIST, and in fact is also a list) You must use [½](1) to get a value 0.5, and then type([½](1)) = DOM_RAT and TYPE(...) = 0, a real I hope this could help you. Salvo RE: Vector or list to Number "conversion" - Spybot - 03-21-2015 06:40 AM All You Guys provided Great solutions! PROBLEM SOLVE!!! Thank you Guys! |