File tree Expand file tree Collapse file tree 1 file changed +20
-15
lines changed Expand file tree Collapse file tree 1 file changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -15,22 +15,27 @@ def abs
1515 end
1616
1717 def to_proc ( *args )
18- if args . empty?
19- if free_symbols . count > 1
20- raise ArgumentError , 'You should provide symbols order for #to_proc' \
21- '. Only formulae with 1 free symbol can deduce' \
22- ' its name automatically (#{free_symbols.count}' \
23- ' found in #{self}).'
24- end
25- return SymEngine . lambdify ( self , free_symbols . map { |s | s } )
26- else
27- if free_symbols . count > args . length
28- raise ArgumentError , 'Formula contains #{free_symbols.count} free ' \
29- 'symbols. You should provide at least this number ' \
30- 'of arguments (only #{args.length} given).'
31- end
32- return SymEngine . lambdify ( self , args )
18+ SymEngine . lambdify ( self , args . empty? ? default_args : check_args ( *args ) )
19+ end
20+
21+ def default_args
22+ if free_symbols . count > 1
23+ raise ArgumentError , 'You should provide symbols order for #to_proc' \
24+ '. Only formulae with 1 free symbol can deduce' \
25+ " its name automatically (#{ free_symbols . count } " \
26+ " found in #{ self } )."
27+ end
28+ free_symbols . to_a
29+ end
30+
31+ def check_args ( *args )
32+ if free_symbols . count > args . length
33+ raise ArgumentError , "Formula contains #{ free_symbols . count } free " \
34+ 'symbols. You should provide at least this number ' \
35+ "of arguments (only #{ args . length } given)."
3336 end
37+
38+ args
3439 end
3540 end
3641end
You can’t perform that action at this time.
0 commit comments