Problem 464. Function Sniffer
- Given a string,
- find out which built-in functions are present,
- output a simple string,
- that has sorted and unique list of the identified functions,
- separated by spaces.
- For example, 'x=cos(theta); y=sin(theta);'
- should produce 'cos sin'.
Solution Stats
Problem Comments
-
4 Comments
The test suite is a little soft. I feel the addition of 'for i=log2(2):abs(n^2-n)', which should yield 'for log2' would stymie almost all the solutions provided.
In my opinion, the Cody problems should expand Matlab understanding not cause frustration in search of obscure functions. To this end, I think the tags should include regexp, symvar, cellfun, sprintf, exist, unique, and cell2mat. Learning the usage of these functions is one purpose of Cody.
also operands like +,-,/,*,.*,~,|,& etc. are treated by Matlab as builtin functions, so in my opinion test case 2 answer sholud be ': sqrt sum' and for test case 3 '- ones rand round'
Imho, operators (+,-,&,etc) are a special kind of function in which parameters are arranged in a certain order. The problem does not need to cover them. And again imho, for and if should not even be considered functions, but structures of repetition and control respectively, because they are built-in hardware (and it's how computers work). Moreover they are not mapping values from a set into another as in Math. Finally "functions" that have no output value should be called procedures (such as reset, delete, and disp).
PS: Some operators, these special functions, are also built-in hardware.
Solution Comments
Show commentsProblem Recent Solvers41
Suggested Problems
-
Renaming a field in a structure array
1517 Solvers
-
1008 Solvers
-
Construct a string from letters and counts
142 Solvers
-
230 Solvers
-
Back to basics 24 - Symbolic variables
143 Solvers
More from this Author100
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!