Clojure-Intro-Course / clojure-intro-class

NOTE: This repository is obsolete. Was: A pilot project to use Clojure for introductory computer science courses at the University of Minnesota - Morris
20 stars 3 forks source link

automate precondition generation #98

Open leek5pin opened 8 years ago

leek5pin commented 8 years ago

two step process where minimal thing is humanly readable

need to incorporate meta to get metadata on functions

need to parse metadata to be readable by our asset_handling

leek5pin commented 8 years ago

This should be mostly correct: (re-defn #'clojure.core/reduce [[:f :coll] [:f nil :coll]]) (re-defn #'clojure.core/map [[:f :colls]]) (re-defn #'clojure.core/str [[:args]])

The types so far are: :arg any argument :coll any collection :n any number :colls & collections :str string :strs & strings :f function :fs & functions :args any & arguments

leek5pin commented 8 years ago

That is for input: (pre-re-defn #'clojure.core/reduce) (pre-re-defn #'clojure.core/map) (pre-re-defn #'clojure.core/str)

elenam commented 8 years ago

Whats' the nil in 3-arg reduce?

leek5pin commented 8 years ago

good point. i just noticed that too. I'm not sure what I want that to be.

leek5pin commented 8 years ago

well, I want it to be :arg.

leek5pin commented 8 years ago

Do I? what do you think? We have no reason to check arbitrary arguments, and no reason to do anything at all with a function like #'clojure.core/str

leek5pin commented 8 years ago

I figured out why nil was there. :val was missing from my hash map that went to :arg. although my question still remains.

leek5pin commented 8 years ago

So, it seems to work for everything that does not have pattern matching in the function definition. I'll add functionality for that later. Before that I need to add some testing.

Currently, it will give you nil if the name of the argument is missing from the arg-type map. The clojure cheatsheet entries are mostly the same as the doc-strings, so you can find that missing data there.

You can run this line of code to check it out:

(map #(println (pre-re-defn %)) (vals (ns-publics 'clojure.core)))

elenam commented 8 years ago

Looks great, thanks! I haven't tried it yet, but Tony and I will look at it on Tuesday.