35
Views
9
Solved
###### subtract Items from a list
Question

Hello everybody.

I am new to the world of outsystems. I do practices to learn and understand the workflow within the platform. I am doing an exercise with a list I set myself as a challenge:

1.  Enter element to a list
2. Add the list elements and subtract the last element:
Example: List items; {100, 50, 1}. 100 + 50 = 150, 150-1
3. Subtract the elements from the list: 100 - 50 = 50, 50 - 1 = 49

The result of point 3 is negative. some

Logic.:

Assign:

Some new ideas on how to do point 3

Solution

Implemented Case 3 scenario . Refer to the attached oml and url

Regards ,

Harika.

SampleTest.oml

Solution

I have implement same scenario as you said hope this will helps you.

I have attached URL as well as OML.

https://akshayproject.outsystemscloud.com/SubtractItemList/Subtract?_ts=637614187028434147

Thanks and Regards,

Akshay Deshpande

SubtracttemList.oml

Hello.

Akshay Deshpande

Thank you very much, the application that implemented makes precisely point 1 and 2. I am looking to solve point 3 that subtracts all the elements from the list:

Example: List = {100, 50, 1}

Process 100 -50 = 50; 50-1 = 49.

Result = 49.

Hello cristian,

Check Below screenshot if its work, refer this OML

Thanks and Regards,

Akshay Deshpande.

SubtracttemList1.oml

Solution

Hello Cristan,

can you explain what wrong with my solution ?

Even Still I have that URL and working as per your requirement.

thanks and Regards,

Akshay Deshpande.

Solution

Hello Cristan,

can you explain what wrong with my solution ?

Even Still I have that URL and working as per your requirement.

thanks and Regards,

Akshay Deshpande.

Hi Cristian,

The result is negative because your Resta value is 0 at the default value. Then when loop the list the result will like negative value of sum all items (0-100-50-1 = -151).

A possible solution is that you set Resta = lista[0] (first value), then loop the list by set Start Index = 1.

Hope this help,

Khuong

Hi ,

Khuong is correct.

you should do like

To subtract the last value, then you need to check the currentrownumber = length-1, If it matches then it's the last element need to perform subtract.

Kindly refer the attached oml and url

Hope this heps!

Regards,

Ellakkiya.s

Subtract.oml

Solution

I have implement same scenario as you said hope this will helps you.

I have attached URL as well as OML.

https://akshayproject.outsystemscloud.com/SubtractItemList/Subtract?_ts=637614187028434147

Thanks and Regards,

Akshay Deshpande

SubtracttemList.oml

Hello.

Akshay Deshpande

Thank you very much, the application that implemented makes precisely point 1 and 2. I am looking to solve point 3 that subtracts all the elements from the list:

Example: List = {100, 50, 1}

Process 100 -50 = 50; 50-1 = 49.

Result = 49.

Hello cristian,

Check Below screenshot if its work, refer this OML

Thanks and Regards,

Akshay Deshpande.

SubtracttemList1.oml

Solution

Hello Cristan,

can you explain what wrong with my solution ?

Even Still I have that URL and working as per your requirement.

thanks and Regards,

Akshay Deshpande.

Hi Christian,

We can add all the elements including the last element and compute the total sum. Subtract the total sum with twice of the last element in the list. The logic will be easy to implement for a beginner. Please refer to the OML.

Example: List:30,40,20

My logic:

Total sum=30+40+20=90;

Christian's sum=Total sum-(2*last element)=>90-(2*20)=50

Subtraction.oml

Solution

Implemented Case 3 scenario . Refer to the attached oml and url

Regards ,

Harika.

SampleTest.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.