1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Higher order function

Last updated at Posted at 2013-02-24

Introduction

There are two characteristics in higher order function.

  • Accept a function as a parameter
  • Return a function

Popularity

Higher order function is now implemented in many programming launguage, such as Ruby, javascript,Haskell, especilly it is heavily used in jQuery(A javascript library). In Java, there is no higher order function, but you can wrap the higher oreder function in an annoymous inner class.

jQuery

click is the higher order function, where the function alert a dialog is the parameter passed in

    $("#target").click(function() {
      alert("Handler for .click() called.");
    });

Ruby

There are many higher order function in Array of Ruby, such as each, map, inject but these methods come from the Enumerable mixin.

    (1..2).each do |num|
      puts num
    end

    %w{jason sam}.map { |name|  name }

The Usage of higher order function

Reduce control structure
Simplify design pattern
Abstract programming in another aspect

Reference

What are some interesting uses of higher-order functions?

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?