This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#4101 2011-11-19 09:37:38

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

make a list and add 2000 random items to it. Now do the same in Scratch!


Jens Mönig

Offline

 

#4102 2011-11-19 10:54:00

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Jens wrote:

make a list and add 2000 random items to it. Now do the same in Scratch!

To be honest, Scratch is performing really well with 5000+ items.


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#4103 2011-11-19 12:55:35

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Request: String operators!

Code:

(letter () of [])
(join [] and [])
(length of [])

I need them to make a hash function.
I also want to be able to set value 10 of a list and not have to set value 3.


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#4104 2011-11-19 12:59:52

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

MathWizz wrote:

Request: String operators!

Code:

(letter () of [])
(join [] and [])
(length of [])

I need them to make a hash function.
I also want to be able to set value 10 of a list and not have to set value 3.

You don't have to ask for anything that's in BYOB.  But they can't all be implemented on the same day!   smile


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4105 2011-11-19 23:40:54

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

MathWizz wrote:

Request: String operators!

Code:

(letter () of [])
(join [] and [])
(length of [])

I need them to make a hash function.
I also want to be able to set value 10 of a list and not have to set value 3.

You don't have to ask for anything that's in BYOB.  But they can't all be implemented on the same day!   smile

+1


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#4106 2011-11-20 02:56:44

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Could a few people with a lot of patience try the following in Snap! (with all the variable watchers hidden) and time how long it takes and let me know along with your OS and browser? (And I guess how old your computer is.  smile )

http://cs.berkeley.edu/~bh/sort1.png

http://cs.berkeley.edu/~bh/sort2.png

http://cs.berkeley.edu/~bh/sort3.png

http://cs.berkeley.edu/~bh/sort4.png

(I don't advise trying it for lists larger than 100 items.)

Thanks!


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4107 2011-11-20 10:41:06

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

@bharvey, it took about 7min *wondering what would happen if i change it to 1000*
tongue

Offline

 

#4108 2011-11-20 13:39:29

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

roijac wrote:

@bharvey, it took about 7min *wondering what would happen if i change it to 1000*
tongue

That's about the same as my result.  What's your browser and OS?  I want to be sure this isn't just a browser problem.

I estimate that 1000 items would take about half a year, extrapolating from the 100 case.

EDIT: Jens and I are having a disagreement about the nature of the problem.  We'll see if his upcoming fix fixes it...   smile

Last edited by bharvey (2011-11-20 13:58:23)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4109 2011-11-20 15:01:00

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

ff7, linux, intel core 2 quad x64, if it's important  smile
tested recursive calls,

btw, you should know what OS i'm using, don't you?  tongue

Offline

 

#4110 2011-11-20 21:24:21

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Jens and I are having a disagreement about the nature of the problem.  We'll see if his upcoming fix fixes it...   smile

It's not a fix, it's a feature and it's called atomicity (to be used wisely). Check out the new WARP block!


Jens Mönig

Offline

 

#4111 2011-11-20 22:36:45

iTweak0r
Scratcher
Registered: 2011-07-30
Posts: 100+

Re: BYOB 3 - Discussion Thread

Jens wrote:

bharvey wrote:

Jens and I are having a disagreement about the nature of the problem.  We'll see if his upcoming fix fixes it...   smile

It's not a fix, it's a feature and it's called atomicity (to be used wisely). Check out the new WARP block!

what does the warp block do? i put blocks in there and it gives me an error


Make it in Scratch! because it's cooler when it's made in scratch
http://i.imgur.com/D4iqPHR.png

Offline

 

#4112 2011-11-21 08:12:59

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

warp?  hmm
@bharvey, i think your problem was that you didn't use in-place functions, but created new list every time, which had to be saved to RAM etc.

Edit: tried the script on python. works fast, as long you don't make the list longer than 1000 (max. recursive calls issue)

Code:

listLength=100 #change here to change the list's length
def cons(a, b):
    result=[a]
    index=-1
    for i in range(len(b)):
        index+=1
        result.append(b[index])
    return result

def cdr(a):
    result=[]
    index=0
    for i in range(len(a)-1):
        index+=1
        result.append(a[index])
    return result

def odds(L):
    if len(L)==0: return L
    return cons(L[0], evens(cdr(L)))

def evens(L):
    if len(L)==0: return L
    return odds(cdr(L))

def merge(a, b):
    if len(a)==0: return b
    if len(b)==0: return a
    if a[0]>b[0]:
        return cons(b[0], merge(a, cdr(b)))
    return cons(a[0], merge(b, cdr(a)))

def sort(L):
    if len(L)<2: return L
    return merge(sort(odds(L)), sort(evens(L)))

import random
spam=[round(random.random()*10000) for i in range(listLength)]
spam=sort(spam)
print(spam)

Last edited by roijac (2011-11-21 08:42:00)

Offline

 

#4113 2011-11-21 10:24:02

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

roijac wrote:

@bharvey, i think your problem was that you didn't use in-place functions, but created new list every time, which had to be saved to RAM etc.

Yes, that was the point of the test.  When lists are properly implemented, the operations I called CONS and CDR are very fast, and do not require copying the list each time.  Proper implementation is necessary to support functional programming on lists, which we should support!


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4114 2011-11-21 12:04:31

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I'd just thought I'd mention this. I bet you could report the topic post to a mod if you really need it edited and they would edit it for you. Although it doesn't look like you'll need to anyway.


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#4115 2011-11-21 15:46:13

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

nXIII wrote:

If you wanted a super-performant list structure, I could try to implement virtual lists. Then you could have a list of millions of items with no less performance, all in one big page.

I think it's the display, not the accessing, that's at issue.

Sorry, I meant "list-displaying-structure"--that is, a morph. Virtual lists reuse morphs in order to only allocate memory for and display enough items to fit in the viewing pane. That way, only eight or ten morphs would ever be rendered at one time, and the list doesn't even have to create a morph for every single item.

Last edited by nXIII (2011-11-21 15:47:20)


nXIII

Offline

 

#4116 2011-11-21 16:37:44

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

warped insertion sort example

time it takes to populate a list with random integers and to create a sorted copy on Brian's old MacBookPro and on my ancient PC both running Chrome:

   100 items: 1 sec / 1 sec
   500 items: 15 secs  / 22 secs
   1000 items: 1 min 10 secs / 1 min 26 secs

with all watchers hidden.

http://chirp.scratchr.org/dl/experimental/JsMorphic/grf/insertion%20sort.png

The WARP block corresponds to the "atomic" check box in BYOB, it runs the code it encompasses as a single block, interrupting only occasionally in order to update the display and to let the user interact. Try it on fractal turtle drawings and enjoy!

P.S.: The list watcher uses a "virtual list displaying structure" in that it only shows a subrange of about 100 cells. It feels slow because I'm only updating it every half second or so in order to allocate more resources to the evaluator, and even then I'm interrupting it while the update is still in progress in order to resume program evaluation again. It's not a DOM/CSS/XML/BMW/CIA/YMCA issue.  smile

with both list watchers showing it takes almost the same time:

   100 items: 2 secs
   500 items: 22 secs
   1000 items: 1 min 10 secs

to populate the unsorted list with random integers and to create and display a sorted copy of it. Where it's slow is below 100 items, because it has to create the cells the first time. But anything above 100 items doesn't take any longer just to display.

P.P.S.: Also new today are REPEAT UNTIL and WAIT UNTIL

Last edited by Jens (2011-11-21 17:23:06)


Jens Mönig

Offline

 

#4117 2011-11-21 16:58:52

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: BYOB 3 - Discussion Thread

@Jens Awesome update! I will make use of the warp block.  big_smile


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#4118 2011-11-21 21:08:11

iTweak0r
Scratcher
Registered: 2011-07-30
Posts: 100+

Re: BYOB 3 - Discussion Thread

coooool i know what the warp block does now

and also its cool because it can be used on anything, not just user-created blocks


Make it in Scratch! because it's cooler when it's made in scratch
http://i.imgur.com/D4iqPHR.png

Offline

 

#4119 2011-11-21 22:34:37

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

nXIII wrote:

Sorry, I meant "list-displaying-structure"--that is, a morph. Virtual lists reuse morphs in order to only allocate memory for and display enough items to fit in the viewing pane. That way, only eight or ten morphs would ever be rendered at one time, and the list doesn't even have to create a morph for every single item.

Oh, I see.  That sounds good -- but not until save and load are done!!!  (I was going to put a ferocious angry smiley here but the Scratch forum only has innocuous ones.  smile )


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4120 2011-11-22 02:29:20

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

nXIII wrote:

Sorry, I meant "list-displaying-structure"--that is, a morph. Virtual lists reuse morphs in order to only allocate memory for and display enough items to fit in the viewing pane. That way, only eight or ten morphs would ever be rendered at one time, and the list doesn't even have to create a morph for every single item.

Oh, I see.  That sounds good -- but not until save and load are done!!!  (I was going to put a ferocious angry smiley here but the Scratch forum only has innocuous ones.  smile )

is this so high on your list?
yay!  smile

Offline

 

#4121 2011-11-23 00:09:38

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Update:  We both won the argument -- we were both right about different aspects of the problem and need both our solutions.  smile


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4122 2011-11-23 04:18:00

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

@Jens "Try it on fractal turtle drawings and enjoy!"
See the following example : without/with warp 70 sec/0.5 sec

http://www.xleroy.net/ByobTuto/New/Snap!/dragoncurvenew.gif

Offline

 

#4123 2011-11-23 11:03:32

Sidharth
Scratcher
Registered: 2007-12-14
Posts: 100+

Re: BYOB 3 - Discussion Thread

Why is the name for the "all but first of" block "cdr" and the "insert at place 1" block called "cons"?


http://www.danasoft.com/citysign.jpg

Offline

 

#4124 2011-11-23 11:09:47

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Update:  We both won the argument -- we were both right about different aspects of the problem and need both our solutions.  smile

Isn't it awesome when it works out that way and no one gets to gloat?  smile

Offline

 

#4125 2011-11-23 11:52:08

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Sidharth wrote:

Why is the name for the "all but first of" block "cdr" and the "insert at place 1" block called "cons"?

Not the permanent names.  But they're historical, from LISP, where functional programming on linked lists originated.  CONS is short for CONStruct, because it makes a new pair, the fundamental unit of storage; CDR dates from the first Lisp implementation on an IBM 704 computer, which had an Address and a Decrement in its central processor register, so it's the Contents of the Decrement of the Register; the left half of the pair was the Contents of the Address of the Register.  The reason these otherwise silly names have survived is that they lend themselves to combination, so CDDADR ("cuh duh DAA dur") is f(x)=(cdr(cdr(car(cdr x)))).  smile

Note: CONS isn't "insert at place 1"!  It does not modify its input list; it makes a new list (which shares storage with the input list).  In the BYOB 3 tools this is called ADJOIN (item) TO (list).  We're considering (item) IN FRONT OF (list) as an alternative.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

Board footer