• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Using scanLeft to output to an array?

 
Ranch Hand
Posts: 63
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings, I've a Scala syntax question; I came across a situation where scanLeft seemed perfect for the job at hand, but I needed to write the results to an existing array. However, I couldn't work out how to "teach" scanLeft to put its results in that array, rather than generating whatever structure it wanted to.

Can anyone show me how I'd do that?

TIA,
Toby.
 
Ranch Hand
Posts: 579
6
jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if you have solved this problem yet.
Why are you using scanLeft specifically?

Here is something I think you might be looking for:

But if you are updating an array, there are definitely better ways to do it.
Benefit of functional programming is no side effects.
 
Toby Eggitt
Ranch Hand
Posts: 63
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

s ravi chandran wrote:Not sure if you have solved this problem yet.
Why are you using scanLeft specifically?

[snip snip...]

But if you are updating an array, there are definitely better ways to do it.
Benefit of functional programming is no side effects.



Thanks for the input Ravi, I appreciate you taking the time to answer.

I ended up building a parallel scanLeft-to-array by hand. It worked out fairly well and scales well.

Thanks,
Toby
 
s ravi chandran
Ranch Hand
Posts: 579
6
jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!