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

Arg literal % #50

Closed leek5pin closed 9 years ago

leek5pin commented 9 years ago

(map #(+ %a 1) [1 2 3]) Error: arg literal must be %, %& or %integer Found in file may2015.clj on line 18 at character 12. intro.core/-main (core.clj line 114)

java.lang.IllegalStateException

elenam commented 9 years ago

The message there should be something like "% must be either on its own or followed by a number or &". A note: (#(+ %1.99 1) 5) works, 1.99 rounds down to 1. Thus saying "an integer" is actually too restrictive. However, (#(+ %0.99 1) 5) rounds down to zero and gives a weird error (from tryclojure): java.lang.RuntimeException: Unable to resolve symbol: p0__8999# in this context Putting a negative number gives an even stranger error.

I don't think we need to worry about the zero case and the negative case.

leek5pin commented 9 years ago

I was able to fix the wording on it, by adding it into error_dictionary, but I can't get my test for the new wording to pass. If I push, can you take a look at it?

elenam commented 9 years ago

Sure. You will probably need to pull first since I refactored the way hints are handled which affected multiple files.

leek5pin commented 9 years ago

I had some trouble pushing, and I think it just worked, but you should take a look at it.

elenam commented 9 years ago

Ok, will do in a few minutes.

On Tue, Jun 23, 2015 at 1:30 PM, Sean Stockholm notifications@github.com wrote:

I had some trouble pushing, and I think it just worked, but you should take a look at it.

— Reply to this email directly or view it on GitHub https://github.com/Clojure-Intro-Course/clojure-intro-class/issues/50#issuecomment-114600843 .

Dr. Elena Machkasova Associate Professor of Computer Science Division of Science and Mathematics University of Minnesota, Morris Office: Sci 2325 (320) 589-6308 http://cda.morris.umn.edu/~elenam/

elenam commented 9 years ago

Done. You can pull now. The issue is that it's a parsing error, and so it's like a compilation error: the code fragment can't be parsed, so it's not even running, and the exception is thrown directly to the top level. I fixed it by moving the testing code into a separate file.

leek5pin commented 9 years ago

Is this issue finished?