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 8716991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:12:48+00:00 2026-06-13T06:12:48+00:00

For example, we need to implement function Set addToSet(Stack, Object) : it accept a

  • 0

For example, we need to implement function Set addToSet(Stack, Object): it accept a Stack and some object that can be pushed into the stack; the input object should be pushed into the input stack; we need it to return a Set, which contains all elements of the input stack with the new object. If we push the new object into the stack, we violate the principle of functional programming. For some reason, we can’t push the new object into the stack before or after invoking this function (i.e. do pushing outside the function). How should we do?

My guess solution is to copy the input stack to a new one first, and then modify the new stack and finally return the result Set with the new stack together. What’s your opinion?

  • 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-06-13T06:12:49+00:00Added an answer on June 13, 2026 at 6:12 am

    How about:

    function Stack pushToStack(Stack, Object)
    function Set stackToSet(Stack)
    stackToSet(pushToStack(Stack,Object))
    

    No more side effect.

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

Sidebar

Related Questions

I need to implement Online Help in my Java Web Project. For Example User
I have a task that to implement a 'rollback' (not the usual rollback) function
Actually I need to know how this line is getting executed. Example: Browser(InternetExplorer).Page(Stackoverflow).WebElement(textbox).set user
I have a set of variables that i need for multiple other classes. I
Can you show me how to implement this canvas function using opneGL es1: public
I need a solution that will set the heights of two divs whose class
In the example below I have written one to_str() function and one set() procedure
I'm trying really hard to implement jQuery UI's combo box example. I have set
For Example: I need to develop a Small Inventory program for nearby Super Market
For example I need to disable two buttons in runtime. After I disabled first

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.