Skip to content

Instantly share code, notes, and snippets.

@tron1point0
Created March 9, 2012 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tron1point0/2009370 to your computer and use it in GitHub Desktop.
Save tron1point0/2009370 to your computer and use it in GitHub Desktop.
Look, ma, I made a database with a query language!
import Data.List
import Data.Maybe
input x = map (\(a,b) -> (a, b * x))
reduce :: [([Char], Integer)] -> [([Char], Integer)]
reduce = map (\(a,b) -> (head a, sum b)) . map (unzip) . group . sort
planet n = map (\(a,_) -> (n,a))
planets_for = foldl1
(\a b ->
a ++ if (length $ b \\ a) < (length b)
then []
else [head b])
. sortBy (\a b -> compare (length a) (length b))
. map (\a -> snd . fromJust $ find (\(x,_) -> x == a) materials)
. map fst . reduce
materials =
map (\(a,b) -> (head a, b))
. map unzip
. groupBy (\(a,_) (b,_) -> a == b)
. sort $ map (\(a,b) -> (b,a)) planets
-- P0
microorganisms = [("Microorganisms",1)]
carbon_compounds = [("Carbon Compounds",1)]
planktic_colonies = [("Planktic Colonies",1)]
non_cs_crystals = [("Non-CS Crystals",1)]
ionic_solutions = [("Ionic Solutions",1)]
autotrophs = [("Autotrophs",1)]
reactive_gas = [("Reactive Gas",1)]
noble_gas = [("Noble Gas",1)]
suspended_plasma = [("Suspended Plasma",1)]
noble_metals = [("Noble Metals",1)]
complex_organisms = [("Complex Organisms",1)]
base_metals = [("Base Metals",1)]
felsic_magma = [("Felsic Magma",1)]
heavy_metals = [("Heavy Metals",1)]
aqueous_liquids = [("Aqueous Liquids",1)]
-- Planets
barren = planet "Barren" $ aqueous_liquids ++ base_metals ++ carbon_compounds ++ microorganisms ++ noble_metals
gas = planet "Gas" $ aqueous_liquids ++ base_metals ++ ionic_solutions ++ noble_gas ++ reactive_gas
ice = planet "Ice" $ aqueous_liquids ++ heavy_metals ++ microorganisms ++ noble_gas ++ planktic_colonies
lava = planet "Lava" $ base_metals ++ felsic_magma ++ heavy_metals ++ non_cs_crystals ++ suspended_plasma
oceanic = planet "Oceanic" $ aqueous_liquids ++ complex_organisms ++ microorganisms ++ planktic_colonies
plasma = planet "Plasma" $ base_metals ++ heavy_metals ++ noble_metals ++ non_cs_crystals ++ suspended_plasma
storm = planet "Storm" $ aqueous_liquids ++ base_metals ++ ionic_solutions ++ noble_gas ++ suspended_plasma
temperate = planet "Temperate" $ aqueous_liquids ++ autotrophs ++ carbon_compounds ++ complex_organisms ++ microorganisms
planets = barren ++ gas ++ ice ++ lava ++ oceanic ++ plasma ++ storm ++ temperate
-- P1-4
integrity_response_drones = reduce $ input 6 gel_matrix_biopaste ++ input 6 hazmat_detection_systems ++ input 6 planetary_vehicles
nano_factory = reduce $ input 6 industrial_explosives ++ input 40 reactive_metals ++ input 6 ukomi_superconductors
broadcast_node = reduce $ input 6 data_chips ++ input 6 high_tech_transmitters ++ input 6 neocoms
recursive_computing_module = reduce $ input 6 guidance_systems ++ input 6 synthetic_synapses ++ input 6 transcranial_microcontrollers
self_harmonizing_power_core = reduce $ input 6 camera_drones ++ input 6 hermetic_membranes ++ input 6 nuclear_reactors
wetware_mainframe = reduce $ input 6 biotech_research_reports ++ input 6 cryoprotectant_solution ++ input 6 supercomputers
vaccines = reduce $ input 10 livestock ++ input 10 viral_agent
sterile_conduits = reduce $ input 6 smartfab_units ++ input 6 vaccines ++ input 40 water
gel_matrix_biopaste = reduce $ input 10 biocells ++ input 10 oxides ++ input 10 superconductors
supercomputers = reduce $ input 10 consumer_electronics ++ input 10 coolant ++ input 10 water_cooled_cpu
hazmat_detection_systems = reduce $ input 10 polytextiles ++ input 10 transmitter ++ input 10 viral_agent
hermetic_membranes = reduce $ input 10 genetically_enhanced_livestock ++ input 10 polyaramids
robotics = reduce $ input 10 consumer_electronics ++ input 10 mechanical_parts
nuclear_reactors = reduce $ input 10 enriched_uranium ++ input 10 microfiber_shielding
organic_mortar_applicators = reduce $ input 40 bacteria ++ input 6 condensates ++ input 6 robotics
neocoms = reduce $ input 10 biocells ++ input 10 silicate_glass
synthetic_synapses = reduce $ input 10 supertensile_plastics ++ input 10 test_cultures
high_tech_transmitters = reduce $ input 10 polyaramids ++ input 10 transmitter
transcranial_microcontrollers = reduce $ input 10 biocells ++ input 10 nanites
camera_drones = reduce $ input 10 rocket_fuel ++ input 10 silicate_glass
cryoprotectant_solution = reduce $ input 10 fertilizer ++ input 10 synthetic_oil ++ input 10 test_cultures
data_chips = reduce $ input 10 microfiber_shielding ++ input 10 supertensile_plastics
polyaramids = reduce $ input 40 industrial_fibers ++ input 40 oxidizing_compound
industrial_fibers = reduce $ input 3000 autotrophs
superconductors = reduce $ input 40 plasmoids ++ input 40 water
construction_blocks = reduce $ input 40 toxic_metals ++ input 40 reactive_metals
livestock = reduce $ input 40 biofuels ++ input 40 proteins
rocket_fuel = reduce $ input 40 electrolytes ++ input 40 plasmoids
viral_agent = reduce $ input 40 bacteria ++ input 40 biomass
plasmoids = reduce $ input 3000 suspended_plasma
supertensile_plastics = reduce $ input 40 biomass ++ input 40 oxygen
coolant = reduce $ input 40 water ++ input 40 electrolytes
oxidizing_compound = reduce $ input 3000 reactive_gas
enriched_uranium = reduce $ input 40 precious_metals ++ input 40 toxic_metals
miniature_electronics = reduce $ input 40 chiral_structures ++ input 40 silicon
proteins = reduce $ input 3000 complex_organisms
silicon = reduce $ input 3000 felsic_magma
electrolytes = reduce $ input 3000 ionic_solutions
biomass = reduce $ input 3000 planktic_colonies
smartfab_units = reduce $ input 10 construction_blocks ++ input 10 miniature_electronics
nanites = reduce $ input 40 reactive_metals ++ input 40 bacteria
polytextiles = reduce $ input 40 biofuels ++ input 40 industrial_fibers
chiral_structures = reduce $ input 3000 non_cs_crystals
precious_metals = reduce $ input 3000 noble_metals
microfiber_shielding = reduce $ input 40 silicon ++ input 40 industrial_fibers
mechanical_parts = reduce $ input 40 precious_metals ++ input 40 reactive_metals
toxic_metals = reduce $ input 3000 heavy_metals
test_cultures = reduce $ input 40 bacteria ++ input 40 water
synthetic_oil = reduce $ input 40 electrolytes ++ input 40 oxygen
oxides = reduce $ input 40 oxygen ++ input 40 oxidizing_compound
reactive_metals = reduce $ input 3000 base_metals
biocells = reduce $ input 40 precious_metals ++ input 40 biofuels
oxygen = reduce $ input 3000 noble_gas
water = reduce $ input 3000 aqueous_liquids
transmitter = reduce $ input 40 plasmoids ++ input 40 chiral_structures
bacteria = reduce $ input 3000 microorganisms
biofuels = reduce $ input 3000 carbon_compounds
water_cooled_cpu = reduce $ input 40 water ++ input 40 reactive_metals
fertilizer = reduce $ input 40 proteins ++ input 40 bacteria
genetically_enhanced_livestock = reduce $ input 40 proteins ++ input 40 biomass
consumer_electronics = reduce $ input 40 chiral_structures ++ input 40 toxic_metals
biotech_research_reports = reduce $ input 10 construction_blocks ++ input 10 livestock ++ input 10 nanites
ukomi_superconductors = reduce $ input 10 superconductors ++ input 10 synthetic_oil
silicate_glass = reduce $ input 40 oxidizing_compound ++ input 40 silicon
industrial_explosives = reduce $ input 10 fertilizer ++ input 10 polytextiles
guidance_systems = reduce $ input 10 transmitter ++ input 10 water_cooled_cpu
condensates = reduce $ input 10 coolant ++ input 10 oxides
planetary_vehicles = reduce $ input 10 mechanical_parts ++ input 10 miniature_electronics ++ input 10 supertensile_plastics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment