Function frequency: Difference between revisions

m
(Added a Perl section.)
m (→‎{{header|Sidef}}: updated code)
Line 1,802:
=={{header|Sidef}}==
Sidef provides full access to its parser, allowing us to inspect all the declarations within a program.
<lang ruby>varfunc programfoo ={ <<'EOT'}
func foo { }
func bar { }
 
foo(); foo(); foo()
bar(); bar();
EOT
 
var data = Perl.to_sidef(parserParser{:vars}{:main}).flatten
var parser = Parser.new # initialize a new parser
parser.parse_script( code => program ) # parse the code
 
var data = Perl.to_sidef(parser{:vars}{:main}).flatten
 
data.sort_by { |v| -v{:count} }.first(10).each { |entry|
2,747

edits