Page 1 of 1
					
				Mapping with two arguments
				Posted: Tue Oct 13, 2009 1:51 pm
				by Fritz
				Is it possible to give some argument to a map function? The method below want not work:
Code: Select all
(define (add-tail tl str)
  (append str tl))
(map (add-tail "-Schwanz") '("Hund" "Katze" "Pinguin"))
Now I do this so:
Code: Select all
(map add-tail (dup "-Schwanz" 3 true) '("Hund" "Katze" "Pinguin"))
But I have a feeling there should be a simpler way.
 
			 
			
					
				
				Posted: Tue Oct 13, 2009 2:21 pm
				by Jeff
				You need to pass map a function. You can do that with curry:
Code: Select all
(map (curry add-tail (dup "-Schwanz" 3 true)) '("Hund" "Katze" "Pinguin"))
 
			 
			
					
				
				Posted: Tue Oct 13, 2009 2:40 pm
				by Lutz
				Jeff meant to say this:
Code: Select all
(map (curry add-tail "-Schwanz") '("Hund" "Katze" "Pinguin"))
 
			 
			
					
				
				Posted: Tue Oct 13, 2009 2:41 pm
				by Jeff
				Was he trying to append "-Schwanz" or "-Schwanz-Schwanz-Schwanz"?
			 
			
					
				
				Posted: Tue Oct 13, 2009 2:42 pm
				by Lutz
				one "Schwanz" (tail in German) should be enough for each animal :)
			 
			
					
				
				Posted: Tue Oct 13, 2009 2:43 pm
				by Jeff
				Le pido perdon. Hablo solamente ingles y espanol. Y lisp ;)
			 
			
					
				
				Posted: Tue Oct 13, 2009 3:55 pm
				by Fritz
				Thanx! Now it works.
Btw, Spanish is very useful for me to name functions. I can define something like "buscar", "cargar" or "destripar" and be sure, that these symbols are not protected.
			 
			
					
				
				Posted: Tue Oct 13, 2009 4:11 pm
				by newdep
				You can rename all function inside Newlisp ;-) I did once made a Dutch newlisp..
..Awfull ;-)