listPrepend

Inserts an element at the beginning of a list.

listPrepend(someList, value [, delimiters]) → returns String

Member Function Syntax

someList.listPrepend( value [, delimeters])

Argument Reference for the listPrepend function

list

Required: Yes
A string list.

value

Required: Yes
An element or list of elements.

delimiters

Required: No
Default: ,
Characters that separate list elements. Values:
  • ,
  • |
  • ;
  • -
  • chr(9)
  • chr(10)
  • chr(13)

Examples sample code invoking the listPrepend function


Prepend to a List using a dash delimeter

someList = "1-2-3-4";
someList = listPrepend(someList,"0","-");
writeOutput(someList);

Expected Result: "0-1-2-3-4"


Prepend to a List using the List member function

CF 11+ Lucee 4.5+

seinfeldList = "Close Talker,Soup Nazi";
seinfeldList = seinfeldList.listPrepend("Puffy Shirt");
writeOutput(seinfeldList);

Expected Result: "Puffy Shirt,Close Talker,Soup Nazi"


Fork me on GitHub