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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:31:52+00:00 2026-05-26T03:31:52+00:00

I want to create a lookup table in Groovy, given a size (in this

  • 0

I want to create a lookup table in Groovy, given a size (in this case the size is of 4):

    RGGG
    RRGG
    RRRG
    RRRR

That is in first iteration only one R should be there and size-1 times of G should be there. As per the iteration value increases R should grow and G should decrease as well. So for size 4 I will have 4 lookup values.

How one could do this in Groovy?

  • 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-26T03:31:53+00:00Added an answer on May 26, 2026 at 3:31 am

    You mean like this:

    def lut( width, a='R', b='G' ) {
      (1..width).collect { n ->
        ( a * n ) + ( b * ( width - n ) )
      }
    }
    
    def table = lut( 4 )
    
    table.each { println it }
    

    prints:

    RGGG
    RRGG
    RRRG
    RRRR
    

    Your question doesn’t really say what sort of data you are expecting out? This code gives a List of Strings

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

Sidebar

Related Questions

For a LPC922 microcontroller (with SDCC) I want to create a lookup table with
In SQLite, given this database schema CREATE TABLE observations ( src TEXT, dest TEXT,
I want to create a stored procedure (on SQL Server 2005) that fetches a
I want to create conditional comments in XSLT. But when I use this: <!--
So I have this SQL table that I need to update. Now we use
This is for a Ruby on Rails 3.0.x project. I have a lookup table
I want to create a new record in the mailers table, where three fields
I have a Calendar table with about 2K rows. This is a lookup table,
This is my first C program that does something useful. I'm implementing a generic
I am trying to create an ANI lookup table from 2 separate tables, one

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.