Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 32947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:50:36+00:00 2026-05-10T13:50:36+00:00

Anyone have a decent example, preferably practical/useful, they could post demonstrating the concept?

  • 0

Anyone have a decent example, preferably practical/useful, they could post demonstrating the concept?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T13:50:37+00:00Added an answer on May 10, 2026 at 1:50 pm

    (Edit: a small Ocaml FP Koan to start things off)

    The Koan of Currying (A koan about food, that is not about food)

    A student came to Jacques Garrigue and said, ‘I do not understand what currying is good for.’ Jacques replied, ‘Tell me your favorite meal and your favorite dessert’. The puzzled student replied that he liked okonomiyaki and kanten, but while his favorite restaurant served great okonomiyaki, their kanten always gave him a stomach ache the following morning. So Jacques took the student to eat at a restaurant that served okonomiyaki every bit as good as the student’s favorite, then took him across town to a shop that made excellent kanten where the student happily applied the remainder of his appetite. The student was sated, but he was not enlightened … until the next morning when he woke up and his stomach felt fine.

    My examples will cover using it for the reuse and encapsulation of code. This is fairly obvious once you look at these and should give you a concrete, simple example that you can think of applying in numerous situations.

    We want to do a map over a tree. This function could be curried and applied to each node if it needs more then one argument — since we’d be applying the one at the node as it’s final argument. It doesn’t have to be curried, but writing another function (assuming this function is being used in other instances with other variables) would be a waste.

    type 'a tree = E of 'a | N of 'a * 'a tree * 'a tree let rec tree_map f tree = match tree with     | N(x,left,right) -> N(f x, tree_map f left, tree_map f right)     | E(x) -> E(f x)  let sample_tree = N(1,E(3),E(4) let multiply x y = x * y let sample_tree2 = tree_map (multiply 3) sample_tree 

    but this is the same as:

    let sample_tree2 = tree_map (fun x -> x * 3) sample_tree 

    So this simple case isn’t convincing. It really is though, and powerful once you use the language more and naturally come across these situations. The other example with some code reuse as currying. A recurrence relation to create prime numbers. Awful lot of similarity in there:

    let rec f_recurrence f a seed n =     match n with     | a -> seed     | _ -> let prev = f_recurrence f a seed (n-1) in            prev + (f n prev)  let rowland = f_recurrence gcd 1 7 let cloitre = f_recurrence lcm 1 1  let rowland_prime n = (rowland (n+1)) - (rowland n) let cloitre_prime n = ((cloitre (n+1))/(cloitre n)) - 1 

    Ok, now rowland and cloitre are curried functions, since they have free variables, and we can get any index of it’s sequence without knowing or worrying about f_recurrence.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 94k
  • Answers 94k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer ultramonkey will give you a good description of how to… May 11, 2026 at 6:51 pm
  • Editorial Team
    Editorial Team added an answer textarea encoded with javascript escape() escape isn't safe for non-ascii.… May 11, 2026 at 6:51 pm
  • Editorial Team
    Editorial Team added an answer sprintf("%05.2f", 0.33) # or "%05.2f" % 0.33 May 11, 2026 at 6:51 pm

Related Questions

I think I'm in somewhat of a unique situation: I have a decent amount
I've been trying to create a custom control that works exactly like the Panel
I've been trying to come up with a good design pattern for mapping data
I have a Windows service that runs implementations of a framework across multiple threads.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.