This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

First program with usage of streams  RSS feed

 
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I've written simple program for finding anagrams and printing word + it's anagrams (if count of anagrams for it is ==  max count of anagrams in given file) . But I got the problem, because I don't know how to return output of filtered structure.
For printing my intent is to have something like that: word: anagram1 anagram2 anagram3... anagram(n)
Could you help me? This is my first program with usage of java.util.Stream so I feel a little lost for now.

 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah and don't worry. This site in URL is  link to forum for riddle fanatics  and it is safe.
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so I put
in the what's next line (33), but it is far from perfect.
Output:

 
Bartender
Posts: 9551
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, what do you want to happen?

P.S. you can eliminate the get() in line 21, because if you use computeIfAbsent(), it returns the set you need.

This has the added benefit that you only create the new set when you really need to.
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to have program that at the end (with usage of Streams) will print something like:
word1 anagram1 anagram2
word2 anagram1 anagram2 ...

But I've already did it:

It looks nice and it seems to work
 
Stephan van Hulst
Bartender
Posts: 9551
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also write your application like this:
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Do you pee on your compost? Does this tiny ad?
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!