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 30-Nov-2015 16:16:58

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

remove_from_list and removeItemInList don't seem to be working

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;;

Offline

#2 30-Nov-2015 17:21:03

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: remove_from_list and removeItemInList don't seem to be working

This is normal. The returned list is your result.

set list1 = remove_from_list list1 561;

and you are happy smile

Offline

#3 30-Nov-2015 17:54:54

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: remove_from_list and removeItemInList don't seem to be working

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!

Offline

Board footer

Powered by FluxBB