Fork me on GitHub
#beginners
<
2015-09-15
>
mosho00:09:58

I thought about it more like a package in Java or namespace in C#

devn02:09:31

Maybe he can spread those components and have a single namespace.

devn02:09:05

As long as it's just data you're splitting you could read chunks from separate files into one namespace.

mosho02:09:41

@devn: is that possible in clojurescript?

samueldev13:09:56

morning folks

samueldev13:09:06

I'm confused as to why a test I've written isn't passing

samueldev13:09:33

I've got a simple fn that takes a string of numbers delimited by a space character

samueldev13:09:36

and it adds them together

samueldev13:09:48

The test is for if the string you pass in is empty....

samueldev13:09:26

And the function itself....

samueldev13:09:19

The error I'm getting is a cast exception

samueldev13:09:30

java.lang.Boolean cannot be cast to clojure.lang.IFn

rauh13:09:06

Double check your cond syntax. It's got too many parentheses

samueldev13:09:06

I have to write a good 10-25 tests for this function, so the cond error-occured approach is an attempt to have a more compact way of checking for all of the errors

samueldev13:09:09

rather than 25 if statements

rauh13:09:33

Also, more general: You'd check these things in :pre which automatically throws

samueldev13:09:20

The examples I can find for using :pre don't have any destructuring

samueldev13:09:52

does that approach let me do some fancy let stuff before my :pre and then access those in my :pre?

samueldev13:09:02

Suppose I could just try it 😛

rauh13:09:24

Also: Your code is very imperative style. Try to make it more functional. Eg: Get ride of negatives and error-occured.

rauh13:09:14

I also wouldn't constrict this function to not allow only positive values. You're making that function less useful then. If you don't allow negative values then split it up into two functions. One doing only the parsing returning the sequence of numbers and then your application code checking for negative numbers and calling reduce.

samueldev13:09:52

Haha I don't get to dictate what the function does

samueldev13:09:05

It's a practice app as dictated by my employer

samueldev13:09:32

;;(deftest empty-string-test) ;;(deftest negative-number-test) ;;(deftest single-number-test) ;;(deftest multiple-number-test) ;;(deftest new-line-delimeter-test) ;;(deftest mixed-delimeter-test) ;;(deftest custom-delimeter-test) ;;(deftest multiple-negative-number-test) ;;(deftest numbers-larger-than-1000-test) ;;(deftest long-custom-delimeter-test) ;;(deftest multiple-custom-delimeter-test) ;;(deftest multiple-long-customer-delimeter-test) ;;(deftest can-use-numeric-delimiters)

samueldev13:09:39

are all the tests I have to write 😉

rauh13:09:33

I see, never mind then simple_smile

samueldev13:09:57

So, OK, if I want to test the function I pasted above

samueldev13:09:01

which is defined in my core file

samueldev13:09:39

I understood I could run lein repl, then (ns unit-test-exercise.core), and then in my repl I could just freely call any function defined in my core file to test it out

samueldev13:09:58

Is that not the case? If I follow the steps above, I can't call my fn

samueldev13:09:13

(`Unable to resolve symbol add in this context`)

curtosis14:09:52

beginner?ish cljs question... given the frequency with which the #(-> % .-target .-value) idiom appears, why isn't there a common function to do this? Or am I just blind and haven't noticed it?

curtosis14:09:13

I mean, I see the idiom all over, but never see it abstracted, and so I'm wondering if there's an underlying reason why not.