[DGD] Code from Heaven...

Felix A. Croes felix at dworkin.nl
Sat Nov 8 11:49:33 CET 1997


> Can anyone tell me the purpose of the # signs in the code below (taken from
> heaven7)?
> It won't compile on dgd (i tried my own version and plain P3). DGD complains
> about illegal characters.
>
> ------------
> Wim van der Vegt / Dutch Open University
>
> void save_wiz_file() {
>     rm("/info/WIZLIST");
>     write_file(
>       "/info/WIZLIST",
>       implode(
>         map_array(wizlist_info(),
>           lambda(({'a}),
>             ({#'sprintf, "%s %d %d\n",
>               ({#'[, 'a, WL_NAME}),
>               ({#'[, 'a, WL_COMMANDS}),
>               ({#'[, 'a, WL_EXTRA})
>             })
>           )
>         ), ""
>       )
>     );
> }

That's code for Amylaar's 3.2.1 driver.  Lambda expressions are too
odd to explain, but the above code basically does this:

    void save_wiz_file()
    {
	mixed **wizinfo;
	string str;
	int i;

	wizinfo = wizlist_info();
	str = "";
	for (i = 0; i < sizeof(wizinfo); i++) {
	    str += wizinfo[i][WL_NAME] + " " + wizinfo[i][WL_COMMANDS] +
		   + " " + wizinfo[i][WL_EXTRA] + "\n";
	}
	rm("/info/WIZLIST");
	write_file("/info/WIZLIST", str);
    }

Dworkin



More information about the DGD mailing list