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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:00:05+00:00 2026-05-13T08:00:05+00:00

our homework is to write a ruby script who calculate a subset of wordlist

  • 0

our homework is to write a ruby script who calculate a subset of wordlist depending on the expression.

regular binary operations are

&& And operator
|| Or operator
++ Concatenate operator
! Negation operator

A valid call would be like

./eval.rb wordlist && a c
or
./eval.rb wordlist && || a b c

First call means generate a new wordlist which all words have at least one ‘a’ and ‘c’.
So my question is how do I process the arguemnts in a efficent way? Maybe recursiv?
I’m stuck…

Thanks in advance.

  • 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-13T08:00:06+00:00Added an answer on May 13, 2026 at 8:00 am

    Looks like a grammer with prefix notation. A stack is indeed your friend, and the easiest stack to use is the call stack. For example, given this grammar:

    expression ::= number | operand number number
    operand ::= '+' | '-'
    

    This is the code to evaluate it:

    #!/usr/bin/ruby1.8
    
    @tokens = ['*', 2, '+', 3, 4]
    
    def evaluate
      token = @tokens.shift    # Remove first token from @tokens
      case token
      when '*'
        return evaluate * evaluate
      when '+'
        return evaluate + evaluate
      else
        return token
      end
    end
    
    puts evaluate    # => 14
    

    Although this is Ruby, it’s close enough to pseudo-code. I’ve put explicit returns in, although Ruby does not require them, because it may be clearer to someone who does not know Ruby.

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

Sidebar

Related Questions

Our web app uses SystemPropertyPlaceholder to load property files depending on the value of
this is a homework question. I am doing diffs on our domain model and
Our homework assignment asks us to prove that the Java LinkedList implementation is doubly-linked
This is part of a homework assignment. What we have to do is write
For my data structures class our homework is to create a generic heap ADT.
As part of our homework we are asked to implement an abstract class with
I have a homework to do that says the following: Write a program in
This is not a homework, it's more of a challenge from our prof but
Our homework assignment asks us to use a jagged array to store the values
I am beginner at C++, the homework ask us to document our code (preamble,

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.