StackOverflowError

16 views
Skip to first unread message

Gal Dolber

unread,
Jun 7, 2012, 6:00:52 AM6/7/12
to loop...@googlegroups.com
Hi,
I've been playing with loop, loving it so far!

I'm getting StackOverflowError on this code:

subseqs(a) ->
  func.@call(a) + func.@call(a.reverse())
  where
    func: @(a) -> {a.subList(a.indexOf(i), a.size()) for i in a}

print(subseqs([-10,20,-34,10,22,-5]))


What am I doing wrong?

also, if I use a[a.indexOf(i)..] I get an error, array slicing doesn't work in most of the situations I tried

Thanks


--
Guit: beautiful gwt applications

https://github.com/galdolber/Guit




Dhanji R. Prasanna

unread,
Jun 7, 2012, 6:42:51 PM6/7/12
to loop...@googlegroups.com, gal.d...@gmail.com
Hi,

Thanks for the kind words! You're creating a closure on entry into the function every time, try this instead:

>> subseqs(a) ->
|      func(a) + func(a.reverse())
|      where
|        func(a) ->
|          a.subList(a.indexOf(i), a.size()) for i in a
|    
ok
>> subseqs([-10,20,-34,10,22,-5])
[[-10, 20, -34, 10, 22, -5], [20, -34, 10, 22, -5], [-34, 10, 22, -5], [10, 22, -5], [22, -5], [-5], [-5, 22, 10, -34, 20, -10], [22, 10, -34, 20, -10], [10, -34, 20, -10], [-34, 20, -10], [20, -10], [-10]]


As for the list slice, let me take a closer look--there is definitely some bug going on. Thanks for reporting it!

Dhanji.

Gal Dolber

unread,
Jun 7, 2012, 6:55:41 PM6/7/12
to loop...@googlegroups.com
Oh, I see! thanks!!

Dhanji R. Prasanna

unread,
Jun 7, 2012, 7:37:15 PM6/7/12
to loop...@googlegroups.com, gal.d...@gmail.com
OK have fixed the bug with list slice expressions. Now works as expected:

>> a:[1,2,3]
[1, 2, 3]
>> a[a.indexOf(2)..]
[2, 3]


Please update your distro.
Reply all
Reply to author
Forward
0 new messages