Reputation: 23
Part of my code is like this:
Load_name:addLoad({'incrementalnodalload', 7, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
the last part (I mean 1,2,...,10) can be extended as much as required (for example 1,2,...,1000).
Thus I want to replace this part with something like this:
Load_name:addLoad({'incrementalnodalload', 7, 1, inc_number})
inc_number = 1:1000
However, it does not work!
Any suggestion is highly appreciated!
Upvotes: 1
Views: 44
Reputation: 26774
Here is inc_number
function that accepts two parameters and does what you need in this context:
function inc_number(f,t)
if f > t then return else return f,inc_number(f+1,t) end
end
Load_name:addLoad({'incrementalnodalload', 7, 1, inc_number(1,100)})
Note that it only works when the result of inc_number
call is the last parameter in the list of parameters. Example:
print(table.concat({inc_number(1,10)}, ","))
-- prints: 1,2,3,4,5,6,7,8,9,10
Upvotes: 2