Created
November 18, 2015 14:46
-
-
Save paulkernstock/8ccbe87f3c7d8a9fb349 to your computer and use it in GitHub Desktop.
Reading out coefficients, dictionary style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
record Dictionary "Dictionary record for getting values using name lookup" | |
parameter String name "Unique name used as identifier"; | |
parameter Real c[:] "Coefficients"; | |
end Dictionary; | |
record R | |
constant String name; | |
end R; | |
function FooFunction | |
input R r annotation(choicesAllMatching=true); | |
output Real[3] o; | |
protected | |
parameter Dictionary[2] dict={Dictionary(name="A",c={1,2,3}),Dictionary(name="B",c={4,5,6})}; | |
Boolean[:] b; | |
Integer index; | |
algorithm | |
b := {i.name == r.name for i in dict}; | |
index :=Modelica.Math.BooleanVectors.firstTrueIndex(b); | |
o := dict[index].c; | |
end FooFunction; |
On stackoverflow, you posted the HTTPS clone URL:
https://gist.github.com/8ccbe87f3c7d8a9fb349.git
That address will work for cloning! Every gist is also a git repository (and it has revisions).
If you want to link to this page here, just copy the URL from the address bar:
https://gist.github.com/8ccbe87f3c7d8a9fb349
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you change the name and extension from gistfile1.txt to example.mo you will get syntax highlighting.