You're viewing version 1.2.0 of load-file. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

load-file

clojure.core

  • (load-file name)
Sequentially read and evaluate the set of forms contained in the file.

3 Examples top

  • ;; Very useful from a REPL
    ;; Paths are specified as strings using canonical file path notation 
    ;; (rather than clojure-style namespaces dependent on the JVM classpath).
    ;; The working directory is set to wherever you invoked the JVM from, 
    ;; likely the project root.
    
    (load-file "src/mylib/core.clj")
    
    ;; now you can go and evaluate vars defined in that file.
  • ;; file located at src/address_book/core.clj
    ;; current dir is src/..
    
    (load-file "src/address_book/core.clj")
  • ;; create a clojure file on the fly using spit
    ;; then load it into the REPL and use its function
    
    user=> (spit "mycode.clj" "(defn doub [x] (* x 2))")
    nil
    user=> (load-file "mycode.clj")
    #'user/doub
    user=> (doub 23)
    46
    user=>
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/load

    Loads Clojure code from resources in classpath. A path is interpreted

  • 0
    clojure.core/spit

    Opposite of slurp. Opens f with writer, writes content, then close

Log in to add a see also.

Comments top

No comments for load-file. Log in to add a comment.