<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks Stuart, Ovidiu. Yes, partially applied functions is the way.<div class=""><br class=""></div><div class="">Mike</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 18 Dec 2017, at 16:00, Stuart Dootson <<a href="mailto:stuart.dootson@gmail.com" class="">stuart.dootson@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Something like the code below - populate a list with partially applied functions, then use foldl to apply the functions in turn to the input list?<div class=""><br class=""></div><div class=""><div class="">v :: Int -> [a] -> [a]</div><div class="">v = drop</div><div class=""><br class=""></div><div class="">w :: Int -> Int -> [a] -> [a]</div><div class="">w keep reject = (take keep).(drop reject)</div><div class=""><br class=""></div><div class="">-- Apply the list of functions (in turn) to the list, yielding a list</div><div class="">apply_ops :: [ [a] -> [a] ] -> [a] -> [a]</div><div class="">apply_ops fns l = foldl (flip ($)) l fns</div><div class=""><br class=""></div><div class="">-- Partially apply functions with non-list arguments to get list of functions of type [a] -> [a]</div><div class="">ops :: [ [a] -> [a] ]</div><div class="">ops = [v 3, w 2 1]</div><div class=""><br class=""></div><div class="">-- result = (w 2 1) ((v 3)[1,2,3,4,5,6,7,8])</div><div class="">-- = w [4,5,6,7,8]</div><div class="">-- = [5,6]</div><div class="">result :: [Int]</div><div class="">result = apply_ops ops [1,2,3,4,5,6,7,8]</div><div class=""><br class=""></div><div class="">main =</div><div class=""> do</div><div class=""> print result</div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On 17 December 2017 at 09:32, mike h <span dir="ltr" class=""><<a href="mailto:mike_k_houghton@yahoo.co.uk" target="_blank" class="">mike_k_houghton@yahoo.co.uk</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="">
<br class="">
I have a number of functions like these:<br class="">
<br class="">
v :: Int -> [a] -> [a]<br class="">
w :: Int -> Int -> [a] -> [a]<br class="">
x :: a -> a -> [a] -> [a]<br class="">
<br class="">
y :: a -> b ->… <other args>... -> [a] -> [a]<br class="">
z…<br class="">
etc.<br class="">
<br class="">
where there are any number of args of different types but the last two are common to all the functions i.e. they all have [a] -> [a]<br class="">
<br class="">
What I’m trying to do is build a collection (ordered) of such functions and then apply each in turn to a [a] to get the final [a]. What would be the best approach to this?<br class="">
<br class="">
Thanks<br class="">
<br class="">
Mike<br class="">
______________________________<wbr class="">_________________<br class="">
Beginners mailing list<br class="">
<a href="mailto:Beginners@haskell.org" class="">Beginners@haskell.org</a><br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-<wbr class="">bin/mailman/listinfo/beginners</a><br class="">
</blockquote></div><br class=""></div>
_______________________________________________<br class="">Beginners mailing list<br class=""><a href="mailto:Beginners@haskell.org" class="">Beginners@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners<br class=""></div></blockquote></div><br class=""></div></body></html>