Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
function handlerNames pScript
|
||||
put pScript into pScriptCopy
|
||||
filter pScript with regex pattern "^(on|function).*"
|
||||
-- add in the built-in commands & functions
|
||||
put the commandNames & the functionnames into cmdfunc
|
||||
repeat for each line builtin in cmdfunc
|
||||
put 0 into handlers[builtin]
|
||||
end repeat
|
||||
|
||||
-- add user defined handlers, remove this section of you do not want your own functions included
|
||||
repeat with x = 1 to the number of lines of pScript
|
||||
put word 2 of line x of pScript into handlername
|
||||
put 0 into handlers[handlername]
|
||||
end repeat
|
||||
|
||||
-- count handlers used
|
||||
repeat with x = 1 to the number of lines of pScriptCopy
|
||||
repeat for each key k in handlers
|
||||
if k is among the tokens of line x of pScriptCopy then
|
||||
add 1 to handlers[k]
|
||||
end if
|
||||
end repeat
|
||||
end repeat
|
||||
|
||||
combine handlers using cr and space
|
||||
sort lines of handlers descending by word 2 of each
|
||||
put line 1 to 10 of handlers into handlers
|
||||
return handlers
|
||||
end handlerNames
|
||||
|
|
@ -0,0 +1 @@
|
|||
put handlerNames(the script of this stack & cr & the script of this card & cr & the script of me)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
if 8
|
||||
put 8
|
||||
return 8
|
||||
function 7
|
||||
factorialacc 4 -- user def function for other rosetta task
|
||||
factorialr 3 -- user def function for other rosetta task
|
||||
handlerNames 3
|
||||
factorial 2 -- user def function for other rosetta task
|
||||
factorialit 2 -- user def function for other rosetta task
|
||||
mouseUp 2
|
||||
19
Task/Function-frequency/Sidef/function-frequency.sidef
Normal file
19
Task/Function-frequency/Sidef/function-frequency.sidef
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
var program = <<'EOT'
|
||||
func foo { }
|
||||
func bar { }
|
||||
|
||||
foo(); foo(); foo()
|
||||
bar(); bar();
|
||||
EOT
|
||||
|
||||
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|
|
||||
if (entry{:type} == :func) {
|
||||
say ("Function `#{entry{:name}}` (declared at line",
|
||||
" #{entry{:line}}) is used #{entry{:count}} times")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue