maxim_jaffe
2018-7-28 11:00:53

Good Morning Racket!


maxim_jaffe
2018-7-28 11:01:05

or more like good lunch around here


maxim_jaffe
2018-7-28 11:06:18

So was trying to find any existing functions like residual sum of squares and the likes (along the lines of metrics in scikit-learn http://scikit-learn.org/stable/modules/classes.html#sklearn-metrics-metrics ). Does anyone know of any package that is ok maintained with this type of stuff? The closest I found was https://github.com/n3mo/data-science


maxim_jaffe
2018-7-28 11:07:12

It’s easy enough to program some but they already exist why reinvent the wheel


soegaard2
2018-7-28 11:09:30


soegaard2
2018-7-28 11:11:03

Is there a modern package for the Science Collection ?


maxim_jaffe
2018-7-28 11:28:08

yeah I checked out the general stats one


maxim_jaffe
2018-7-28 11:28:27

let me see the other link


maxim_jaffe
2018-7-28 11:30:57

hum seems like standard math has a lot of equivalent parts of the Science Collection


maxim_jaffe
2018-7-28 11:32:49

think I’ll just put together a small metrics library


maxim_jaffe
2018-7-28 11:32:51

by the way


maxim_jaffe
2018-7-28 11:34:34

is (Sequenceof A) the more general approach to deal with list like things?


maxim_jaffe
2018-7-28 11:36:56

another thing there isn’t anything like a dataframe in Racket is there? I mean I am mostly okay with just arrays and lists of lists


githree
2018-7-28 11:40:11

There is one by RayRacine: https://gitlab.com/RayRacine/munger/


githree
2018-7-28 11:40:53

and Alex Harsanyi is working on his own version here: https://github.com/alex-hhh/ActivityLog2/tree/master/rkt/data-frame


githree
2018-7-28 11:41:06

currently part of ActivityLog2


maxim_jaffe
2018-7-28 11:41:10

cool


maxim_jaffe
2018-7-28 12:09:29

Any idea how I can get the test to work? > (array #[#[2 2] #[2 2]]) - : (Array Positive-Byte) (array #[#[2 2] #[2 2]]) > (random-array #(2 2) 2 3) - : (Array Integer) (array #[#[2 2] #[2 2]])


maxim_jaffe
2018-7-28 12:10:03

-------------------- random-array tests . ERROR check-equal?: contract violation any-wrap/c: Unable to protect opaque value passed as `Any` value: (array #[#[2 2] #[2 2]]) in: the 1st argument of (->* (Any Any) (any/c) any/c) contract from: (interface for check-equal?) blaming: <pkgs>/rackunit-typed/rackunit/main.rkt (assuming the contract is correct) at: <pkgs>/rackunit-typed/rackunit/main.rkt:22.2 --------------------


maxim_jaffe
2018-7-28 12:10:53

even more wierd is that > (equal? (random-array #(2 2) 2 3) (array #[#[2 2] #[2 2]])) - : Boolean #t


maxim_jaffe
2018-7-28 12:13:11

don’t quite understand why equal? works fine and check-equal? doesn’t..!


andika.riyan
2018-7-28 12:48:49

@andika.riyan has joined the channel


maxim_jaffe
2018-7-28 16:06:00

So optimization coach says the following about norm-l2: This expression has a Complex type, despite all its arguments being reals. If you do not want or expect complex numbers as results, you may want to restrict the type of the arguments or use float-specific operations (e.g. flsqrt), which may have a beneficial impact on performance.. I get a green highlighting once I modify it to norm-l2-opt, is this the best way to perform this optimization (with the cast)?


maxim_jaffe
2018-7-28 16:08:03

thanks for any feedback :slightly_smiling_face:


maxim_jaffe
2018-7-28 16:13:56

hum guess real->double-flonum is better then cast, yes?


maxim_jaffe
2018-7-28 16:30:54

yeah sorry for all the questions, it’s just coming from a purely dynamically typed language like Python, guess I didn’t expect this to be so hard sometimes


maxim_jaffe
2018-7-28 16:31:10

I understand the benefits, but doesn’t make it easier


ben
2018-7-28 16:31:35

do you need to use flsqrt here?


ben
2018-7-28 16:31:54

or, can you change Real to Flonum in the function type?


maxim_jaffe
2018-7-28 16:32:19

hum I’ll give it a try


maxim_jaffe
2018-7-28 16:32:35

Flonum instead of Float yeah?


ben
2018-7-28 16:32:43

I don’t remember the difference


ben
2018-7-28 16:33:44

oh, it looks like they’re the same but flonum is from Scheme


maxim_jaffe
2018-7-28 16:35:51

hum from what I understood


maxim_jaffe
2018-7-28 16:36:10

to get the benefit of the optimization I have to use the fl… functions


maxim_jaffe
2018-7-28 16:36:16

can’t seem to find a sum one though


maxim_jaffe
2018-7-28 16:38:07

meh this seems a bit to much for me now will just stick to non-optimized version which seems to at least work


maxim_jaffe
2018-7-28 16:38:37

strange that they don’t have sum in flonum though


ben
2018-7-28 16:46:07

fl+


maxim_jaffe
2018-7-28 16:49:29

Don’t think it does the same


maxim_jaffe
2018-7-28 16:50:06

I tried using a fold but the polymorphism is just a headache to understand


maxim_jaffe
2018-7-28 16:50:33

#lang typed/racket (require math/base typed/racket/flonum)


maxim_jaffe
2018-7-28 16:51:48

ben
2018-7-28 16:51:54

oh, I see #lang typed/racket (require racket/flonum) (: flsum (-> (Listof Flonum) Flonum)) (define (flsum f*) (for/fold ([acc : Flonum 1.0]) ([f (in-list f*)]) (fl+ acc f)))


maxim_jaffe
2018-7-28 16:52:52

hum ok! looks nice


maxim_jaffe
2018-7-28 16:53:04

but


maxim_jaffe
2018-7-28 16:53:07

1.0 ?


ben
2018-7-28 16:53:12

here’s one way to do the fold #lang typed/racket (require racket/flonum) (foldl fl+ 1.0 (map exact->inexact '(1 2 3)))


maxim_jaffe
2018-7-28 16:55:00

guess I can just use 0.0


ben
2018-7-28 16:55:03

ben
2018-7-28 16:55:08

ahhh!


maxim_jaffe
2018-7-28 16:55:47

hum but do you always have to provide a initial value


maxim_jaffe
2018-7-28 16:56:48

I remember using reduce (which is a fold no?) in python don’t remember having to give a first value


maxim_jaffe
2018-7-28 16:56:58

it would just use the first and go from there


maxim_jaffe
2018-7-28 16:57:19

but it’s not unbearable :stuck_out_tongue:, just a bit more verbose I guess


maxim_jaffe
2018-7-28 16:58:18

so is f* a notation to describe a flonum list ?


maxim_jaffe
2018-7-28 16:58:49

I mean convention?


ben
2018-7-28 16:59:16

what did reduce do for an empty list?


ben
2018-7-28 16:59:25

I just like * for lists


maxim_jaffe
2018-7-28 17:00:06

good question! let me check


maxim_jaffe
2018-7-28 17:00:26

think it returned a null


maxim_jaffe
2018-7-28 17:00:35

or None to be more precise


maxim_jaffe
2018-7-28 17:00:38

but let me check


maxim_jaffe
2018-7-28 17:03:50

It actually gives an error :laughing:


maxim_jaffe
2018-7-28 17:04:21

>>> reduce(lambda x, y: x + y, [1]) 1 >>> reduce(lambda x, y: x + y, [1, 2]) 3 >>> reduce(lambda x, y: x + y, [1, 1]) 2 >>> reduce(lambda x, y: x + y, []) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: reduce() of empty sequence with no initial value


maxim_jaffe
2018-7-28 17:04:54

plus I had to write a lambda (I can import the + operator from somewhere, but to be honest it was quicker to just do the lambda)


maxim_jaffe
2018-7-28 17:05:12

let me try with the operator


maxim_jaffe
2018-7-28 17:06:38

same thing >>> reduce(operator.add, []) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: reduce() of empty sequence with no initial value >>> reduce(operator.add, [1]) 1


maxim_jaffe
2018-7-28 17:07:30

what was even funnier is I was a bit confused I was getting an error to begin with, but then I realised I was already in Racket mode, wrote (reduce ...)


maxim_jaffe
2018-7-28 17:08:16

funny I have only been programming seriously for a few days and I already start feeling comfortable with that syntax


maxim_jaffe
2018-7-28 17:18:13

Seriously, shouldn’t these function just be in the base flonum library :stuck_out_tongue:?


ben
2018-7-28 17:22:28

flsum is in math/flonum. Pull requests for new things would be welcome


maxim_jaffe
2018-7-28 17:25:08

ah what a relief hehe


maxim_jaffe
2018-7-28 17:25:59

but there isn’t a flsqr so maybe I can work in that? Should be straightforward no..?


maxim_jaffe
2018-7-28 17:26:44

fl2sqr


maxim_jaffe
2018-7-28 17:27:43

..?


maxim_jaffe
2018-7-28 17:27:53

why no flsqr


maxim_jaffe
2018-7-28 17:27:57

flsqr/error


maxim_jaffe
2018-7-28 17:30:24

“Compute the same values as (fl+ x y), (fl- x y), (fl* x y), (fl/ x y), (fl* x x), (flsqrt x), (flexp x) and (flexpm1 x), but return the normally rounded-off low-order bits as the second value. The result is an unboxed double-double.” https://docs.racket-lang.org/math/flonum.html?q=flsqr#%28def._%28%28lib._math%2Fflonum..rkt%29._flsqrt%2Ferror%29%29


maxim_jaffe
2018-7-28 17:31:18

Why flsqr/error exists and not flsqr..? Is it a problem? I mean if flexpt exists why not flsqr..?


ben
2018-7-28 17:32:52

I dunno. I guess the original author figured (fl* x x) was fine


ben
2018-7-28 17:33:00

I don’t think there’s a deep reason


maxim_jaffe
2018-7-28 17:36:34

hum.. little bit strange considering there is a regular sqr..! To submit a issue on racket/flonum is that in the main repository?


ben
2018-7-28 17:44:25

yes, but I think a better place is the racket/math repo


maxim_jaffe
2018-7-28 17:45:40

ok :wink:


ben
2018-7-28 17:48:22

oh, for your question about check-equal?, here’s a small program with the same issue:


ben
2018-7-28 17:48:25
#lang typed/racket/base
(require/typed racket/base
  (void (-> Any Void)))
(struct foo ())
(void (foo))

ben
2018-7-28 17:49:17

Typed Racket works hard to protect types, so you can trust they predict how the program’s actually going to run


ben
2018-7-28 17:49:27

and part of that is protecting typed values that flow into untyped code


ben
2018-7-28 17:49:53

usually the type is guide for how to protect things, but when the type is Any Typed Racket just tries its best to add protection


ben
2018-7-28 17:50:23

but it can’t add protection if the value is an opaque struct (and TR doesn’t have an inspector to learn about the struct’s fields and their types)


ben
2018-7-28 17:51:00

so basically, check-equal? errors because its a Racket library using Any types … this really should be fixed somehow


maxim_jaffe
2018-7-28 17:55:25

so let me see if I understood it’s the array struct that is opaque..?


ben
2018-7-28 17:57:22

yes


ben
2018-7-28 17:59:47

and this program doesn’t error: #lang typed/racket/base (require/typed racket/base (void (-> Any Void))) (struct foo () #:transparent) (void (foo))


maxim_jaffe
2018-7-28 18:00:32

ah yes, I remember reading about the #:transparent keyword in one of the guides


maxim_jaffe
2018-7-28 18:01:35

hum ok, so the only way for me to get the test working is to cast it into the type I actually expect from the function I am writing (in this case (Array Integer)) right? I mean it’s not perfect but..!


maxim_jaffe
2018-7-28 18:01:48

or annotate it..?


maxim_jaffe
2018-7-28 18:01:59

no annotate won’t work will it


ben
2018-7-28 18:04:34

(check equal? (array1) (array2)) might wor


maxim_jaffe
2018-7-28 18:05:03

ah ok! way simpler hehe


maxim_jaffe
2018-7-28 18:06:50

by the way think I actually manage to optimize the norm-… functions with the newfound knowledge, hehe. Optimization Coach gives me green lights on all functions


maxim_jaffe
2018-7-28 18:07:51

there is probably a nicer way of doing the last one


ben
2018-7-28 18:10:05

cool (if it was me, I’d replace all the sum (map ....) with folds, but yeah this looks good)


maxim_jaffe
2018-7-28 18:13:29

hum yeah I was thinking about that, but still didn’t get my head around folds totally


ben
2018-7-28 18:14:30

oh and by “fold” I really mean for/fold.


maxim_jaffe
2018-7-28 18:15:39

let me see if I can do it :slightly_smiling_face:


maxim_jaffe
2018-7-28 18:19:40

ah maybe tomorrow hehe… my brain went for a walk I think


maxim_jaffe
2018-7-28 18:36:27

I don’t quite understand why my tests are giving a problem in some other file..! They are obviously problems inmy file… I’ve wrapped my test-suite with a (define tests …) and I am using (run-tests tests). Any ideas..?


maxim_jaffe
2018-7-28 18:46:49

I’ve named the individual tests but still wondering why it does that..?


ben
2018-7-28 18:59:04

I’d need to see the files to help, but my favorite way to do unit tests is with a test submodule: #lang racket/base ;; ... code here (module+ test (require rackunit) (check-equal? 2 2) )


ben
2018-7-28 18:59:22

and running raco test file.rkt does the tests, and otherwise they’re out of the way


maxim_jaffe
2018-7-28 19:00:36

hum ok!


maxim_jaffe
2018-7-28 19:02:58

anyways thanks for all the help @ben :slightly_smiling_face:


maxim_jaffe
2018-7-28 19:03:30

I’ll try and write down the name of everyone that helped for my acknowledgements :slightly_smiling_face:


maxim_jaffe
2018-7-28 19:04:07

here at the racket.slack


ben
2018-7-28 19:05:06

lol it’s all good we’re all trying to help racket succeed


maxim_jaffe
2018-7-28 19:05:15

I really like the language


maxim_jaffe
2018-7-28 19:05:25

after looking at the dozen so languages


maxim_jaffe
2018-7-28 19:05:39

it was the first I felt confident it would work for what I wanted


ben
2018-7-28 19:07:03

awesome thats great to hear


maxim_jaffe
2018-7-28 19:07:04

Haskell, Scala, D, Elixir, Oz (:laughing: ), Julia, Hy (Python) and a bunch of others


ben
2018-7-28 19:07:15

I hope we can fix the awkward/difficult parts


maxim_jaffe
2018-7-28 19:07:18

ah Clojure too!


maxim_jaffe
2018-7-28 19:08:13

That Racket had good base support for plotting, GUI and math (especially arrays/matrix) as well as just plain graphics was really enticing


maxim_jaffe
2018-7-28 19:09:04

couldn’t find a combination of those that worked nicely in most languages beyond Python


maxim_jaffe
2018-7-28 19:09:31

clojure seems like it was okay a bunch of years back but the basic libraries are way to old


maxim_jaffe
2018-7-28 19:09:42

plus JVM ugh.


maxim_jaffe
2018-7-28 19:10:41

only Julia came close, but it’s way to Beta for me


maxim_jaffe
2018-7-28 19:11:33

I mean they’ve been saying they’re going to release a stable version soon for years now


maxim_jaffe
2018-7-28 19:11:51

plus most libraries are in constant flux


ben
2018-7-28 19:17:31

what made the clojure libraries feel old? (so racket can avoid getting old, too)


maxim_jaffe
2018-7-28 20:02:44

maxim_jaffe
2018-7-28 20:02:50

Well I heard a whole talk about how it got old, seems like they’ll come around eventually but for now didn’t seem like a great ecosystem to switch too


maxim_jaffe
2018-7-28 20:03:39

Incanter was the main library a couple of years ago, but it has been worked on for a while now


maxim_jaffe
2018-7-28 20:05:01

My second choices to racket were julia and scala


maxim_jaffe
2018-7-28 20:05:13

Scala seems great for big data science


maxim_jaffe
2018-7-28 20:05:40

But for the kind of thing I’m used to in python didn’t seem to helpful


maxim_jaffe
2018-7-28 20:05:55

Seemed like a steep learning curve


maxim_jaffe
2018-7-28 20:07:44

Plus I don’t really love that everything is based on OO in Scala, even if it has good FP support. I mean it sounds in someways more true to the OO then Python and more scalable because of that


maxim_jaffe
2018-7-28 20:08:31

But I don’t know, the whole Java ecosystem is a bit to strange for me (I would need to interface with a bunch of java libraries to get things done)


maxim_jaffe
2018-7-28 20:09:21

When your used to much of the simplicity of python as an ecosystem, it feels too much


maxim_jaffe
2018-7-28 20:10:33

DrRacket is great in that sense, I just started doing stuff without worrying about setting uo IDEs and for some languages having to get basic syntax highlighting working


maxim_jaffe
2018-7-28 20:11:19

Emacs and vim is just not something I have time to learn now


maxim_jaffe
2018-7-28 20:12:29

I’ve written most of my stuff in python with just gedit and geany+repl when things get a bit more messy (also gave Spyder a try)


maxim_jaffe
2018-7-28 20:13:07

Basically coming from Python, Racket was the first thing that just worked


maxim_jaffe
2018-7-28 20:13:19

Without having to worry too much


maxim_jaffe
2018-7-28 20:13:43

Although I haven’t used the package manager it seems straightforward


maxim_jaffe
2018-7-28 20:14:25

And apart from the ecosystem I liked the language


maxim_jaffe
2018-7-28 20:16:38

I’ve been wanting to learn a lisp language for years now


maxim_jaffe
2018-7-28 20:16:52

Or at least a functional programming language


maxim_jaffe
2018-7-28 20:18:18

Ah you can add OCaml to the list, although I only looked at it very briefly since I couldn’t get the libraries I wanted working


soegaard2
2018-7-28 20:18:44

maxim_jaffe
2018-7-28 20:19:21

Hehe I like the title


maxim_jaffe
2018-7-28 20:20:12

And nice graphs!


maxim_jaffe
2018-7-28 20:20:58

Thanks @soegaard2 when I’m at the computer I’ll look at it


soegaard2
2018-7-28 20:21:10

Oh btw. The function flsum adds the numbers in an order that improves accuracy.


maxim_jaffe
2018-7-28 20:21:22

Ah nice!


maxim_jaffe
2018-7-28 20:21:55

It’s working well for me in those little functions I wrote


soegaard2
2018-7-28 20:26:50

@maxim_jaffe btw - Neil wrote plot, so don’t be surprised the article has nice graphs :slightly_smiling_face:


maxim_jaffe
2018-7-28 20:27:53

“Test for nearness instead of equality”. By the way for testing floating-point finction with check-= what is a reasonable epsilon


soegaard2
2018-7-28 20:29:19

depends


soegaard2
2018-7-28 20:30:38

Often you can try something small. Other times you needs to be more cautious.


maxim_jaffe
2018-7-28 20:33:53

Something like the error in the range of what you get when you do(* 3 1.0/3.0) (if I remember right that gives a really small error right?)


maxim_jaffe
2018-7-28 20:34:08

Or is that to rigid?


soegaard2
2018-7-28 20:34:53

Depends! But read the article. Neil shows how to debug floating point calculations.


maxim_jaffe
2018-7-28 20:35:05

Hum ok!


maxim_jaffe
2018-7-28 20:35:09

Will do


maxim_jaffe
2018-7-28 20:35:16

:slightly_smiling_face:


maxim_jaffe
2018-7-28 20:38:29

By the way a channel just for typed racket could be useful no? Especially for questions on getting correct typing definitions and such


maxim_jaffe
2018-7-28 20:38:47

Who’s interested?


maxim_jaffe
2018-7-28 20:41:25

You should see the julia slack there is so many channels hehe


maxim_jaffe
2018-7-28 20:42:36

Practically one for each core/popular library


samth
2018-7-28 20:43:27

there are many fewer of us, so mostly people just use this channel


maxim_jaffe
2018-7-28 20:44:00

Yeah understandable


maxim_jaffe
2018-7-28 20:44:51

But at the same time might help keep annoying people like me contained :joy:


soegaard2
2018-7-28 20:46:40

I like a little life here. It only makes sense to make new channels when there are too much activity (and it becomes confusing to follow a discussion).


maxim_jaffe
2018-7-28 20:46:51

Plus at julia usually the core developers/maintainers/fans of a library kept a close eye in the related channel


maxim_jaffe
2018-7-28 20:47:04

Hehe sure


maxim_jaffe
2018-7-28 20:47:11

I know what you mean


maxim_jaffe
2018-7-28 20:48:08

Your probably right, but still hehe


maxim_jaffe
2018-7-28 20:50:31

Julia has about 1300 people in their #general to give you an idea


maxim_jaffe
2018-7-28 20:52:19

And about 100–200 in the most popular library channels


maxim_jaffe
2018-7-28 20:56:31

On a completely different note


maxim_jaffe
2018-7-28 20:57:27

Does anyone know users / developers from Brazil


maxim_jaffe
2018-7-28 20:57:36

Or Portugal for the matter


maxim_jaffe
2018-7-28 20:57:54

I used to run a small computer school


maxim_jaffe
2018-7-28 20:58:16

Back there and think the kids would have really liked racket / 2htdp


maxim_jaffe
2018-7-28 20:58:46

When I go back might give it a try


maxim_jaffe
2018-7-28 20:58:57

As a social project


maxim_jaffe
2018-7-28 21:00:15

Think the ability to make little games or videos would be popular


ben
2018-7-28 21:00:52

(I think there are some people from Brazil on the mailing list)


maxim_jaffe
2018-7-28 21:01:04

Cool!


soegaard2
2018-7-28 21:01:29

Wasn’t there a spanish mailing list at some point?


maxim_jaffe
2018-7-28 21:01:33

Probably not where I lived though hehe


maxim_jaffe
2018-7-28 21:01:50

State of Piauí


maxim_jaffe
2018-7-28 21:02:12

Almost in the middle of nowhere


maxim_jaffe
2018-7-28 21:02:50

Computer literacy is really low there


maxim_jaffe
2018-7-28 21:02:55

Where I lived


maxim_jaffe
2018-7-28 21:03:32

More likely for kids to have access to smartphones and tablets then computers


maxim_jaffe
2018-7-28 21:04:46

By the way is there any project on getting a racket working on android and a REPL to play around with


maxim_jaffe
2018-7-28 21:07:52

I heard in the racket manifesto talk of matthias that there was work on the ARM processor




maxim_jaffe
2018-7-28 21:09:24

Hehe just found the same github


maxim_jaffe
2018-7-28 21:11:49

But that’s for deploying apps right?


zenspider
2018-7-28 23:22:08

I’m guessing this is a bug in 7.0?

raco setup: error: during making for <pkgs>/oedipuslex
raco setup:   Users/ryan/Work/git/zenspider/schemers/oedipuslex/test.rkt:23:14: read-syntax: end-of-file following `\|` in symbol
raco setup:     compiling: <pkgs>/oedipuslex/test.rkt

namely, that the path reported is missing the leading / (cc @mflatt)

Possibly also that this used to work in 6.x… but I don’t know if things have been made stricter and now it is a legit failure or if it should have worked in 7. That’s separate at this point.


zenspider
2018-7-28 23:23:59

(these were produced via migrating packages inside of drracket, if that matters)


zenspider
2018-7-28 23:31:55

Looks like the package manager is already reporting an error on metapict… how was it compiling before?


notjack
2018-7-28 23:34:03

“oedipuslex” :+1:


notjack
2018-7-28 23:34:29

some top-tier naming right there


zenspider
2018-7-28 23:35:09

:stuck_out_tongue: