bharvey wrote:
OldCodger wrote:
list comprehension
Look at my http://byob.berkeley.edu/streams.ypr]lazy list/url BYOB project to see how we can do this. The syntax isn't exactly the same, but nothing stops you from making a block
if that notation turns you on.
Lazy lists are very useful but I hate Lisp-speak. I am going to try and build a list comprehension block.
Offline
bharvey wrote:
OldCodger wrote:
list comprehension
Look at my lazy list BYOB project to see how we can do this. The syntax isn't exactly the same, but nothing stops you from making a block
http://cs.berkeley.edu/~bh/comprehension.png
if that notation turns you on.
i don't understand that notation. Could you explain it or make a more readable notation?
Offline
joefarebrother wrote:
i don't understand that notation. Could you explain it or make a more readable notation?
[ (map-function) | (upvar) IN (stream) , (predicate) ]
means
MAP (map-function) OVER (KEEP ITEMS SUCH THAT (predicate) FROM (stream))
but using the stream (lazy list) versions of MAP and KEEP. So for example
[ ((2) * (x)) | (x) IN (positive-integers) , ((SQRT OF (x)) = (ROUND (SQRT OF (x))) ]
would take the positive integers, select the ones that are squares of integers, and compute 2 * x for each, giving the stream (2, 8, 18, 32, 50, 72, ...).
(That explains the notation, but assumes you understand lazy lists, which allow lists to have infinitely many elements. If you need help with that, first read the project notes in my project, then ask again.)
Last edited by bharvey (2012-06-10 09:32:42)
Offline
bharvey wrote:
Hardmath123 wrote:
You need a GreaseMonkey userscript:
Good workaround, thanks, but it still needs to be really fixed — I don't think most schools are going to run Greasemonkey!
Well, you could put that directly into the code too.
Offline
technoboy10 wrote:
technoboy10 wrote:
Is there a Snap! discussion thread?
We're just using this, until Snap! is released/goes into beta.
Offline
scimonster wrote:
technoboy10 wrote:
technoboy10 wrote:
Is there a Snap! discussion thread?
We're just using this, until Snap! is released/goes into beta.
Okay.
Offline
Does Snap! alpha look weird on Firefox for anyone else (Windows 7)?
Offline
bharvey wrote:
joefarebrother wrote:
i don't understand that notation. Could you explain it or make a more readable notation?
[ (map-function) | (upvar) IN (stream) , (predicate) ]
means
MAP (map-function) OVER (KEEP ITEMS SUCH THAT (predicate) FROM (stream))
but using the stream (lazy list) versions of MAP and KEEP. So for example
[ ((2) * (x)) | (x) IN (positive-integers) , ((SQRT OF (x)) = (ROUND (SQRT OF (x))) ]
would take the positive integers, select the ones that are squares of integers, and compute 2 * x for each, giving the stream (2, 8, 18, 32, 50, 72, ...).
(That explains the notation, but assumes you understand lazy lists, which allow lists to have infinitely many elements. If you need help with that, first read the project notes in my project, then ask again.)
So it is a composition of (strm-map (func)(strm)) and (strm-filter (pred)(strm))
Last edited by joefarebrother (2012-06-11 13:35:02)
Offline
joefarebrother wrote:
So it is a composition of (strm-map (pred)(strm)) and (strm-filter (pred)(strm))
Yes, exactly, except that "pred" applies only to filter, not map. (Predicate functions are the ones that return Boolean values.)
Offline
Jens wrote:
technoboy10 wrote:
Does Snap! alpha look weird on Firefox for anyone else (Windows 7)?
Can you post a screenshot showing what looks weird? Thanks!
Last edited by technoboy10 (2012-06-10 20:09:32)
Offline
bharvey wrote:
joefarebrother wrote:
i don't understand that notation. Could you explain it or make a more readable notation?
[ (map-function) | (upvar) IN (stream) , (predicate) ]
means
MAP (map-function) OVER (KEEP ITEMS SUCH THAT (predicate) FROM (stream))
but using the stream (lazy list) versions of MAP and KEEP. So for example
[ ((2) * (x)) | (x) IN (positive-integers) , ((SQRT OF (x)) = (ROUND (SQRT OF (x))) ]
would take the positive integers, select the ones that are squares of integers, and compute 2 * x for each, giving the stream (2, 8, 18, 32, 50, 72, ...).
(That explains the notation, but assumes you understand lazy lists, which allow lists to have infinitely many elements. If you need help with that, first read the project notes in my project, then ask again.)
You can watch this video by Erik Meijer and read the same chapter in Programming in Haskell by Graham Hutton. They will help you understand list comprehension.
http://channel9.msdn.com/shows/Going+Deep/C9-Lectures-Dr-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-5-of-13/
Offline
technoboy10 wrote:
Jens wrote:
technoboy10 wrote:
Does Snap! alpha look weird on Firefox for anyone else (Windows 7)?
Can you post a screenshot showing what looks weird? Thanks!
Here you go!
http://scratch.mit.edu/static/projects/ … 890_sm.png<Clicky
Thanks for the screenshot! I cannot reproduce these on my computers (Mac and PC), except for the missing Unicode characters (the stop sign) in some browsers. To me it appears that your OS display settings allow for too few colors (it looks like 16 - 256 colors to me). Can you try changing your display settings to allow for more colors? Thanks!
Offline
While I can't say I'm having any trouble with the bluriness technoboy described, I can report that the latest version of Chrome on Windows is missing the stop and go unicode characters (I just thought you hadn't added them yet). Any plans to fix that?
Offline
shadow_7283 wrote:
While I can't say I'm having any trouble with the bluriness technoboy described, I can report that the latest version of Chrome on Windows is missing the stop and go unicode characters (I just thought you hadn't added them yet). Any plans to fix that?
Well, the green and red squares have been replaced (as of today) with the standard green flag and stop sign, so maybe that was the way they fixed that.
Offline
Unfortunately the full Unicode set (or even the most common subset) isn't supported by every browser, especially under Windows, but eventually we're going to replace the problematic font symbols with drawn ones. At the moment, however, this isn't a priority.
Offline
Posted this thread and realized I probably should have just asked my question here.
Offline
Snap! alpha update
Folks, this week's work on Snap! features among other things:
* global custom blocks ("for all sprites")
* optional solid drop shadows and stack highlights (default in Chrome)
* saving / loading of global variables and stage variables
Enjoy!
Offline
Jens wrote:
Snap! alpha update
Enjoy!
1- Saving/loading of a variable defined as a LIST is reloaded correctly but is not recognized in the executable block. I need to reset it. I shall investigate further on.
2 - I ignore if this is a new feature or not. Anyhow it is new for me.
To duplicate one block from Sprite1 to a newly created Sprite2 :
- duplicate the block and drag it onto the Sprite area.
- close Sprite1 and open Sprite2.
- drag the duplicated block onto the script area of Sprite2
- that's it !
Offline