• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Loading a file and executing it

 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys : Making some progress w/ clojure. Ran into a wall though :




I'm trying to simply (1) load a file, and then (2) execute a method in that file. However, the method is not seen ?

So I have two questions

1) How can I know what methods have been loaded and defined by my file ?

and

2) How can I execute the hello() function in the aforementioned script from REPL ?

and finally,

3) This is unrelated, but.... What is the "#" in the '#"\W+"' function (see below) doing ? I always assumed that # sign's were for anonymous functions, but #"\W+" seems more like a regex, i.e. it shouldnt need a pound before it ?

(filter #(> (count %) 2) (re-split #"\W+" "A day"))


Thanks ..........
 
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using a namespace in your Example1.clj, you'll need to switch to that namespace in the REPL in order to access those functions - or qualify them with the namespace you just loaded. Something like:

assuming the namespace matches your file path name, or:


To get a list of public vars in a namespace, use:

That will show everything in the user namespace (where the REPL is by default) and everything in your test.Example1 namespace. (vals (ns-publics ...)) might prove easier to read.

# identifies a "reader macro" called dispatch and there are several forms, including #(anonymous function), #"regex", #{a set} - see http://clojure.org/reader for more detail.
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On a side note, just keep in mind to use list syntax to call functions in Clojure.
(func param) not func param
 
reply
    Bookmark Topic Watch Topic
  • New Topic