[racket-users] Re: Gui editable grid/table

2019-07-19 Thread Travis Hinkelman
Hi Raoul,

Matthias Felleisen is working on a Racket implementation of the 7GUIs 
project, which includes a simple spreadsheet as one of the tasks.

https://github.com/mfelleisen/7GUI

Perhaps that will suit your needs.

Best,

Travis


On Friday, July 19, 2019 at 8:17:58 PM UTC-7, Raoul Schorer wrote:
>
> Hi,
>
> I am trying to make a gui editable table. Is that possible in racket/gui?
>
> It seems list-box% is not editable by default. Apparently, one can't stick 
> editors as list-box% choices either.
>
> Can you please help?
>
> Thanks!
> Raoul
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0eff2c7c-e9c3-458a-a433-137656df7b6b%40googlegroups.com.


[racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-07-14 Thread Travis Hinkelman

>
> (Indeed, the first thing I thought 
>  when I heard that this might happen was, did I make a mistake in 
>  shifting my work to Racket?  It is unlikely I would have come to 
>  Racket if there wasn't an equivalent amount of elegance.) 
>

I want to briefly echo this sentiment. I've been casually learning Racket 
for several months (and greatly enjoying it), which was preceded by several 
months of reading and thinking about which programming language to learn 
next (my background is as a biologist that uses R and NetLogo). When I was 
listening to the livestream this morning, I had a moment of panic that 
maybe I had made the wrong choice to learn Racket. Or maybe I jumped on the 
Racket train at the wrong time.

Thanks,

Travis 


On Sunday, July 14, 2019 at 10:44:30 AM UTC-7, cwebber wrote:
>
> The context of this email is the proposal by Matthew Flatt that we move 
> to an easier-to-accept surface syntax for #lang racket2. 
>
> Matthew Flatt has heard more than enough from me of concern about this 
> proposal.  But I should indicate that I'm highly sympathetic to the 
> goal.  I would like to lay out the following observations: 
>
>  - The challenge with s-expressions is largely in anxiety with something 
>that looks extremely alien.  I suspect there's more fear from 
>instructors than students in encountering a lisp syntax; my 
>experience is that introducing someone who doesn't know differently 
>to a parenthetical syntax isn't scary for them, and they tend to like 
>it.  But people who have *started out* with experience in a non-lispy 
>language tend to find it scary. 
>
>  - Nonetheless, assumptions that various math operators should be infix 
>is understandable because that's what people see today. 
>
>  - I am indeed very for growth in the community, though my main interest 
>in growth is in seeing a wider diversity of participants than just 
>raw numbers.  Obviously other peoples' mileage may vary. 
>
>  - We are at serious risk in this pivot of losing some key things: 
>
>- Many communities I have been in that have undertaken such a large 
>  pivot to increase popularity expend enormous energy in the move to 
>  the new thing, and in that process, the project actually collapses. 
>  What I'm trying to say is that a pivot is a gamble; we should 
>  calculate our odds carefully.  (Indeed, the first thing I thought 
>  when I heard that this might happen was, did I make a mistake in 
>  shifting my work to Racket?  It is unlikely I would have come to 
>  Racket if there wasn't an equivalent amount of elegance.) 
>
>- I'm not sure if I could have understood Racket Week with a syntax 
>  that didn't have the elegance of s-expressions.  This is not to say 
>  that *no* syntax can have that level of elegance where things can 
>  be so clear, however. 
>
> IIRC Matthew's proposal for "#lang racket2" was something like the 
> following: 
>
>  a) function(args ...) should work. 
>  b) infix is necessary for math, such as 3 + 4 
>  c) parentheses should be possible for grouping 
>
> The weird thing about the last one being that this is already kind of 
> true in s-expressions, but by ~default this also results in application. 
>
> Let me add one more suggested design goal: 
>
>  - the new syntax should must not be significantly less elegant than 
>s-expressions. 
>
> Is there a way to achieve this?  I actually think the best path forward 
> is to have a surface syntax that actually maps completely to 
> s-expressions, which is in fact universal that it can work with *any* 
> s-expression syntax. 
>
> I would suggest starting with Wisp as the basis for examining this: 
>
>   https://dustycloud.org/blog/wisp-lisp-alternative/ 
>   https://srfi.schemers.org/srfi-119/srfi-119.html 
>
> Sweet-expressions may also be an alternative to explore.  However, I 
> think Wisp is a more elegant base; it can transform *any* wisp code into 
> s-exp code.  Not discussed in my blogpost about Wisp is that it also 
> supports infix via {3 + 4}.  So ok, now we have that.  And we can still 
> group: 
>
>   {3 + {8 + 4}} 
>
> So that's points b) and c), but we don't have a) yet.  Could we add it? 
>
> I think we can extend wisp with one thing and get everything we want: if 
> you have func(arg1 arg2 arg3) where the parenthesis comes *immediately* 
> after the symbol, that is rewritten to (func arg1 arg2 arg3).  I will 
> call this version ~Wisp. 
>
> With all this, observe the following code rewritten from Scheme to ~Wisp: 
>
>   (define (rgb-maker mk) 
> (lambda (sz) 
>   (vc-append (colorize (mk sz) "red") 
>  (colorize (mk sz) "green") 
>  (colorize (mk sz) "blue" 
>
>   define rgb-maker(mk) 
> lambda(sz) 
>   vc-append(colorize(mk(sz) "red") 
> colorize(mk(sz) "green") 
> colorize(mk(sz) "blue")) 
>
> Here is another chunk of code, taken 

Re: [racket-users] returning GUI elements in function?

2019-07-09 Thread Travis Hinkelman
It's funny how just knowing that there is an easy solution to a problem 
makes the problem easier to solve. My first thought about returning objects 
(prior to sending initial email) was that I would return all of the objects 
unnamed but then I was confused about how to specify the parents of the 
child objects in the `initialize-progress-bar` function. The code below 
solves my problem. As always, I welcome people sharing alternative ways to 
write the same code. 

#lang racket/gui

(define (initialize-progress-bar)
  (define frame (new frame%
 [label "Progress Bar"]
 [width 300]))

  (define hpane (new horizontal-pane%
 [parent frame]))

  (define gauge (new gauge%
 [label ""]
 [parent hpane]
 [range 100]))

  (define msg (new message%
   [parent hpane]
   [auto-resize #t]
   [label "0%"]))

  (send frame show #t)
  (values gauge msg))

(define (update-progress-bar new-value)
  (send the-gauge set-value new-value)
  (send the-msg set-label (string-append (~a new-value) "%")))

(define-values (the-gauge the-msg) (initialize-progress-bar))
(for ([i (in-range 1 101)])
  (sleep 0.05)
  (update-progress-bar i))




On Tuesday, July 9, 2019 at 1:05:03 AM UTC-7, Laurent wrote:
>
> There are several ways to solve this (including deriving classes), but the 
> simplest for you right now is probably to have `initialize-progress-bar' 
> return the gui widgets (in particular `gauge' and `msg'), assign the values 
> to `the-gauge' and `the-msg' (say) from the return values of 
> `(initialize-progress-bar)` call, and then pass these values to 
> `update-progress-bar' so that `gauge' and `msg' have the correct values 
> there.
>
> Does that make sense?
>
> On Tue, Jul 9, 2019 at 7:23 AM Travis Hinkelman  > wrote:
>
>> Hi All,
>>
>> I was playing around with creating a progress bar. The basic idea was 
>> straightforward.
>>
>> #lang racket/gui
>>
>> (define frame (new frame%
>>[label "Progress Bar"]
>>[width 300]))
>>
>> (define hpane (new horizontal-pane%
>>[parent frame]))
>>
>> (define gauge (new gauge%
>>[label ""]
>>[parent hpane]
>>[range 100]))
>>
>> (define msg (new message%
>>  [parent hpane]
>>  [auto-resize #t]
>>  [label "0%"]))
>>
>> (send frame show #t)
>>
>> (for ([i (in-range 1 101)])
>>   (sleep 0.05)
>>   (send gauge set-value i)
>>   (send msg set-label (string-append (~a i) "%")))
>>
>>
>> When I tried to take the next step of wrapping this up into a couple of 
>> functions, I was completely lost. I don't know how to initialize a frame 
>> with child elements by calling a function because all of the elements of 
>> the frame only exist in the function and not at the top-level (probably 
>> butchering the jargon here; hopefully it makes sense). I wasn't really sure 
>> where to look to learn more about doing such a thing. Here is some 
>> pseudocode to try to further illustrate my confusion.
>>
>> (define (initialize-progress-bar)
>>   ;; insert code that creates progress bar
>>   ;; i.e., from defining frame to sending frame in code above)
>>
>> (define (update-progress-bar new-value)
>>   (send gauge set-value new-value)
>>   (send msg set-label (string-append (~a new-value) "%")))
>>
>> (initialize-progress-bar)
>> (for ([i (in-range 1 101)])
>>   (sleep 0.05)
>>   (update-progress-bar i))
>>
>> Thanks,
>>
>> Travis
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/61a3ea75-d285-45d1-90d4-de569c441c8d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/61a3ea75-d285-45d1-90d4-de569c441c8d%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/7adee791-e04e-44b8-8f27-881298865d48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] returning GUI elements in function?

2019-07-09 Thread Travis Hinkelman
Hi All,

I was playing around with creating a progress bar. The basic idea was 
straightforward.

#lang racket/gui

(define frame (new frame%
   [label "Progress Bar"]
   [width 300]))

(define hpane (new horizontal-pane%
   [parent frame]))

(define gauge (new gauge%
   [label ""]
   [parent hpane]
   [range 100]))

(define msg (new message%
 [parent hpane]
 [auto-resize #t]
 [label "0%"]))

(send frame show #t)

(for ([i (in-range 1 101)])
  (sleep 0.05)
  (send gauge set-value i)
  (send msg set-label (string-append (~a i) "%")))


When I tried to take the next step of wrapping this up into a couple of 
functions, I was completely lost. I don't know how to initialize a frame 
with child elements by calling a function because all of the elements of 
the frame only exist in the function and not at the top-level (probably 
butchering the jargon here; hopefully it makes sense). I wasn't really sure 
where to look to learn more about doing such a thing. Here is some 
pseudocode to try to further illustrate my confusion.

(define (initialize-progress-bar)
  ;; insert code that creates progress bar
  ;; i.e., from defining frame to sending frame in code above)

(define (update-progress-bar new-value)
  (send gauge set-value new-value)
  (send msg set-label (string-append (~a new-value) "%")))

(initialize-progress-bar)
(for ([i (in-range 1 101)])
  (sleep 0.05)
  (update-progress-bar i))

Thanks,

Travis

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/61a3ea75-d285-45d1-90d4-de569c441c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] redundancy in GUI callback functions

2019-05-26 Thread Travis Hinkelman
Ah, well, that was more straightforward than I expected. I was lazy with my 
Saturday-night learning session and didn't push very hard to solve it on my 
own. Thank you for taking the time to help. I also appreciate that you 
caught those bugs and improved the code style. Thanks again.


On Saturday, May 25, 2019 at 8:19:23 PM UTC-7, Sorawee Porncharoenwase 
wrote:
>
> Just abstract the common part out? E.g.,
>
> (define (update-text-field read-field write-field converter)
>   (define text (send read-field get-value))
>   (cond
> [(string=? text "")
>  (send read-field set-field-background (make-object color% 255 255 255 1))
>  (send write-field set-value "")]
> [(number? (string->number text))
>  (send read-field set-field-background (make-object color% 255 255 255 1))
>  (send write-field set-value (converter (string->number text)))]
> [else
>  (send read-field set-field-background (make-object color% 255 0 0 1))
>  (send write-field set-value "")]))
>
> (define (update-fahrenheit control event)
>   (update-text-field text-celsius text-fahrenheit convert-c))
>
> (define (update-celsius control event)
>   (update-text-field text-fahrenheit text-celsius convert-f))
>
> Note that your original code has a bug: you always use convert-c in both 
> directions. Obviously, in update-celsius you want to use convert-f.
>
> There’s also another subtle bug that I didn’t fix. Suppose you type an 
> invalid character (like “a”) to the left text field. This will make the 
> field become red. Now, switch to the right field and type “32”. The left 
> field will output “0” while being red, though it probably should now be 
> white.
>
> On Sat, May 25, 2019 at 7:57 PM Travis Hinkelman  > wrote:
>
>> Hi All,
>>
>> I'm working through the tasks in 7guis 
>> <https://eugenkiss.github.io/7guis/tasks> to learn about GUI programming 
>> in Racket. My code 
>> <https://gist.github.com/hinkelman/e35d4abf3203277c4428bcd6abad8183> for 
>> the temperature converter task works as expected but there is a lot of 
>> redundancy in my update-fahrenheit and update-celsius callback functions. I 
>> would appreciate feedback on how to make this code less redundant.
>>
>> Thanks,
>>
>> Travis
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/8f97260c-62be-4a6f-9459-244a88632ef9%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/8f97260c-62be-4a6f-9459-244a88632ef9%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f730a304-2edc-4257-a0ed-0c66f417ee19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] redundancy in GUI callback functions

2019-05-25 Thread Travis Hinkelman
Hi All,

I'm working through the tasks in 7guis 
 to learn about GUI programming in 
Racket. My code 
 for 
the temperature converter task works as expected but there is a lot of 
redundancy in my update-fahrenheit and update-celsius callback functions. I 
would appreciate feedback on how to make this code less redundant.

Thanks,

Travis

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8f97260c-62be-4a6f-9459-244a88632ef9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] recursive function with multiple arguments

2019-04-10 Thread travis . hinkelman
Hi All,

I'm trying to better understand recursion. I decided to rewrite the logmodr 
function from this blog post 
 as 
a recursive function. I was easily able to write the recursive functions if 
all but one of the arguments were set to default values. But I was 
completely stumped by how to handle the situation without using default 
argument values. After a considerable amount of flailing about, I finally 
realized that I could accomplish this task by passing the arguments as a 
struct (see code below). I find the struct approach relatively intuitive 
but it strikes me as quite verbose. Are there other (better?) ways to 
handle this task?

Thanks,

Travis


#lang racket

(require math)

(struct args (y r k thetasd) #:transparent) ; only 'y' changes in 
project-pop function below

(define (logmod args-struct)
  (define theta (flvector-ref (flnormal-sample 0.0 (args-thetasd 
args-struct) 1) 0))
  (args (* (args-y args-struct) (* (- (args-r args-struct) (* (args-r 
args-struct) (/ (args-y args-struct) (args-k args-struct (exp theta)))
(args-r args-struct)
(args-k args-struct)
(args-thetasd args-struct)))

(define (project-pop args-struct t [i 1])
  (define y (args-y args-struct))
  (if (= i t)
  (list y)
  (cons y (project-pop (logmod args-struct) t (+ i 1)
  
(project-pop (args 1.0 1.8 20.0 0.1) 25)


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Pretty display of tabular data?

2019-03-22 Thread travis . hinkelman
I just came across a post  on 
tabular data structures in R, Python, and SQL. The post is written has a 
friendly intro to the subject, which the author claims is a gap that needs 
filling. Thus, the post might not contain much information that is new to 
this group. Perhaps the opportunity is for the Racket community to use that 
friendly intro as a springboard to a comparison for how to approach tabular 
data in Racket.



On Saturday, March 16, 2019 at 3:54:51 PM UTC-7, jackh...@gmail.com wrote:
>
> Hooray! Now we're up to 7 tagged packages 
>  (that was fast!)
>
> On Saturday, March 16, 2019 at 12:13:38 PM UTC-7, johnbclements wrote:
>>
>> Yep, excellent idea. I’ve added the ’tabular’ tag to csv-writing. 
>>
>> John 
>>
>> > On Mar 15, 2019, at 3:24 AM, jackh...@gmail.com wrote: 
>> > 
>> > I think we should all work towards making our existing code in this 
>> area more discoverable, so we can get a better sense of what libraries for 
>> working with tables exist in the wild. To those of you who own Racket 
>> packages that provide any functionality related to data tables: I recommend 
>> adding the "tabular" tag to your package's description in the package 
>> catalog. There's no need to remove more-specific tags (like "data-frame") 
>> from your package, but even if you have a more specific tag please include 
>> the general "tabular" tag so it's easy to search for your package. So far 
>> there's only 3 packages tagged with "tabular" (and one of those is a 
>> package of mine that I just tagged while writing this post). I see several 
>> packages that are good candidates for the tag: 
>> > • data-frame 
>> > • sqlite-table 
>> > • table-panel 
>> > • tabular 
>> > • rml-core (maybe?) 
>> > • sinbad 
>> > • spmatrix (maybe?) 
>> > • spreadsheet-editor 
>> > • csv 
>> > • csv-reading 
>> > • csv-writing 
>> > • simple-csv 
>> > • Most things with the "sql" tag 
>> > The more packages we have tagged and documented, the easier it will be 
>> to find real code using tables in the wild. Which is information we'll need 
>> if we want to understand how a standard `racket/table` API might look. 
>> > 
>> > On Thursday, March 14, 2019 at 10:28:41 AM UTC-7, Ryan Kramer wrote: 
>> > On Thursday, March 14, 2019 at 12:26:39 AM UTC-5, Alex Harsanyi wrote: 
>> > 
>> > There are now several projects announced on this list, all of them deal 
>> with 
>> > data analysis on one way or the other.  Would it be possible to join 
>> forces 
>> > and merge these projects so that we end up with one library that 
>> servers 
>> > multiple purposes equally well?  Something where the final product is 
>> greater 
>> > than the sum of its parts... 
>> > 
>> > Or perhaps these libraries have aims that are so different from each 
>> other 
>> > that the only thing they share is a very abstract concept of "table"? 
>> > 
>> > I think my project "plisqin" is one of those you are thinking of. 
>> Matt's "tbl" is also one. I'm also keeping an eye on Ryan's "sql". Are 
>> there any more you were thinking of? 
>> > 
>> > Regarding joining forces/merging these projects, this is a good 
>> question that I think warrants discussion. So I'll share my thoughts. 
>> > 
>> > Obviously I can't speak for all of us, but right not I only see the 
>> "very abstract concept of "table"" as potential shared code. (Also, 
>> learning about snip% earlier in this thread was awesome. I'd love to use 
>> something like that in my project.) 
>> > 
>> > I think the differences between plisqin and tbl are fairly obvious - 
>> plisqin is an alternative to SQL while tbl is an alternative to 
>> "Python/NumPy/SciPy, or R/Tidyverse (or, horrors, plain R)" 
>> > 
>> > Now comparing Ryan's sql to plisqin is a different story. These 
>> projects are both alternatives to SQL. But I think there is enough 
>> difference between our approaches and scope to warrant separate projects, 
>> at least for now. 
>> > 1) sql seems to be mostly implemented as macros. plisqin is mostly 
>> implemented as procedures. 
>> > 2) plisqin has some design decisions that some might consider "too much 
>> magic", namely inline joins and "inject-able aggregates" (need better name) 
>> as documented here: https://docs.racket-lang.org/plisqin/intro.html. 
>> Whereas sql-the-package seems to more closely mirror SQL-the-language - it 
>> would be difficult to surprise yourself with the SQL you generate. 
>> > 3) I am trying to design #lang plisqin so that people with no Lisp 
>> experience can use it. (Whether I will succeed is another matter...) 
>> > 
>> > I apologize to Ryan C if I have mischaracterized sql. I'd like to have 
>> a longer conversation about this, but maybe this list is not the right 
>> place. (Also, Ryan, if you think our goals are more similar than I do, I'd 
>> be 

Re: [racket-users] Use cases for tables and records

2019-02-22 Thread travis . hinkelman
The data-science package isn't focused on the table (or data frame) 
structure (it uses lists of lists) but it includes tooling that is useful 
for working with data stored in that type of structure such as "split -> 
apply -> combine", column indexing, subsetting, grouping, and aggregating.

https://github.com/n3mo/data-science

In particular, I find the documentation for that package very approachable 
for people coming from R/Matlab.



On Friday, February 22, 2019 at 5:47:33 AM UTC-8, Sam Tobin-Hochstadt wrote:
>
> Bitbucket should work fine with the package system -- just provide the 
> URL for the git repository as the source and everything should be good 
> to go. 
>
> Sam 
>
> On Fri, Feb 22, 2019 at 8:14 AM Matt Jadud > 
> wrote: 
> > 
> > On Thu, Feb 21, 2019 at 2:59 PM > 
> wrote: 
> >> 
> >> 
> >> - Tables, which are like a list of records that all have the same 
> keywords. Tables are similar to dataframes and are intended to make it easy 
> to process spreadsheet-like data such as CSV files. Example: 
> >> 
> > 
> > Everyone must be thinking the same things these past few months... 
> > 
> > https://bitbucket.org/jadudm/data-table 
> > 
> > I have been looking at Pyret's interface to tables, as well as the 
> data-frame package in the Racket pkg collection, and R's interface to 
> dataframes. My goal is something that is syntactically/conceptually simple 
> for students to use for EDA, and potentially scales well to more 
> interesting questions involving data. In the fall, I'll be doing work with 
> students around environmental sensing as part of their coursework, and I 
> want something for working with data that fits into the HtDP approach to 
> introducing students to thinking about designing programs. 
> > 
> > Right now, I'm still exploring, and haven't made significant progress on 
> documentation, largely because I've just lifted the library to a point that 
> I can start using it myself for some experimentation with data in a project 
> of my own. This has illustrated some things that are missing, are not as 
> clean as they could be, etc., so I'm going to circle around again on the 
> library as I explore. My thinking is that if I can simplify the interfaces 
> and operations on a project with a heavy data lift, I might be heading in 
> the right direction for small data projects as well. 
> > 
> > At the moment, I can import public spreadsheets from Google, slurp in 
> MySQL tables, SQLite tables, and CSV files. Although proprietary, I'll 
> probably add support for Airtable as an input as well, and will eventually 
> look at some of the MQTT dashboards for IoT (eg. io.adafruit.com). I have 
> not tested the living daylights out of the library, but nascent tests are 
> proceeding with development to watch for regressions as I explore. I can 
> insert, select, and sieve (filter) from tables, as I like the nomenclature 
> that Pyret uses for tables; I'm borrowing their ideas for the interface to 
> table operations for now. 
> > 
> > I like the interface you've proposed for quickly specifying columns 
> (although the rationale for keywords is unclear to me), but I'd personally 
> have to think about the role of types on those columns. I like Pyret's 
> sanitizers, which provide cleanliness guarantees that the user can specify, 
> thus protecting the programmer from ill-formatted data in the table. 
> > 
> > I suppose data-table is a usable library at this point, but it's highly 
> fragile while I'm working on it. However, I'm happy to push to Github as 
> well as Bitbucket (which apparently does not play well with the package 
> distribution system?), so that it can be poked at by others. 
> > 
> > Cheers, 
> > Matt 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Racket Users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to racket-users...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "table" data structure in Racket

2019-02-21 Thread travis . hinkelman
After posing the question yesterday, I spent a little time poking around in 
the Github repository for Apache Arrow and came to the same conclusion, 
i.e., large project presumably facilitated by corporate backing.


On Thursday, February 21, 2019 at 4:28:55 PM UTC-8, Alex Harsanyi wrote:
>
>
>
> On Thursday, February 21, 2019 at 7:19:39 AM UTC+8, travis.h...@gmail.com 
> wrote:
>>
>> Hi All,
>>
>> I'm resurrecting this thread to ask if anyone in the Racket community has 
>> Apache Arrow on their radar. It seems like Apache Arrow might be gaining 
>> steam.
>>
>
>> Apache Arrow is a cross-language development platform for in-memory data. 
>>> It specifies a standardized language-independent columnar memory format for 
>>> flat and hierarchical data, organized for efficient analytic operations on 
>>> modern hardware. It also provides computational libraries and zero-copy 
>>> streaming messaging and interprocess communication. Languages currently 
>>> supported include C, C++, C#, Go, Java, JavaScript, MATLAB, Python, R, 
>>> Ruby, and Rust. [Source 
>>> 
>>> ]
>>
>>
>> I have no clue what it would take to make Racket a supported language. I 
>> also don't have a sense of what kind of demand the Racket community has for 
>> this sort of thing. Just curious if anyone is thinking about a Racket and 
>> Apache Arrow pairing.
>>
>>
> I had looked at Apache Arrow when it was first mentioned in this thread, 
> but the project is large and providing bindings seemed like a large task -- 
> the Java, Rust, JavaScript and Python bindings are large projects by 
> themselves.  I suspect Apache Arrow (along with numpy and other scientific 
> / data-processing packages) are backed by several large companies who 
> provide the development resources.
>
> Providing usable Racket bindings for Apache Arrow is not something one can 
> do as a hobby in a few weekends.  I ended up writing my own data frame 
> package, which is smaller, simpler and has the features and performance 
> levels that I need.
>
> Alex. 
>  
>
>> Thanks,
>>
>> Travis 
>>
>> On Wednesday, April 6, 2016 at 1:27:56 AM UTC-7, Konrad Hinsen wrote:
>>>
>>> On 05/04/2016 21:12, Asumu Takikawa wrote: 
>>>
>>> > I haven't built anything like that, but I was hoping that we could get 
>>> a GSoC 
>>> > student for it (that didn't pan out though obviously). The idea was to 
>>> use 
>>> > packages from Python/Julia/R as inspiration: 
>>> > 
>>> >http://pandas.pydata.org/pandas-docs/stable/index.html 
>>> >http://dataframesjl.readthedocs.org/en/latest/ 
>>> >https://github.com/Rdatatable/data.table/wiki 
>>>
>>> Also consider this one: 
>>>
>>> https://arrow.apache.org/ 
>>>
>>> Konrad. 
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "table" data structure in Racket

2019-02-20 Thread travis . hinkelman
Hi All,

I'm resurrecting this thread to ask if anyone in the Racket community has 
Apache Arrow on their radar. It seems like Apache Arrow might be gaining 
steam.

Apache Arrow is a cross-language development platform for in-memory data. 
> It specifies a standardized language-independent columnar memory format for 
> flat and hierarchical data, organized for efficient analytic operations on 
> modern hardware. It also provides computational libraries and zero-copy 
> streaming messaging and interprocess communication. Languages currently 
> supported include C, C++, C#, Go, Java, JavaScript, MATLAB, Python, R, 
> Ruby, and Rust. [Source 
> 
> ]


I have no clue what it would take to make Racket a supported language. I 
also don't have a sense of what kind of demand the Racket community has for 
this sort of thing. Just curious if anyone is thinking about a Racket and 
Apache Arrow pairing.

Thanks,

Travis 

On Wednesday, April 6, 2016 at 1:27:56 AM UTC-7, Konrad Hinsen wrote:
>
> On 05/04/2016 21:12, Asumu Takikawa wrote: 
>
> > I haven't built anything like that, but I was hoping that we could get a 
> GSoC 
> > student for it (that didn't pan out though obviously). The idea was to 
> use 
> > packages from Python/Julia/R as inspiration: 
> > 
> >http://pandas.pydata.org/pandas-docs/stable/index.html 
> >http://dataframesjl.readthedocs.org/en/latest/ 
> >https://github.com/Rdatatable/data.table/wiki 
>
> Also consider this one: 
>
> https://arrow.apache.org/ 
>
> Konrad. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Communicating the purpose of Racket (was: hackernews)

2019-02-15 Thread travis . hinkelman
I will throw out the Julia homepage (https://www.julialang.org) as a good 
example of language marketing. Perhaps, though, I find the marketing 
effective because it is largely targeted at people like me.



On Tuesday, February 12, 2019 at 1:18:26 PM UTC-8, Nadeem Abdul Hamid wrote:
>
> Maybe the mouse-over reveals of each of the 6 blocks on the page should be 
> on a timed animation so they reveal the text detail one by one, independent 
> of the mouse hovering over them? That would provide a gallery-like effect 
> that reveals the prose behind the images.
>
>
> On Tue, Feb 12, 2019 at 3:11 PM Sorawee Porncharoenwase <
> sorawe...@gmail.com > wrote:
>
>> Here's my impression of the homepage.
>>
>> [image: Screen Shot 2019-02-12 at 11.33.27.png]
>>
>> This is some abstract arts. I don't know what to make out of it.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: nested for loops and suggested alternatives

2019-02-10 Thread travis . hinkelman
For the benefit of other beginners, I think there was a small typo in 
prop-projection.v1 where the intention was to call that function 
recursively rather than calling pop-projection in the body of 
pop-projection.v1. The typo is corrected below:

(define (pop-projection.v1 A n iter)
  (if (zero? iter)
  (list n)
  (cons n (pop-projection.v1 A (matrix* A n) (- iter 1)

Thanks to everyone for the feedback. It has been very illuminating!



On Sunday, February 10, 2019 at 5:49:01 PM UTC-8, Matthias Felleisen wrote:
>
>
>
> On Feb 10, 2019, at 7:26 PM, Alex Harsanyi  > wrote:
>
> One way to do this is for `pop-abundances` to have an extra parameter, the 
> list of previous abundances, and whenever the function is called 
> recursively, it adds the current abundance to this list and passes it on to 
> the next call.  The final call will than return this result instead of the 
> last abundance.  In the example below, "cons" adds to the front of the 
> list, so "result" contains the most recent values first and  this list is 
> reversed before being returned to the user.  Also, when `pop-abundances` is 
> invoked by the user, there are no "previous abundances" , so it needs to be 
> invoked with an empty list -- this is handled by a default parameter for 
> 'result':
>
> #lang racket
> (require math/matrix)
>
> (define A (matrix [[0 0 5.905]
>[0.368 0.639 0.025]
>[0.001 0.152 0.051]]))
>
> (define n (col-matrix [5 5 5]))
>
> (define (pop-projection A n iter [result '()])
>   (if (zero? iter)
>   (reverse (cons n result))
>   (pop-projection A (matrix* A n) (- iter 1) (cons n result
>
> (pop-projection A n 25)
>
>
>
>
> Don’t use accumulators if the function has all the information: 
>
> #lang racket
>
> (require math/matrix)
>
> (define A
>   (matrix
>[[0 0 5.905]
> [0.368 0.639 0.025]
> [0.001 0.152 0.051]]))
>
> (define n (col-matrix [5 5 5]))
>
> (define (pop-projection A n iter [result '()])
>   (if (zero? iter)
>   (reverse (cons n result))
>   (pop-projection A (matrix* A n) (- iter 1) (cons n result
>
> (define (pop-projection.v1 A n iter)
>   (if (zero? iter)
>   (list n)
>   (cons n (pop-projection A (matrix* A n) (- iter 1)
>
> (equal? (pop-projection A n 25) (pop-projection.v1 A n 25))
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: nested for loops and suggested alternatives

2019-02-10 Thread travis . hinkelman
Thanks, Daniel, this is helpful. I think that I understand your code, but 
it is a still a foreign way of thinking for me. Of course, that is a big 
part of why I'm learning Racket, i.e., to make programming with lists and 
recursion more natural. One key gap for me is how to build up data 
structures using lists and recursion. Perhaps the answer is that you don't 
build up the data structure in memory but by writing to disk. In this 
particular example, it is useful to have the values at every iteration for 
plotting the population trajectory (by age class or summed across age 
classes). 

Below is a little example I was exploring that involves matrix 
multiplication (col-matrix is abundance in different age classes; square 
matrix is transition probabilities among age classes). It was obvious to me 
how to use recursion to get the final col-matrix of abundances but not how 
to build up a data structure that included the abundances at every 
iteration.

(require math/matrix)

(define A (matrix [[0 0 5.905]
   [0.368 0.639 0.025]
   [0.001 0.152 0.051]]))

(define n (col-matrix [5 5 5]))

(define (pop-projection A n iter)
  (if (zero? iter) n
  (pop-projection A (matrix* A n) (- iter 1

(pop-projection A n 25)



On Sunday, February 10, 2019 at 3:56:25 AM UTC-8, Daniel Prager wrote:
>
> Thanks for the screenshot Travis.
>
> Just for fun, here's a version in Racket that eschews assignment, vectors 
> and for loops, in favour of recursion and lists ...
>
> #lang racket
>
> (define years 30)
> (define prop-female 0.5)
> (define egg-surv 0.6)
>
> (define fecundity '(0 0 200 400 800))
> (define survival '(0.2 0.4 0.6 0.8 0))
> (define capacity '(1e6 1e5 1e4 1e3 1e2 -))
> (define cap0 (first capacity))
>
> (define (beverton-holt N p c) (/ N (+ (/ 1 p) (/ N c
>
> (define (evolve N [f fecundity] [s survival] [cap (rest capacity)] [Nt0 0] 
> [Nt null])
> (if (null? f)
> (cons Nt0 (reverse Nt))
> (evolve (rest N) (rest f) (rest s) (rest cap)
> (+ Nt0 (if (= (first f) 0)
>0
>(beverton-holt (* (first N) prop-female)
>   (* (first f) egg-surv)
>   (- cap0 Nt0
> (if (= (first s) 0)
> Nt
> (cons (beverton-holt (first N) (first s) (first cap)) 
> Nt)
>
> (define (iterate N n [i 1])
>   (displayln (list i N))
>   (unless (= i n) (iterate (evolve N) n (+ i 1
>
> (iterate (make-list (length fecundity) 10) years)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: nested for loops and suggested alternatives

2019-02-10 Thread travis . hinkelman
I played around a bit with the math/matrix library. Actually, my first idea 
for a Racket learning project was to rewrite the code in the R popbio 
package (https://cran.r-project.org/web/packages/popbio/popbio.pdf) in 
Racket. But I bailed on that when I saw that eigendecomposition was still 
on the list of unimplemented but useful algorithms for math/matrix.

Performance is not important for this example but this math/array warning 
gave me the impression that perhaps it was not the best place to start for 
me. 

Performance Warning: Indexing the elements of arrays created in untyped 
> Racket is currently 25-50 times slower than doing the same in Typed Racket, 
> due to the overhead of checking higher-order contracts. We are working on 
> it.


I also thought it would be good to stick to racket/base for my early forays 
with Racket but I would not give that same advice to someone learning R 
(i.e., some R packages greatly ease the introduction to R).


On Sunday, February 10, 2019 at 12:47:52 AM UTC-8, Philip McGrath wrote:
>
> You may also want to look into the math/array 
>  and math/matrix 
>  libraries.
> -Philip
>
>
> On Sun, Feb 10, 2019 at 3:42 AM Alex Harsanyi  > wrote:
>
>> This line looks suspicious:
>>
>>  (define results (make-vector years (make-vector (vector-length 
>> fecundity) 0)))
>>
>> The "(make-vector (vector-length fecundity) 0)" expression will create a 
>> single vector, than it creates the outer vector will all elements pointing 
>> to it.  It is not a matrix, but a "column" vector where each element is 
>> referencing the same row vector.  This means that if you update an element 
>> in one of the rows, the same value will "appear" in all other rows. The 
>> only row that is different is the first one which you initialize in the 
>> line:
>>
>> (vector-set! results 0 (make-vector (vector-length fecundity) 10))
>>
>> What you probably want is a vector of vectors, which can be built like 
>> this
>>
>> (define results (for/vector ([index (in-range years)]) (make-vector 
>> (vector-length fecundity) 0)))
>>
>> Alex.
>>
>>
>>
>> On Sunday, February 10, 2019 at 3:40:42 PM UTC+8, travis.h...@gmail.com 
>> wrote:
>>>
>>> Hi All,
>>>
>>> I'm an R programmer that has recently started learning Racket. I decided 
>>> to start by trying to create a simple age-structured population model. In 
>>> R, I would initialize a matrix and use nested for loops to move through the 
>>> elements of the matrix and propagate the population forward through time. 
>>> For my first attempt in Racket (
>>> https://gist.github.com/hinkelman/3ee6115cdd7f0a4c8f1672b7d8df5c27), I 
>>> used for* to loop through a vector of vectors. The code in that gist 
>>> doesn't quite work. There is apparently something wrong with how I'm using 
>>> vector-set! such that "rows" in my vector of vectors are being updated 
>>> prematurely. I would greatly appreciate it if someone could point out what 
>>> I'm doing wrong there. I'm also interested in suggestions for alternative 
>>> approaches because it seems unlikely that I have written this code in 
>>> idiomatic Racket.
>>>
>>> Thanks,
>>>
>>> Travis
>>>
>>> P.S. If it is helpful, here is a gist (
>>> https://gist.github.com/hinkelman/d5b8414b0c6383057d7846509a724bbf) 
>>> with the R code that I was trying to write in Racket.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: nested for loops and suggested alternatives

2019-02-10 Thread travis . hinkelman
Yes, this was the problem. I now have results that match the output from R. 
I've updated the gist with your line for the correct way to create a vector 
of vectors. I will have to spend some more time to understand the 
make-vector behavior. Perhaps my thinking is too constrained by my R 
experience where many functions are "vectorized"? I guess the part that was 
confusing me (and still is) is why make-vector worked as expected (by me) 
for my inner vector but not my outer vector. Thanks!


On Sunday, February 10, 2019 at 12:42:53 AM UTC-8, Alex Harsanyi wrote:
>
> This line looks suspicious:
>
>  (define results (make-vector years (make-vector (vector-length 
> fecundity) 0)))
>
> The "(make-vector (vector-length fecundity) 0)" expression will create a 
> single vector, than it creates the outer vector will all elements pointing 
> to it.  It is not a matrix, but a "column" vector where each element is 
> referencing the same row vector.  This means that if you update an element 
> in one of the rows, the same value will "appear" in all other rows. The 
> only row that is different is the first one which you initialize in the 
> line:
>
> (vector-set! results 0 (make-vector (vector-length fecundity) 10))
>
> What you probably want is a vector of vectors, which can be built like this
>
> (define results (for/vector ([index (in-range years)]) (make-vector 
> (vector-length fecundity) 0)))
>
> Alex.
>
>
>
> On Sunday, February 10, 2019 at 3:40:42 PM UTC+8, travis.h...@gmail.com 
> wrote:
>>
>> Hi All,
>>
>> I'm an R programmer that has recently started learning Racket. I decided 
>> to start by trying to create a simple age-structured population model. In 
>> R, I would initialize a matrix and use nested for loops to move through the 
>> elements of the matrix and propagate the population forward through time. 
>> For my first attempt in Racket (
>> https://gist.github.com/hinkelman/3ee6115cdd7f0a4c8f1672b7d8df5c27), I 
>> used for* to loop through a vector of vectors. The code in that gist 
>> doesn't quite work. There is apparently something wrong with how I'm using 
>> vector-set! such that "rows" in my vector of vectors are being updated 
>> prematurely. I would greatly appreciate it if someone could point out what 
>> I'm doing wrong there. I'm also interested in suggestions for alternative 
>> approaches because it seems unlikely that I have written this code in 
>> idiomatic Racket.
>>
>> Thanks,
>>
>> Travis
>>
>> P.S. If it is helpful, here is a gist (
>> https://gist.github.com/hinkelman/d5b8414b0c6383057d7846509a724bbf) with 
>> the R code that I was trying to write in Racket.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] nested for loops and suggested alternatives

2019-02-09 Thread travis . hinkelman
Hi All,

I'm an R programmer that has recently started learning Racket. I decided to 
start by trying to create a simple age-structured population model. In R, I 
would initialize a matrix and use nested for loops to move through the 
elements of the matrix and propagate the population forward through time. 
For my first attempt in Racket 
(https://gist.github.com/hinkelman/3ee6115cdd7f0a4c8f1672b7d8df5c27), I 
used for* to loop through a vector of vectors. The code in that gist 
doesn't quite work. There is apparently something wrong with how I'm using 
vector-set! such that "rows" in my vector of vectors are being updated 
prematurely. I would greatly appreciate it if someone could point out what 
I'm doing wrong there. I'm also interested in suggestions for alternative 
approaches because it seems unlikely that I have written this code in 
idiomatic Racket.

Thanks,

Travis

P.S. If it is helpful, here is a gist 
(https://gist.github.com/hinkelman/d5b8414b0c6383057d7846509a724bbf) with 
the R code that I was trying to write in Racket.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Python's append vs Racket's append and helping novices understand the implications

2019-02-01 Thread travis . hinkelman
I don't have any suggestions for you but I agree that it is an important 
issue. My programming experience is primarily confined to R but I've 
recently started tinkering with Racket. My primary interest in Racket is to 
expand my programming horizons but I also see the potential to use it at 
work as replacement for R for building simulation models. The idea that 
Racket could replace R for those tasks is based on the expectation that 
Racket would be faster than R (relatively low bar for Racket to clear) but 
similarly expressive. However, in my 10+ years as an R programmer, there is 
a lot of hard-won knowledge of performance traps to avoid and optimization 
tricks to try. As I move forward learning Racket, it will be interesting to 
see how my naive Racket code stacks up to my better optimized R code. I 
personally will very much appreciate any efforts targeted towards making 
performance issues more transparent to Racket beginners.

Thanks,

Travis



On Friday, February 1, 2019 at 10:28:12 PM UTC-8, Alex Harsanyi wrote:
>
> Someone asked recently for help on Reddit[1] with a Racket performance 
> issue.
> The problem was they they were constructing a large list by appending many
> short lists repeatedly; their code was calling `(set!  result (append 
> result
> shortList))` in a loop and this was slow (unsurprisingly.)
>
> While trying to help them out, it occurred to me that this person was 
> perhaps
> translating a program from Python to Racket, maybe to evaluate Racket.  The
> problem is that list-append operations are efficient in Python, but the
> natural corresponding choice in Racket, the `append` function, is not.  I
> wonder how many people are in a similar situation, where they try to 
> convert a
> Python program to Racket, see that the performance is bad, and conclude 
> that
> Racket is slow -- Every time Racket is mentioned on Reddit or HN there is 
> at
> least one person mentioning that Racket is slow and sadly they may even 
> have
> their own data to prove it.
>
> Given the recent discussion in this group about promoting Racket, I am
> wondering what can we do to help this category of people?  These might be
> persons who never ask for help in any forum, after all the Racket
> documentation is good enough to help anyone who is willing to read it.
>
> One improvement that I can think of is to add a performance description to
> each function that operates on the basic data structures (lists, vectors,
> hash-tables)
>
> What do others think?
> Alex.
>
> [1]: 
> https://www.reddit.com/r/Racket/comments/am5r2w/how_to_read_a_file_linebyline_efficiently/
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.