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.
Pages: 1
colleagues:
I am trying to mutate a component in a list:
fun rebuild_list (list)=
let list -> temp_list in
while (tl temp_list) !=nil do
(
mutate hd list <- [strcat (hd list) "/"];
_fooS hd list;
set temp_list = tl temp_list;
);
0;;
I am getting the error:
mutate hd list <- [strcat hd list "/"??];
>>> ERROR - Type mismatch (detail):
Found: [S [S]]
Expected: [S S]
whether I write
mutate hd list <- [strcat (hd list) "/"];
or
mutate hd list <- [strcat hd list)"/"];
or
mutate hd list <- [(strcat (hd list) "/")];
any input welcome to get rid of those [ ] I am generating.
thx
-h
Offline
mutate work only on tuple
here hd list is S
a list is a tuple of tuples
[first_element nexttuple]
so you can use
mutate list <- [strcat (hd list) "/" _];
"_" is the ignored tuple element here the next tuple in the list
Offline
but be careful here is will always add "/" on the first list element only
you should reconstruct a new list with lcat
Thx arkeon....how would I use lcat to insert a "/" between each element of list?
Offline
strcatnSep in tools.pkg
let strcatnSep list "/" -> path in
thx!
how to turn the string harry/sally/jim/ to the list harry:sally:jim:nil and back into harry/sally/jim/:
proto strToListSep = fun [S S] [S r1];;
proto strcatnSep = fun [[S r1] S] S;;
fun secureLoad(pack)=
let _testpak pack -> ret in
if (ret == nil) then
(
_fooS "xmlparser loading";
_load pack;
1;
)
else
(
_fooS strcat "Error in " ret;
0;
);;
fun rebuild_list (list)=
let strcatnSep list "/" -> rebuilt_list_as_string in
let strcat rebuilt_list_as_string "/"->rebuilt_list_as_string in
_fooS rebuilt_list_as_string;
0;;
fun load_dependencies(parameter)=
let "locked/lib/_mlistlib.pkg"::"tools/os3dlib/tools.pkg"::nil -> list_of_dependencies in
(
while (list_of_dependencies!= nil)&& (secureLoad hd list_of_dependencies) do
(
set list_of_dependencies = tl list_of_dependencies;
_fooS "dependencies loading";
);
//all dependencies have been read
if list_of_dependencies==nil then
(
_fooS "done with dependency loading";
_fooS strcatn "original string to chop is":: parameter::nil;
let strToListSep parameter "/" -> templist in
(
_fooS "separated list, each element split by a \" \, \" below";
_fooSList templist;
rebuild_list templist;
);
0;
)
else
(
_fooS "error in dependency loading";
0;
);
);
0;;
fun main()=
_showconsole;
let "harry/sally/jim/" -> list_to_chop in
(
load_dependencies list_to_chop;
);
0;;
Offline
Pages: 1