【问题标题】:Scala REPL equivalent for R ls( ) functionScala REPL 等效于 R ls() 函数
【发布时间】:2015-08-24 22:30:33
【问题描述】:

Scala REPL 中是否有任何命令可以打印出已定义的对象?例如,在R 控制台中,函数ls() 打印当前环境中所有定义的对象。

【问题讨论】:

    标签: r scala read-eval-print-loop


    【解决方案1】:

    对于 Scala,R 中没有像 ls() 这样的简单函数。但是可以通过以下方式做类似的事情:

    val ls = $intp
    ls.allDefinedNames.foreach(println)
    

    ls.+tab 将给出以下选项:

    scala> ls.
    SparkComputedImports        addImports                  addUrlsToClassPath          allDefinedNames             allImportedNames            asInstanceOf                
    beQuietDuring               beSilentDuring              bind                        classOfTerm                 classServerUri              classSymbols                
    clearExecutionWrapper       close                       compileSources              compileString               definedSymbolList           definedSymbols              
    definedTerms                definedTypes                definitionForName           directBind                  executionWrapper            fallback                    
    generatedName               getClassOutputDirectory     global                      implicitSymbols             implicitSymbolsBySource     importedSymbols             
    importedSymbolsBySource     importedTermNamed           importedTermSymbols         importedTerms               importedTypeSymbols         importedTypes               
    initializeSynchronous       interpret                   interpretSynthetic          isInstanceOf                isNoImports                 isNoPredef                  
    isReportingErrors           languageSymbols             languageWildcardHandlers    languageWildcardSyms        languageWildcards           lastWarnings                
    methodSymbols               mostRecentVar               namedDefinedTerms           out                         parse                       pathToName                  
    rebind                      requestForIdent             requestForName              requestForReqId             requestHistoryForName       reset                       
    runtimeClassAndTypeOfTerm   runtimeTypeOfTerm           sessionImportedSymbols      sessionWildcards            setExecutionWrapper         symbolOfLine                
    symbolOfTerm                toString                    treesForRequestId           typeOfExpression            typeOfTerm                  valueOfTerm                 
    visibleTermNames            wildcardTypes     
    

    【讨论】:

      猜你喜欢
      • 2016-01-08
      • 2012-02-21
      • 2015-05-25
      • 1970-01-01
      • 2020-09-18
      • 1970-01-01
      • 2020-03-18
      • 2017-01-21
      • 2012-01-07
      相关资源
      最近更新 更多