Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 1.35 KB | None | 0 0
  1. type Constraint
  2.   name::String
  3.   relation::String
  4.   limit::Float64
  5.   weight::Float64
  6. end
  7.  
  8. global rel_nuclides3 = Array(Constraint, 0)
  9. sizehint!(rel_nuclides3, 6)
  10. function get_rel_nuc(nuc_name::String, rel::String, limit::String, weight::String)
  11.   if isempty(limit) limit = 0
  12.   else limit = float(limit)
  13.   end
  14.   if isempty(weight) weight = 1
  15.   else weight = float(weight)
  16.   end
  17.   push!(rel_nuclides3, Constraint(nuc_name, rel, limit, weight ) )
  18.   print(rel_nuclides3)
  19. end
  20. @qmlfunction get_rel_nuc
  21.  
  22. function rm_rel_nuc(x::String)
  23.   deleteat!(rel_nuclides3, find( [rel_nuclides3[i].name for i=1:length(rel_nuclides3)] .== x))
  24.   print(rel_nuclides3)
  25. end
  26. @qmlfunction rm_rel_nuc
  27.  
  28. function get_relation(nuc_name::String, rel::String)
  29.   rel_nuclides3[ find( [rel_nuclides3[i].name for i=1:length(rel_nuclides3)] .== nuc_name) ][1].relation = rel
  30.   print(rel_nuclides3)
  31. end
  32. @qmlfunction get_relation
  33.  
  34. function get_limit(nuc_name::String, limit::String)
  35.   rel_nuclides3[ find( [rel_nuclides3[i].name for i=1:length(rel_nuclides3)] .== nuc_name) ][1].limit = float(limit)
  36.   print(rel_nuclides3)
  37. end
  38. @qmlfunction get_limit
  39.  
  40. function get_weight(nuc_name::String, weight::String)
  41.   rel_nuclides3[ find( [rel_nuclides3[i].name for i=1:length(rel_nuclides3)] .== nuc_name) ][1].weight = float(weight)
  42.   print(rel_nuclides3)
  43. end
  44. @qmlfunction get_weight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement