HP Forums

Full Version: Programming workaround for "prepend" HP PRIME
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi I have this issue:


append (L1,1) //works fine

append (L1,"C") //does not work (bad argument type)

//seems like this inserts value of variable C instead of char "C"

//same behaviour is if I use variable that contains this string

known workaround in program is

L1(0):="C" //works fine

but if I need insert "C" to the beginning of my list,

I need to find similiar workaround for prepend function...

I need that output is exactly:


not like

{""C"","A","B"} or {{"C"},"A","B"}

Edited: 28 Nov 2013, 5:26 a.m. after one or more responses were posted

short after posting, i found this solution:


but maybe exists better solution...


CONCAT({"a","b"},{"c"}) => {"a","b","c"}
CONCAT({"c"},{"a","b"}) => {"c","a","b"}


append (L1,"C") //does not work (bad argument type)
it does not work because append is a CAS funcion. string type arguements to a CAS function are assumed to be CAS commands that can not be parsed by the numeric parser and which are parsed by the CAS at execution of the command. This is most likely the issue there...

as much as possible, try to stay in 1 system.

L1(0):= "C" in this cas.
to do the 'prepend', use CONCAT... sorry, there is no quick trick there... unless I create a syntax with negative numbers for 'inserting'... which might be an idea...


Thanks for explanation.
There is always something new to learn :-)