Sponsored Content
Top Forums Shell Programming and Scripting Perl: find next available lowest number that is available in two arrays Post 302747175 by hcclnoodles on Thursday 20th of December 2012 07:23:03 PM
Old 12-20-2012
Perl: find next available lowest number that is available in two arrays

Hi there. I have a number allocation problem whereby I have 2 arrays built from 2 different sources. The arrays will just contain a listed of sorted numbers

Code:
@a 

1
7
10
14
15
16

@b

1
7
10
11
14
15
16

i need to scan both arrays and find the lowest available number that is available in both arrays that is higher than $min which is set to "10". once it finds the the lowest unused number, it quits and presents it in a variable

So in the case of the two arrays above, the number that would get presented is 12 (as 11 is used in one of the arrays)


I have been trying various things such as setting a counter and looping through the two arrays but have been getting myself in a real pickle of infinate loops and utter mess

I wanted to ask whether anyone could point me in the right direction on the best way to tackle this one?

any advice or guidance would be greatly appreciated

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl ? - How to find and print the lowest and highest numbers punched in by the user?

. . . . . . (3 Replies)
Discussion started by: some124one
3 Replies

2. Shell Programming and Scripting

Creating an unknown number of arrays

I need to create arrays like this: cnt=0 { while read myline; do if ];then firstpass="${myline##<meas>}" meas="${firstpass%%</meas>}" tempmeas="${meas%%;*}" MEAS$cnt=$tempmeas print $cnt print ${MEAS'$cnt'} ... (2 Replies)
Discussion started by: ajgwin
2 Replies

3. Shell Programming and Scripting

Perl find page number in a file

Hi i want to ask how can i use perl and find a word in a text file, and also telling that which page doesn't it exist? Eample: have a 10 pages text file, then i need to find 'Hello' in the file, and show that which page is it contain in. Output: Hello contains 8 times in page 1, 3, 4, 7, 10... (9 Replies)
Discussion started by: mingming88
9 Replies

4. Shell Programming and Scripting

Using perl code find greatest number.

How would one go about finding the greatest number in an array of numbers using loops and if statements? For example, if you had an array like this: (4, 8, 3, 19, 6, 11) (3 Replies)
Discussion started by: DemonixX
3 Replies

5. Shell Programming and Scripting

How to find difference between two arrays in Perl?

Hi, Could someone please help me with this? I have two arrays and I need to generate third array containing difference between the two. For example - @Array1 = ; @Array2 = ; I would like to find difference between these two and generate third array that contains the difference. In... (5 Replies)
Discussion started by: sncoupons
5 Replies

6. Shell Programming and Scripting

Korn Shell - Finding lowest number of a file.

I'm writing a KSH script that will get a file on the command line (such as input.txt), and in this file there is on number per line. The program needs to take the file, read each and determine the lowest number in the file. I currently have a while loop setup that will correctly out put every... (8 Replies)
Discussion started by: denyal
8 Replies

7. Shell Programming and Scripting

print every 20 lines the lowest number

Hello all, How can I find the lowest number every 10 lines? For example i have a list name1 -0.1 name2 2 name3 3 name4 -3 name5 1 name6 2 name7 34 name8 34 (6 Replies)
Discussion started by: TheTransporter
6 Replies

8. Shell Programming and Scripting

ksh program that finds the lowest number in a .txt file

i am having a problem finding the lowest number after punching in a bunch of numbers in the .txt file but its probably the way i have the code set up. help please! (4 Replies)
Discussion started by: tinsteer
4 Replies

9. Shell Programming and Scripting

Perl - how to find the number based on the same name

Hi Perl Experts, Could somebody help me how to solve my problem if I have array contains the following data: "SEQ-0 UNSORT2 0", "SEQ-1 UNSORT2 1", "SEQ-2 UNSORT2 2", "SEQ-3 UNSORT2 3", <--- Missing the... (0 Replies)
Discussion started by: askari
0 Replies

10. Shell Programming and Scripting

Sort from highest to lowest number

Hi Guys, I am looking for a way to sort the output below from the "Inuse" count from Highest to Lowest. Is it possible? Thanks in advance. user1 0.12 0.06 0 0.12 User Inuse Pin Pgsp Virtual Unit:... (4 Replies)
Discussion started by: jaapar
4 Replies
vbo_rendering(3)						       Coin							  vbo_rendering(3)

NAME
vbo_rendering - Vertex array and VBO rendering in Coin Coin 2.5 added improved support for OpenGL vertex array and VBO rendering. This might lead to major rendering performance improvements compared to the old rendering code. The new rendering code has been added for the SoIndexedFaceSet, SoVRMLIndexedFaceSet, SoIndexedLineSet, SoVRMLIndexedLineSet, SoPointSet and SoVRMLPointSet nodes. To take advantage of the improved performance vertex array and VBO rendering yields, you'll need to organize your vertex data in a way that makes it possible to render it with OpenGL vertex arrays. OpenGL vertex array rendering does not support multiple index arrays, so all your vertex data (coordinates, normals, colors and texture coordinates) must use the same index array; or use OVERALL binding. For the indexed nodes, this means that PER_VERTEX_INDEXED and OVERALL are the only supported bindings for materials, normals and texture coordinates. When PER_VERTEX_INDEXED binding is used, the corresponding index field should by empty. This will signal the shape to use the coordIndex field for indices. Below is an example scene graph that will be rendered using vertex arrays: NormalBinding { value PER_VERTEX_INDEXED } Coordinate3 { point [ 0 0 0, # 0 1 0 0, # 1 2 0 0, # 2 0 1 0, # 3 1 1 0, # 4 2 1 0, # 5 0 2 0, # 6 1 2 0, # 7 2 2 0, # 8 2 0 0, # 9 2 0 -1, # 10 2 1 0, # 11 2 1 -1, # 12 2 2 0, # 13 2 2 -1 # 14 ] } Normal { vector [ 0 0 1, # 0 0 0 1, # 1 0 0 1, # 2 0 0 1, # 3 0 0 1, # 4 0 0 1, # 5 0 0 1, # 6 0 0 1, # 7 0 0 1, # 8 1 0 0, # 9 1 0 0, # 10 1 0 0, # 11 1 0 0, # 12 1 0 0, # 13 1 0 0 # 14 ] } IndexedFaceSet { coordIndex [ 0, 1, 4, 3, -1, 1, 2, 5, 4, -1, 3, 4, 7, 6, -1, 4, 5, 8, 7, -1, 9, 10, 12, 11, -1, 11, 12, 14, 13, -1 ] normalIndex [ ] # = use coordIndex }.fi Please note that since only one index array can be used, it might be necessary to supply duplicate normals and coordinates to meet this requirement. Also, if normals are needed, you have to supply them. A shape with autogenerated normals can't be rendered using vertex arrays (since a single coordinate might get multiple normals). The PointSet nodes can always be rendered using vertex arrays since these nodes haven't got index arrays, and the only bindings supported are PER_VERTEX and OVERALL. If it's inconvenient to create vertex array ready scene graphs directly from your application, it's also possible to use SoReorganizeAction to reorganize the geometry before rendering. Version 3.1.3 Wed May 23 2012 vbo_rendering(3)
All times are GMT -4. The time now is 02:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy