View Single Post
Old 07-16-2022, 01:24 PM   #5
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
This is a way to do the same example using a for loop. It might be easier to read and understand.
Code:
program:
	sample_input = 'Bus, Car, Starship, Ferry, Ferry Terminal, Alien Spacecraft';

	output = '';
	for item in sample_input:
		if  	  item == 'bus' then ni = 'Public Transport'
			elif item == 'ferry' then ni = 'Vehicle'
			elif item == 'starship' then ni = 'Vehicle'
			else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_remove_duplicates(output, ',')
The output is
Code:
Public Transport, Car, Vehicle, Ferry Terminal, Alien Spacecraft
You can sort the list if you want with
Code:
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
Now the output is
Code:
Alien Spacecraft, Car, Ferry Terminal, Public Transport, Vehicle
chaley is offline   Reply With Quote