View Single Post
Old 02-23-2021, 05:33 AM   #363
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,102
Karma: 1954136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by chaley View Post
[/CODE]I used the keyword 'separator' to remove some ambiguity in the language parser.
That makes senese. It is now working for me.

Code:
program:
	book_ids = from_selection('id');
	all_authors = category_items('authors',book_ids);
	res = '';
	for a in all_authors separator '&':
		ratings = from_search('rating', strcat('rating:true and author:"=', a, '"'));
		if ratings then
			avg = divide(mean(ratings), 2);
			res = list_union(res, strcat(a, ':', avg), ',')
		fi
	rof;
	res
Using all authors without restricting them using from_search() or from_selection() on large libraries is not recommended as it is verrrrrrry slow.

Quote:
Originally Posted by chaley View Post
Note that the 'thing' following the keyword is an arbitrary expression.
Wow. I will sure come up with a use for that sometime in the future.
capink is offline   Reply With Quote