If you want to learn cdunctional programming, you’ve been given some
wxcellent advice.  R is not the best place for that.  If you want to become
excellent at R programming,  functional programming is one tool in the box.

FP has a few key ideas.  Working with immutable data is one.  Functions as
values is one.  And composition is a very important one. Designing
computations so that they are built out of reusable pieces that can be
combined using a handful of combinators.

A lot of R code, some of it extremely useful, has been written by people
who ae expert statisticians but poor programmers.  A lot of useful R
packages have been designed by people who weren’t thinking in terms of
making reusable pieces that could be easily combined.  Functions with
oodles of optional keyword parameters.  Interfaces with obvious gaps.

So don’t just think about rewriting code.  Think about redesigning whole
interfaces.

On Sat, 14 Feb 2026 at 8:13 AM, Ivan Krylov via R-help <[email protected]>
wrote:

> Dear Saad Lamjadli,
>
> В Thu, 12 Feb 2026 13:01:26 +0100
> SAAD LAMJADLI <[email protected]> пишет:
>
> > I have analyzed and rewritten dozens of base R functions, and this
> > process has been very instructive. However, I still find it difficult
> > to write more complex and robust functions on my own.
> >
> > I would be very grateful for any advice you might have — whether in
> > the form of recommended books, learning strategies, advanced
> > resources, or suggestions for progressing toward more advanced
> > functional programming skills in R.
>
> If you're solely focused on functional programming, try Structure and
> Implementation of Computer Programs [1] or How to Design Programs [2],
> but be ready to learn some theory and an unfamiliar language (Scheme).
> For purely functional programming, you can try learning OCaml or
> Haskell, but it's not a task for the faint of heart. Once you're done,
> you'll be saying things like "a monad is just a monoid in the category
> of endofunctors" and not understanding why people are giving you
> strange looks in return.
>
> If you'd like to make your programs more complex and robust, you need
> to study software architecture. The Architecture of Open Source
> Applications [3] is a free resource on the topic. Clean Architecture by
> Robert C. Martin is a more fundamental book, very much worth obtaining.
>
> As for learning software development in R... R is an environment where
> you can interact with data; it only moonlights as a programming
> language when you develop packages in it. To this end you can read
> Extending R by John M. Chambers, Writing R Extensions
> (RShowDoc("R-exts")) and many other free resources on the Web.
>
> Finally, Functional Programming by Thomas Mailund predates the native R
> pipe (|>) and the currently experimental tail call support (Tailcall(),
> Exec()), so it's probably worth spending some time to learn the new
> tools as well.
>
> --
> Best regards,
> Ivan
>
> [1]
>
> https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/index.html
>
> [2]
> https://htdp.org/2025-12-27/Book/index.html
>
> [3]
> https://aosabook.org/en/
>
> ______________________________________________
> [email protected] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to