<p dir="ltr">Michael:<br>
Yes, a map with a function that leaves everything I do not want to change alone, that would indeed be the smooth, obvious FP way to do it. I will change my code to work this way. Thanks.<br>
Geoffrey</p>
<div class="gmail_quote">On Feb 28, 2015 10:52 AM, "Michael Orlitzky" <<a href="mailto:michael@orlitzky.com">michael@orlitzky.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 02/28/2015 10:02 AM, Geoffrey Bays wrote:<br>
> Michael:<br>
> Thanks, split on would work nicely.<br>
><br>
> I probably should have backed up in my reasoning process to say that my<br>
> real task is to replace a data item in a list with another altered data<br>
> item in the same position, or rather in FP, create a new list with the<br>
> altered item in the same place. And I need a predicate to find the name of<br>
> the item I want to replace.<br>
> Any thoughts?<br>
><br>
<br>
<br>
You can define a function to "fix" the thing that you want to alter, and<br>
then map that function over the list. Just make sure that the function<br>
only alters the thing that you want to alter. For example, suppose the<br>
other numbers are afraid of 7, so you want to change 7 into 8 in some list:<br>
<br>
  -- Turn 7 into 8; leave everything else alone.<br>
  fix_seven :: Int -> Int<br>
  fix_seven 7 = 8<br>
  fix_seven x = x<br>
<br>
  numbers :: [Int]<br>
  numbers = [1..10]<br>
<br>
  ghci> print $ map fix_seven numbers<br>
  [1,2,3,4,5,6,8,8,9,10]<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>