Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-07-2009, 03:12 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
array.reverse()

or array.flip()

It reverses (or flips) the order of an array. I don't think I need to illustrate this, but I will anyway.

a, d, s, h, r
array.reverse()
r, h, s, d, a

It would also be great to have

array.reverse(start index, end index)

a, d, s, h, r
array.reverse(1, 3)
a, h, s, d, r
__________________
Reply With Quote
  #2  
Old 06-07-2009, 03:28 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Could always get Skyld to add something like:
PHP Code:
function flip(arr) {
  
temp.fliparr = new[arr.size()];
  for (
temp.i=0;i<arr.size();i++) {
    
fliparr[arr.size()-1-i] = arr[i];
  }
  return 
fliparr;

To the public functions... however, I agree.
Reply With Quote
  #3  
Old 06-07-2009, 03:45 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Not trying to be negative, seriously. But can anyone show me a use of this?
__________________
Deep into the Darkness peering...
Reply With Quote
  #4  
Old 06-07-2009, 04:12 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I'm sure there are a few moments in time someone would like to flip a list of whatever.
Reply With Quote
  #5  
Old 06-07-2009, 05:03 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Well it can be a shortcut for, for each loops.. like:

PHP Code:

temp
.array = {12345};

for (
temp.= (array.size()-1); 0); temp.i--) {
  echo(array[
i]);
}

for (
temp.val: array.reverse()) {
  echo(
val);

But other than that this usually doesn't pop up much.
__________________
Quote:
Reply With Quote
  #6  
Old 06-07-2009, 10:47 AM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
You should be able to change the "keys" of arrays, just like in PHP.

Now, that would be something...
Reply With Quote
  #7  
Old 06-07-2009, 06:28 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Angel_Light View Post
Not trying to be negative, seriously. But can anyone show me a use of this?
My most recent encounter with something like this was looping through an array of nodes for a pathfinding script...this would've made things much easier.
Reply With Quote
  #8  
Old 06-07-2009, 07:02 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Alright, thanks you guys. I was literally drawing a blank of when I would ever use it, but the pathfinding thing made sense.
__________________
Deep into the Darkness peering...
Reply With Quote
  #9  
Old 06-07-2009, 07:49 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
I see no point for it to be added into the engine ;o
__________________
Reply With Quote
  #10  
Old 06-07-2009, 09:51 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Chompy View Post
I see no point for it to be added into the engine ;o

Agreed.


With most languages you would have to do something like what Jer posted, and it's not like it's difficult to reverse arrays anyways. If Stefan is willing to update it to the engine then by all means go ahead, I just don't think it's one of those things that really needs to be there.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.