help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: equivalent for C-style init: structname varname[] = {...} ?


From: Yury T.
Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
Date: Wed, 14 Nov 2012 08:32:20 -0800 (PST)

Jordi Gutiérrez Hermoso-2 wrote
>> Arrgh! :) Sorry, I'd better go with Sergei's solution or with R, indeed.
>> Thank you all the same.
> 
> Sergei's if anything, is gonna be even *more* complicated, because
> you'll have to replace {s.data} with a bigger expression so you can
> select the ones you want.

Actually, not so. Here's adaptation of my recent example with access to an
individual fields of an item selected by arbitrary key. Reads almost
naturally, right?
Of course, I wasn't shown how make a full range iteration for such a data
structure, so will have to work that out by myself :).

  s = consistent_struct\.
  (.
  "Buffat+Borel 1976 (5)", {"Buffat+Borel 1976 (5)", 13, 1337},
  "Coombes 1972 (2)", {"Coombes 1972 (2)", 13, 1337},
  "Lai+Guo+Petrova+ 1996 (2a)", {"Lai+Guo+Petrova+ 1996 (2a)", 30, 505}
  );.
.
  getfield( s, "Coombes 1972 (2)" ){1}.
  getfield( s, "Coombes 1972 (2)" ){2}.
  getfield( s, "Coombes 1972 (2)" ){3}.




--
View this message in context: 
http://octave.1599824.n4.nabble.com/equivalent-for-C-style-init-structname-varname-tp4646460p4646670.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]