Or, if you are horrified by the inneficiency of such operation, use a scripting 
extension to XQuery, like the
one bellow:
http://www.zorba-xquery.com/html/scripting_spec.html

All functional languages have side-effecting extensions (that I know).

All SQL implementations also have a procedural extension.

Best
Dana

On May 15, 2013, at 8:05 AM, David Lee wrote:

> In XQuery (neglecting some vendor specific extensions) variables are imutable.
> Thus it is counter-productive to think "I have a list then I want to add to 
> it"
> Rather thing "I have a function which I wish to produce a final list"
>  
> Like this
>  
> declare function addlist( $list as xs:string* , $item as xs:string) as 
> xs:string*
> {
>     if( $item = $list ) then $list else ( $list , $item )
>  
> };
>  
> let $list := addlist( ()  , "apples" ) ,
>       $list := addlist( $list , "pears" ),
>       $list := addlist( $list , "peaches" ),
>       $list := addlist( $list , "apples" ),
>       $list := addlist( $list , "pumpkins" )
> return $list
>  
> This *looks like* it is adding values to $list but in fact it is assigning a 
> new variable called $list for every expression
> based on the previous value and possibly adding one more.
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
> ----------------------------------------
> David A. Lee
> [email protected]
> http://www.xmlsh.org
>  
> From: [email protected] [mailto:[email protected]] On Behalf Of 
> Kunal Chauhan
> Sent: Wednesday, May 15, 2013 10:48 AM
> To: [email protected]
> Subject: [xquery-talk] Is it possible to maintain a list of value in XQuery
>  
> Hi,
> 
> I want to maintain a list of value.
> 
> for eg:
> initially I have blank list and through some process I add values in to the 
> list.
> 
> like (Apple,Banana,Cherry)
>  
> now, when get Apple as an output 2nd time it will check into the list.
> If present than don't add value into the list otherwise add it.
> At last I will return the list.
>  
> I don't know whether it's possible or not.
> But this there any work around.
> 
> Thanks and Regards,
> 
> --
> Kunal Chauhan
> [email protected]
> [+918655517141]
> [+919904983614]
> _______________________________________________
> [email protected]
> http://x-query.com/mailman/listinfo/talk

_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to