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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:09:38+00:00 2026-06-16T01:09:38+00:00

How to assign all elements but one in ada? If i have this element_to_ignore

  • 0

How to assign all elements but one in ada?

If i have this

element_to_ignore : integer := 3;
a : array(1..4) := (5,3,2,6);
b : array(1..a'length-1) := a( all but element_to_ignore );

I need this result:
b = (5,3,6)

  • 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-16T01:09:40+00:00Added an answer on June 16, 2026 at 1:09 am

    Use slices and array concatenation.

    This program demonstrates how to do it, and also fixes some problems in your code (you didn’t specify the element types of the arrays, for example):

    with Ada.Text_IO; use Ada.Text_IO;
    procedure Foo is
        Element_To_Ignore : Integer := 3;
        type Array_Of_Integer is array(Positive Range <>) of Integer;
        A : Array_Of_Integer(1..4) := (5,3,2,6);
        B : Array_Of_Integer(1..A'Length-1)
            := A(A'First .. Element_To_Ignore-1) &
               A(Element_To_Ignore+1 .. A'Last);
    begin
        for I In B'Range Loop
            Put_Line(Integer'Image(B(I)));
        end loop;
    end Foo;
    

    You can also omit the bounds on the declarations of A and B and let them get the bounds from the initialization. It does mean that when Element_To_Ignore is 1, B will have bounds 2..4 rather than 1..3. That shouldn’t be a problem as long as you consistently refer to B'First, B'Last, and B'Range rather than using hardwired constants. It also mean that setting Element_To_Ignore to 0 or 5 results in B being set to (5,3,2,6).

    I’ve created a more elaborate demo here.

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

Sidebar

Related Questions

I have the following code to assign a value to all the elements of
I have problem with XML schema. I need inside one element elements of three
First of all I alwyas use one #ID. just asking this question to know
I have read many times about CUDA Thread/Blocks and Array, but still don't understand
We have this ui:repeat: <ui:repeat value=#{notAssigned} var=pair> #{pair.data.processName}<br/> <s:button value=assign action=#{mypage.assign}> <f:param name=taskId value=#{pair.task.id}/>
I used masked arrays all the time in my work, but one problem I
I have to store integer values which are mapped to other integers. One way
I have this code, that takes a string and splits it into an array:
I have a bunch of elements on a page, all of whose ID's are
one can assign a probability to each element of an array by simply deviding

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.