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

  • SEARCH
  • Home
  • 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 4019686
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:08:06+00:00 2026-05-20T10:08:06+00:00

I wrote the following function as a part of a jQuery plugin I am

  • 0

I wrote the following function as a part of a jQuery plugin I am developing:

$.fn.append2 = function(collection, callback) {
    var $this = this;

    $.each(collection, function(key, value) {
        $this.append(callback ? callback(key, value) : value);
    });

    return this;
};

After testing a highly recursive function that heavily depended on .append2, I optimized .append2 to:

$.fn.append2 = function(collection, callback) {
    var $this = this;

    $.each(collection, callback
        ? function(key, value) { $this.append(callback(key,value)); }
        : function(key, value) { $this.append(value); }
    );

    return this;
};

While this code is more efficient in terms of speed, it still left me unsatisfied. I have, essentially, defined the same function twice:

function(key, value) { $this.append(callback(key,value)); }
function(key, value) { $this.append(value); }

And I wondered if there is any language that lets me defined the function only once as:

function(key, value) { $this.append(value); }

And then operate on it by replacing the argument to $this.append from value to callback(key, value). (And, no, not by manipulating strings. By manipulating the function itself.)

Is there any such programming language?

  • 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. Editorial Team
    Editorial Team
    2026-05-20T10:08:07+00:00Added an answer on May 20, 2026 at 10:08 am

    Any homoiconic language lets you do this do some degree or another. All of the Lisp languages let you build functions procedurally out of bits and pieces and then invoke them as normally. The Io language is rare in that I believe it will let you go the other way: given a function, you can pull apart its source code and manipulate it.

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

Sidebar

Related Questions

I wrote the following (part of a jQuery plugin) to insert a set of
I wrote the following: Object.prototype.length = function(){ var count = -1; for(var i in
I wrote this function in C++ as part of a bigger program: Object Single_list<Object>::pop_front()
I wrote the following function in haskell, as it will enumerate every integer: integers
I just wrote the following C++ function to programmatically determine how much RAM a
I wrote a managed C++ class that has the following function: void EndPointsMappingWrapper::GetLastError(char* strErrorMessage)
I want to call the Sleep function on ASM. So I wrote the following:
I have the following php function which i wrote a while ago. Now however,
I wrote the following code in order to apply a function for two lists
Hello i am trying to write the following function to display 7 days of

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.