Created
          March 10, 2017 21:01 
        
      - 
      
 - 
        
Save CliffordAnderson/25ab95e4cc398dbeb29e2ef600b3bcf1 to your computer and use it in GitHub Desktop.  
    Fold Left for Anonymizing Names
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | xquery version "3.1"; | |
| (: The credit for this idea goes to Joe Wicentowski :) | |
| let $sentence := "The men attending the meeting were Mr. Anderson, Mr. Wicentowski, and Mr. Jones. The women attending were Ms. French, Ms. Ryder, and Ms. Callon." | |
| let $names := ("Anderson", "Jones", "French") | |
| let $replace := function($sentence as xs:string?, $name as xs:string) as xs:string? {fn:replace($sentence, $name, "Smith")} | |
| return fn:fold-left($names, $sentence, $replace) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment