Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 Re: Programing » playing around with building grids out of strings » 19-Nov-2018 16:33:19

I think a simple shortcut would be

1. turn the new string element into an S r1 list like this where String_element is a string and Lfirst_list is an [S r1] list:
2. join old list to new list sing os3d list function lcat    (p ,q  )   
3. return old list+new list

fun add_to_end_of_list (first list, String_element)=
//step 1
let String_element::nil-> last_list in
// step 2
lcat	 Lfirst_list last_list;;

I'll try this when I have time.

#2 Re: Programing » playing around with building grids out of strings » 19-Nov-2018 15:41:27

thanks for that ++ insertion Iri.

A question...is there a way to add an element to the end of a list as opposed to the beginning (I've done some looking on redmine to see if the function is in one of the libraries but haven't found it):

If I change

set list = element::list;

to

set list = list::element;

scol throws an error, I assume because I am adding an element that comes after the end of the tail of the list, which is nil.

(!) Line #11:
	list??;;
>>> ERROR - Type mismatch (detail):
Found:    fun [S [S r1] I] [S r1]
Expected: fun [[[r1 r1] r1] [r1 r1] I] [r1 r1]

I'm also curious as to what:

Expected: fun [[[r1 r1] r1] [r1 r1] I] [r1 r1]

means. r1 states the type of recursivity. how can you have recursivity of recursivity? i thought recursivity is only a property of elements, such as S, I, F, user_defined_struct, etc. But recursivity of recursivity? I'm mystified. Sounds like something out of Godel's Theorem.


a list of any objects with a tuple of coordinates instead of string

yes that would be a great idea for creating endless cities. something where you create a grid of square shaped So3 scene nodes (randomly drawn from an array different meshes, all formed so that they can seamlessly join to one another), resize if needed, and then go explore, something like a less spectacular version of 4'10" of this (made with non realtime mandelbulb...https://www.youtube.com/watch?v=PWMTDRWJqu4 )

#3 Programing » playing around with building grids out of strings » 18-Nov-2018 21:48:50

hebdemnobad
Replies: 4

long time (for me) and no coding, my brain has been getting out of shape

I've been thinking about how to build a grid of objects in scol, starting (and perhaps ending) with strings in the system console.

This code has two functions.

The first function takes a string element S , an integer I specifying how many times the element is to occur in a list,  and returns a list of strings: S R1

proto make_string_list =  fun [S [S r1] I ] [S r1];;

The second function takes a list of strings S r1, a multiplier, which counts how many individual strings are to be printed to the console before the console begins writing a new line I, and returns an output string S, which is a grid of the strings written with multiplier I strings per line:

proto build_line_return_string = fun[[S r1] I I S]  S;;

Here is the whole package. I figure this could be done in os3d to build grid like structures for fps games or, if the input of each element is varied, to build grid like city structures:

proto build_line_return_string = fun[[S r1] I I S]  S;;
proto make_string_list =  fun [S [S r1] I ] [S r1];;




fun make_string_list(element, list, iterations) =
let 0 -> counter in
(
while (counter < iterations) do
(
set list = element::list;
set counter=counter+1;
);
);
list;;



fun build_line_return_string (list, multiplier, counter, output_string)=
	
	//end of list, return full string
	if ((hd list)== nil) then
	(
	
	output_string;
	)
	else
	//not end of list yet
	(	
	if ((mod counter multiplier)==0)
	then
	(
	//add head of list to end of string, add line return since we are at a multiple of multiplier that 
        //determines line length and 
        //feed tail of list and changed string back into function
	set output_string= strcatn output_string::(hd list):: "\n"::nil;
	set counter = counter +1;
	build_line_return_string tl list multiplier counter output_string;
	)
	else
	(
        //add head of list to end of string followed by a space, feed tail of list 
        //and changed string  back into function
	set output_string = strcatn output_string::(hd list)::" "::nil;
	set counter = counter +1;
	build_line_return_string  tl list multiplier counter output_string;

	);
	);;	
	
fun main()=
_showconsole; 
let make_string_list "vv" nil 100-> string_list in
_fooS build_line_return_string string_list 2 1 nil;
0;;

#4 Re: Pub - Café » Nice » 16-Jul-2016 15:29:39

If it's of any comfort, ISIS' days are numbered.
1. Never attack France, the U.S., and Russia at the same time.  Bad idea

2. These attacks signal a wounded animal. The v1 and v2 attacks started when Hitler knew the game was over.

Not so comforting:
Ideologies like ISIS act like a great attractor to sociopaths everywhere. Hopefully when their paradise is destroyed their attractiveness will dwindle.

#5 Pub - Café » Nice » 15-Jul-2016 19:07:07

hebdemnobad
Replies: 5

Are you guys, friends, and family ok?

#6 Re: Programing » are there any plans on updating api documentation? » 11-May-2016 20:07:22

arkeon wrote:

Hello,

on android you only have one window (the one created by the system)
for OS3D it's used to bind the 3D buffer on it. and then use 3D overlay bitmaps for HUD

We are currently looking AT QT library to make much better windows support, first for IOS and Raspberry pi port and then latter for android if it works as expected


going ot...does the scol vm on android have any interoperatbility functions (i.e. like sharing the url of the .pak to other apps or launching other apps, and vice versa)?

#7 Re: Programing » multitouch throttle plugit (wip) » 11-May-2016 19:21:21

I updated parts of the .xml file, editor and client. The update places padding between the throttle handle and the top and bottom of the throttle itself, so the handle doesn't move to high or two low. The -.1.0 to .1.0 values are adjusted taking into consideration the padding specified by the user.

I haven't coded the touchpoint behavior into this, so the adjustments just work with a mouse.

This is more or less like a slider control, where 0 is at the middle and the values go up or down from there. I think I will take some options out of the editor (such as the hover/active states)

Uses: moving a handle up and down and making numbers move from 0.0 up to 1.0 and 0.0 down to -1.0.

I plan to put in more options (swapping from left to right or vice versa. maybe making an option to make the throttle horizontal instead of vertical.

Iri I have taken your advice and have broken down some functions into smaller parts so several functions can call on a common function. 

It makes things less confusing, but I see where whiteboards come in useful.

http://ifam.net/mediaoctopus3d/throttlefiles.zip

#8 Re: Programing » are there any plans on updating api documentation? » 11-May-2016 18:02:50

arkeon wrote:

Hello,

on android you only have one window (the one created by the system)
for OS3D it's used to bind the 3D buffer on it. and then use 3D overlay bitmaps for HUD

We are currently looking AT QT library to make much better windows support, first for IOS and Raspberry pi port and then latter for android if it works as expected

i see...so the only 2d gui on android atm the bitmap widget is the only way of conveying text information?

#9 Re: Programing » are there any plans on updating api documentation? » 11-May-2016 16:52:08

iri wrote:

Hi !
At which api do you think ?

Hello...


The non os3d graphic api.....how iOS and android handle the equivalent of windows...the "pages" you shift between in those os's since you aren't using a floating window interface.

I think sometime over the last few months you mentioned some new term that is polymorphic and returns a string representing the type of an object.

#10 Programing » are there any plans on updating api documentation? » 11-May-2016 13:25:06

hebdemnobad
Replies: 7

colleagues:
are there any plans on updating api documentation?

answer at your leisure.


-h

#12 Re: Pub - Café » Paris » 18-Dec-2015 22:39:06

Vive La Republique!


http://www.cnn.com/2015/12/14/europe/fr … ond-round/

Maintenant, nous devons faire la même chose aux États-Unis d'Amérique en 2016 que nous avons notre propre style du front national candidat et mégalomane, M. Trump. 


Le fascisme n'échoue jamais de nourrir sur la peur, n'importe quel pays.

#13 Re: Openspace3D » Multiple. Skeletons for one .mesh » 12-Dec-2015 16:42:53

arkeon wrote:

no this is not implemented that way for now.
what the purpose here ? you mean you want a skeleton file per animation ?


I see. Not one skeleton per animation but one fk animated skeleton and one ik skeleton....so I don't have to do as much work in blender. No worries I'll look into an fk ik switch in blender.

#14 Re: Openspace3D » Multiple. Skeletons for one .mesh » 12-Dec-2015 16:00:29

arkeon wrote:

I'm not sure about Ogre, but the answer is no with the SO3Engine.

But a skeleton can have several root bones.

thx Arkeon
I see...I don't think my question was clear enough. What I meant was can a .mesh use skeleton 1, then os3d unlocks skeleton 1 and links another skeleton to the same mesh.

#15 Openspace3D » Multiple. Skeletons for one .mesh » 11-Dec-2015 23:10:48

hebdemnobad
Replies: 4

Colleagues. ...I couldn't find an answer on ogre3d.org...can one .mesh use multiple skeletons  (I'm  making a rig in blender and would like to use an ik  version and an fk version.....but this is pretty complicated in blender, it would be easier just to use two skeletons)

#16 Re: Pub - Café » time for a mascot » 3-Dec-2015 22:33:18

i'm rebuilding it so it has only manifold geometry (normal shaders don't like using planes so i gave up on the old model)
side.png
top.png
bottom.png

#17 Re: Programing » a cylinder soap opera/ mon feuilleton de cylrindres » 1-Dec-2015 20:46:44

iri wrote:

Well, few remarks in vrac.

//fun [] I
//get an id from lDeleted_cylinder_ids....if there are no ids available, return 0, once an index is encountered, return the index
fun get_deleted_cylinder_ID ()=

Are you sure that an index will never be equal at 0 ? If no, you should return nil instead if the deleted list is empty.

Thx I changed that, I don't know how the index could ever be zero, but nil does seem safer.

You should rename explicitely your variables. By example, in lDeleted_cylinder_ids, the first l for a list is ok. But lindex is an integer, not a list. Why this first l ? An i (iIndex by example) is more comprehensive for the reader. And if the second character is upper, keep this convention.

I'll do that when I work on my throttle plugit that I never finished.

To optimize easily the memory, you should avoid to define uselessly some locale variables. By example :

fun add_cylinder()=
   (...)
   let @birthphase -> birth_function in
   let @deathphase -> death_function in
   let @returnvolume-> volume_function in
   let @returnarea -> area_function in
   (
       //assign birth and death functions
      set lcylinder.fbirthfunction = birth_function;
      set lcylinder.fdeathfunction = death_function;
      set lcylinder.funreturnarea = area_function;
      set lcylinder.funreturnvolume = volume_function;
(...)

Write instead :

fun add_cylinder()=
   (...)
   (
       //assign birth and death functions
      set lcylinder.fbirthfunction = @birthphase ;
      set lcylinder.fdeathfunction = @deathphase;
      set lcylinder.funreturnarea = @returnvolume;
      set lcylinder.funreturnvolume = @returnarea;

done

If i understand correctly, you want keep the index value when a cylinder is deleted ? Right ?

yes

If several life span exist, set several lists may be another method, instead of a big list. One list by life span. It is an idea ...
Or, if you know, you could use an hash table (otherwise, forget that !).

I set things up so the lifespan is anywhere from ms  to around 1638 ms.

A timer object (not only in Scol) is always a greedy object. Some timers are ok. A large number can be problematic, especially as they are destroyed to the first "top". Perhaps, one timer by life span and all cylinders (for a given life span) are created and destroyed in the same "top" ? Depending on your project, of course.

If the vm had something like a built in frame by frame callback, I could build some sort of 'kill' function depending on the lifespan left in each cylinder. But os3d does, and that's where I want to apply this knowledge.


This is a good start !

Thanks!  I think I'll end it here, these cylinders have had enough attention from me. Perhaps this example will help others who want to see how you can build simple objects and have them do things, albeit trival things. On to something some other people can actually use.

#18 Re: Programing » a cylinder soap opera/ mon feuilleton de cylrindres » 1-Dec-2015 17:12:43

I still haven't figured how to configure bluefish so I can paste the code into posts correctly, here is the .pkg:

http://ifam.net/openspace3d/coding/cylinderlist6.pkg

#19 Programing » a cylinder soap opera/ mon feuilleton de cylrindres » 1-Dec-2015 16:55:51

hebdemnobad
Replies: 4

to re familiarize myself with scol for this winter's efforts (I hope to actually finish some project, however small, a plugit at least that others can use, maybe the throttle from last year, or using arkeon's avatar plugit to support user determined meshes for virtual meetings and, at my son's request, fps shooters), I made a script that creates objects, executes their functions, and destroys them by building and destroying lists.  it puts the objects in one list and their unique indexes in another list, and minimizes the time consuming recursive list functions (searching through a list to find, do, add, or remove something) to one.  maybe this could be used in a simple fps game, where the players are hiding behind structures that appear and disappear randomly.

i'm sure there are more elegant ways to do this.  i wanted to write a script that could store unused indecies for objects in one list, so that when there were available indices, the vm would not have to iterate through an entire list.  i was thinking of setting the maximum index each time a new object (cylinder) was created, but if the objects have different lifespans, I'm not sure if that would work.

struct   Cylinder =[

	Icylindernumber	:	I,

	Icylinderindex		:	I,

	Fradius				: 	F,

	Fheight				: 	F,

	funlifespan			:	Timer,
	Ilifespanlength 	:	I,

	Sbirthfphrase		:	S,

	Sdeathphrase		:	S,

	fundyingclyinder	:	fun [Cylinder] S,

	funreturnarea		:	fun [Cylinder] F,

	funreturnvolume	:	fun[Cylinder] F,

	fbirthfunction  	:  fun[Cylinder] S,

	fdeathfunction  	:  fun[Cylinder] S

	

	]mkCylinder;;


//global list of Cylinders to grow and shrink

typeof lCylinderlist=[Cylinder r1];;
//global list of intergers to grab for new cylinders if they are free and to hold indeces of dead cylinders

typeof lDeleted_cylinder_ids = [I r1];;

typeof ICylinder_counter=		I;;

var Ihighest_Cylinder_Index= 0;;



//fun [Cylinder] F

fun returnarea(cylinder)=

   PIf*. cylinder.Fradius;; 

//fun [Cylinder] F 

fun returnvolume(cylinder)=

   (returnarea cylinder)*. cylinder.Fheight;; 



//fun [Cylinder] S

fun birthphase(cylinder)=

   _fooS strcatn "My name is: ":: (itoa(cylinder.Icylinderindex))::" and now I am being born, hello!"::nil;
   _fooS strcatn "My lifespan is :":: (itoa (cylinder.Ilifespanlength)):: " milliseconds."::nil;;

//fun [Cylinder] S     

fun deathphase(cylinder)=

   _fooS strcatn "My name is: ":: (itoa(cylinder.Icylinderindex))::" and now I am dying, goodbye!"::nil;;

/* --------- */



// Miscelleanous

// Note : A function already exists for that in the standard library

fun removeItemInList (list, item)=

	if list == nil then

		nil

	else

		if item == hd list then

			tl list

		else

			(hd list) :: removeItemInList tl list item;;

			

/* --------- */



//fun [] I

//get an id from lDeleted_cylinder_ids....if there are no ids available, return 0, once an index is encountered, return the index

fun get_deleted_cylinder_ID ()=

_fooS "get_deleted_cylinder_ID called";

let hd lDeleted_cylinder_ids -> head in

(

	if (head == nil)  then 

		(

		// there are no available deleted cylinder indexes, they have been used up between the function calling this function and the execution

		//of the line below

		nil;

	) else

	(

	

		_fooS strcatn "head of lDeleted_cylinder_ids is ":: (itoa head)::nil;

		//remove head from lDeleted_cylinder_ids

		set lDeleted_cylinder_ids=  (tl  lDeleted_cylinder_ids);

		_fooS strcatn "the new head of the lDeleted_cylinder_ids list is: " ::(itoa(hd lDeleted_cylinder_ids))::nil;

		_fooS strcatn "the head of the list in this function after resetting list is: ":: (itoa head)::nil; 

		head; 

	



	);

);;

	

//fun [[Cylinder r1] I] I

fun get_highest_id_from_cylinderlist (cylinderlist, id)=

//we want to get the highest Cylinder.Icylinderindex that exists in this list

if ((hd cylinderlist)==nil)&& ((sizelist lCylinderlist)==0) then

(

_fooS "there are no items in the list at all";

1;

)

else if ((hd cylinderlist)==nil)&& ((sizelist lCylinderlist)>0) then

(

      _fooS "we are at the end of a list that has items in it";

      _fooS strcat  "the following value is the highest value found in the complete list is: " (itoa id);

      //since we are making a new cylinder with an index that does not exist, increment global

      //Ihighest_Cylinder_Index by 1 from the highest found id

      set Ihighest_Cylinder_Index = id+1;

      Ihighest_Cylinder_Index;

) 

else

   //we are not at the end of the list yet

(

   //_fooS "there are items in the list and we are not at the end yet";

   let hd cylinderlist -> cylinder in

   let cylinder.Icylinderindex -> this_index in

   if (this_index > id) then

      (

         set id = this_index;

         //_fooS strcat "the highest id found so far is: " (itoa id);

         //we havve the higghest id so far, recursively search through rest of list

         //to see if we can find a higher id

         get_highest_id_from_cylinderlist (tl cylinderlist) id;



      )

   else

      (

         //don't change the id, we have the highest found so far

         //so we recursively search through rest of list

        // _fooS strcat "the highest id found so far is: " (itoa id);

         get_highest_id_from_cylinderlist (tl cylinderlist) id;



      );

);;



//fun[] I

fun get_highest_id_from_all_lists()=

	let  get_deleted_cylinder_ID -> result in

	(

//if there are no items in lDeleted_cylinder_ids, go search for highest id in lCylinderlist

if (result == nil) then

   (

    

    get_highest_id_from_cylinderlist  lCylinderlist nil;

   )

   else

   (

     result;

      

   );

   );;





//fun [cylinder] lCylinderlist



fun delete_cylinder(timer, dcylinder)=

   //destroy the timer

   _deltimer timer;

   //execute death function

   exec dcylinder.fdeathfunction with [dcylinder];

   //add the deleted cylinder index to the lDeleted_cylinder_ids list, so we can grab it if it is free and we add a new cylinder

   let dcylinder.Icylinderindex -> lindex in

   ( 

   _fooS strcatn "cylinder with index number ":: (itoa lindex):: " has died"::nil;

   //add index to lDeleted_cylinder_ids

   set lDeleted_cylinder_ids =lindex:: lDeleted_cylinder_ids;

   //decrement amount of cylinders in existence

   set  ICylinder_counter= ICylinder_counter-1;

   //remove cylinder from lCylinderlist

   set lCylinderlist= removeItemInList lCylinderlist dcylinder;
   _fooS strcatn "there are now :" ::(itoa(sizelist   lDeleted_cylinder_ids))::" cylinders in the lDeleted_cylinder_ids list."::nil;

   _fooS "the list of deleted cylinder id's is below:";  

   _fooIdList  lDeleted_cylinder_ids;

 

    _fooS strcatn "there are now ":: (itoa (sizelist lCylinderlist))::" cylinders in the lCylinderlist. \n \n \n":: nil;

    lCylinderlist;

   );;



//fun [Cylinder Timer] Cylinder

fun makeCylinderTimer (sCylinder, lifespan)=
	 //assign the lifespan in milliseconds for our ephemeral cylinder
   set sCylinder.Ilifespanlength = lifespan;

	set sCylinder.funlifespan = _rfltimer _starttimer _channel lifespan @delete_cylinder sCylinder;

	sCylinder;; 

  

//fun [] Cylinder

fun add_cylinder()=

   //whenever we add a cylinder, no matter where its id comes from, we are incemeneting the ICylinder_counter by one

   set ICylinder_counter=ICylinder_counter+1;

   //get cylinder id

   let get_highest_id_from_all_lists -> id in

   let  mkCylinder [ICylinder_counter id 2.0 22.0 nil nil nil nil nil nil nil nil nil ]->lcylinder in
   let rand/20 -> llifespan in

   let makeCylinderTimer lcylinder llifespan-> lcylinder in


   (

     


       //assign birth and death functions

      set lcylinder.fbirthfunction = @birthphase;

      set lcylinder.fdeathfunction =  @deathphase;

      set lcylinder.funreturnarea = @returnvolume;

      set lcylinder.funreturnvolume = @returnarea;

       //execute birth function

      _fooS "\n \n \n \n";

       _fooS "new cylinder created!";

      exec lcylinder.fbirthfunction with [lcylinder];

      let exec lcylinder.funreturnarea with [lcylinder] ->result in

      _fooS strcat "my area is " (ftoa result);

      let exec lcylinder.funreturnvolume with [lcylinder] ->result in

      _fooS strcat "my volume is " (ftoa result);



      //add cylinder to global lCylinderlist

      set lCylinderlist= lcylinder::lCylinderlist;

      _fooS strcatn "there are now ":: (itoa (sizelist lCylinderlist))::" cylinders in the lCylinderlist.":: nil;

      _fooS strcatn "the new cylinder id is: ":: (itoa id)::nil;

      lcylinder;

  );;

  

fun add_another_cylinder_after_timer(timer, param)=

   

_deltimer timer;

let 100 -> counter in

while (counter >0) do

(

add_cylinder;

set counter= counter-1;

);;





fun main()=

_showconsole;

let 20 -> counter in

while (counter >0) do

(

add_cylinder;

set counter= counter-1;

);

_rfltimer _starttimer _channel 4000 @add_another_cylinder_after_timer  nil;;

[edited] as per most of Iri's suggestions.

#20 Re: Programing » remove_from_list and removeItemInList don't seem to be working » 30-Nov-2015 17:54:54

iri wrote:

This is normal. The returned list is your result.

set list1 = remove_from_list list1 561;

and you are happy smile

yes I am thx!

#21 Programing » remove_from_list and removeItemInList don't seem to be working » 30-Nov-2015 16:16:58

hebdemnobad
Replies: 2

by inference, the cause is probably me, but here it is, neither  remove_from_list and removeItemInList  seem to be removing the requested item from the list

  • neutral

typeof list1 =[I r1];;
typeof list2 =[I r1];;

fun remove_from_list(l,p)=
 if l==nil then nil
 else let l -> [a nxt] in
  if a==p then nxt
  else a::remove_from_list nxt p;;


fun removeItemInList (list, item)=
	if list == nil then
		nil
	else
		if item == hd list then
			tl list
		else
			(hd list) :: removeItemInList tl list item;;
			
fun main()=
   _showconsole; 
   set list1= 2::8::561::591::nil;
   set list2= 2::8::561::591::nil;
    _fooS  "we are starting with list1 below:";
    _fooIdList  list1; 
    remove_from_list list1 561;
    _fooS  "the list after remove_from_list is below";
    _fooIdList list1;
     _fooS  "we are starting with list2 below:";
    _fooIdList  list2; 
    removeItemInList list2 561;
    _fooS  "the list after removeItemInList is below";
    _fooIdList list2;;

#22 Re: Programing » how to get the highest index from a list of struct objects » 30-Nov-2015 00:51:20

Thanks for the correction Iri .....bluefish indents fone for me but I lose the tabs when I paste into posts. I will try changing that setting Arkeon.

[edit]  I checked out my code....I hadn't pasted all of it in and it looks more or like your correct function Iri.
But I get the point...if you can avoid stepping through a list, especially a big one, it's better to do that.

#23 Programing » how to get the highest index from a list of struct objects » 29-Nov-2015 21:09:45

hebdemnobad
Replies: 4

Edited to reflect Iri's observation below, although I'm still having problems with formatting indents from bluefish.

There is probably a list function that would make this easier, but, in any case, if you have a struct of whatever kind, and one of the fields of the struct, named  Iwhateverindex  is an interger, and you are trying to find the object that has the highest Iwhateverindex , this is how you can do it.  in this example, the Iwhateverindex  property is named Icylinderindex:

struct   Cylinder =[
	Icylindernumber:	I,
	Icylinderindex:	I,
	Fradius			: 	F,
	Fheight			: 	F,
	Tlifespan		:	Timer,	
	Sbirthfphrase	:	S,
	Sdeathphrase	:	S,
	fundyingclyinder:	fun [Cylinder] S,
	funreturnarea	:	fun [Cylinder] F,
	funreturnvolume:	fun[Cylinder] F
	
	]mkCylinder;;
	
typeof lCylinderlist=[Cylinder r1];;
typeof lDeleted_cylinder_ids= [I r1];;
typeof ICylinder_counter=		I;;
var Ihighest_Cylinder_Index= 0;;

fun get_highest_id_from_cylinderlist (cylinderlist, id)=
//we want to get the highest Cylinder.Icylinderindex that exists in this list!!!!!
if ((hd cylinderlist)==nil)&& ((sizelist lCylinderlist)==0) then
(
_fooS "there are no items in the list at all";
1;
)
else if ((hd cylinderlist)==nil)&& ((sizelist lCylinderlist)>0) then
(
_fooS "we are at the end of a list that has items in it";
_fooS strcat  "the following value is the highest value found in the complete list is: " (itoa id);
id;
) 
else
//we are not at the end of the list yet
(
_fooS "there are items in the list and we are not at the end yet";
let hd cylinderlist -> cylinder in
let cylinder.Icylinderindex -> this_index in
if (this_index > id) then
(
set id = this_index;
_fooS strcat "the highest id found so far is: " (itoa id);
//we havve the higghest id so far, recursively search through rest of list
//to see if we can find a higher id
get_highest_id_from_cylinderlist (tl cylinderlist) id;

)
else
(
//don't change the id, we have the highest found so far
//so we recursively search through rest of list
_fooS strcat "the highest id found so far is: " (itoa id);
get_highest_id_from_cylinderlist (tl cylinderlist) id;

);
);;


fun main()=
_showconsole;
let mkCylinder [1 879 nil nil nil nil nil nil nil nil]-> cylinder1 in
let mkCylinder [2 1056 nil nil nil nil nil nil nil nil]-> cylinder2 in
let mkCylinder [3 3456 nil nil nil nil nil nil nil nil]-> cylinder3 in
set lCylinderlist = cylinder1:: cylinder2::cylinder3::lCylinderlist; 
let nth_list lCylinderlist 0-> dcylinder in
let dcylinder.Icylinderindex -> index in
_fooS strcatn "the result of the index search through the list is:  ":: (itoa  (get_highest_id_from_cylinderlist lCylinderlist nil))::nil;;

#24 Re: Programing » Persistence of objects or(?) freeing memory » 27-Nov-2015 02:06:20

Thx Arkeon  and iri....my brother just confirmed this (and explained it more to me...he teaches computer science at the university level).

#25 Re: Programing » Persistence of objects or(?) freeing memory » 26-Nov-2015 20:56:44

iri wrote:

I don't remerber precisely.


(hd list) :: removeItemInList tl list item;

This line removes nothing. Instead of that, it adds (so, it keeps) the current item.
In fact, once the function finishes, the returned list is the truncated list.
Thus, it is after the line below that a GC could free the deleted item.

set lCylinder = removeItemInList lCylinder sCylinder;

I'm clear ?

Oops I quoted the wrong line....yes its clear now.

Board footer

Powered by FluxBB