Re: [Vala] An elegant way to concatenate integers into a string.
- From: Martin DeMello <martindemello gmail com>
- To: Celil <celil kj gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] An elegant way to concatenate integers into a string.
- Date: Thu, 24 Jun 2010 19:53:45 +0530
On Tue, Jun 15, 2010 at 6:17 AM, Celil <celil kj gmail com> wrote:
I would like to translate the following python code snippet to vala:
x = [1,2,3]
print ",".join(map(str, x))
So far I have this:
int[] x = {1,2,3};
string[] y = {};
foreach (var e in x) { y += e.to_string(); }
stdout.printf(string.joinv(",", y));
Is there a better way to do this? Dose vala support something equivalent
to the python built-in `map` function?
Good question; I went through the Vala docs and couldn't find a nice
way either. Might be worth porting Ruby's Enumberable module to Vala.
martin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]