Skip to content

Commit

Permalink
Add prefectures
Browse files Browse the repository at this point in the history
  • Loading branch information
malaise committed Dec 11, 2023
1 parent c05d4f8 commit 9850d3b
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 9 deletions.
104 changes: 104 additions & 0 deletions usr/mcd/departements.dat
@@ -1,202 +1,306 @@
01
Ain
Bourg-en-Bresse
02
Aisne
Laon
03
Alliers
Moulins
04
Alpes-de-Haute-Provence
Digne-les-Bains
05
Hautes-Alpes
Gap
06
Alpes-Maritimes
Nice
07
Ardèche
Privas
08
Ardennes
Charleville-Mézières
09
Ariège
Foix
10
Aube
Troyes
11
Aude
Carcassonne
12
Aveyron
Rodez
13
Bouches-du-Rhône
Marseille
14
Calvados
Caen
15
Cantal
Aurillac
16
Charente
Angoulême
17
Charente-Maritime
La Rochelle
18
Cher
Bourges
19
Corrèze
Tulle
2A
Corse-du-Sud
Ajaccio
2B
Haute-Corse
Bastia
21
Côte-d'Or
Dijon
22
Cotes-d'Armor
Saint-Brieuc
23
Creuse
Guéret
24
Dordogne
Périgueux
25
Doubs
Besançon
26
Drôme
Valence
27
Eure
Évreux
28
Eure-et-Loir
Chartres
29
Finistère
Quimper
30
Gard
Nîmes
31
Haute-Garonne
Toulouse
32
Gers
Auch
33
Gironde
Bordeaux
34
Hérault
Montpellier
35
Ille-et-Vilaine
Rennes
36
Indre
Châteauroux
37
Indre-et-Loire
Tours
38
Isère
Grenoble
39
Jura
Lons-le-Saunier
40
Landes
Mont-de-Marsan
41
Loir-et-Cher
Blois
42
Loire
Saint-Étienne
43
Haute-Loire
Le Puy-en-Velay
44
Loire-Atlantique
Nantes
45
Loiret
Orléans
46
Lot
Cahors
47
Lot-et-Garonne
Agen
48
Lozère
Mende
49
Maine-et-Loire
Angers
50
Manche
Saint-Lô
51
Marne
Châlons-en-Champagne
52
Haute-Marne
Chaumont
53
Mayenne
Laval
54
Meurthe-et-Moselle
Nancy
55
Meuse
Bar-le-Duc
56
Morbillan
Vannes
57
Moselle
Metz
58
Nièvre
Nevers
59
Nord
Lille
60
Oise
Beauvais
61
Orne
Alençon
62
Pas-de-Calais
Arras
63
Puy-de-Dôme
Clermont-Ferrand
64
Pyrénées-Atlantiques
Peau
65
Hautes-Pyrénées
Tarbes
66
Pyrénées-Orientales
Perpignan
67
Bas-Rhin
Strasbourg
68
Haut-Rhin
Colmar
69
Rhône
Lyon
70
Haute-Saône
Vesoul
71
Saône-et-Loire
Mâcon
72
Sarthe
Le Mans
73
Savoie
Chambéry
74
Haute-Savoie
Annecy
75
Paris
Paris
76
Seine-Maritime
Rouen
77
Seine-et-Marne
Melun
78
Yvelines
Versailles
79
Deux-Sèvres
Niort
80
Somme
AMiens
81
Tarn
Albi
82
Tarn-et-Garonne
Maontaubon
83
Var
Toulon
84
Vaucluse
Avignon
85
Vendée
La Roche-sur-Yon
86
Vienne
Poitiers
87
Haute-Vienne
Limoges
88
Vosges
Épinal
89
Yonne
Auxerre
90
Territoire de Belfort
Belfort
91
Essonne
Évry-Courcouronnes
92
Hauts-de-Seine
Nanterre
93
Seine-Saint-Denis
Bobigny
94
Val-de-Marne
Créteil
95
Val-d'Oise
Cergy
971
Guadeloupe
Basse-Terre
972
Martinique
Fort-de-France
973
Guyanne
Cayenne
974
La Réunion
Saint-Denis
975
Saint-Pierre-et-Miquelon
Saint-Pierre
976
Mayotte
Mamoudzou
28 changes: 19 additions & 9 deletions usr/mcd/departements.mcd
@@ -1,6 +1,7 @@
# Select a random departement number
# 1..19 2A 2B 21..95 971..974 976
# Put it for some seconds then put its name, then wait for Enter, loop
# Put it for some seconds then put its name and prefecture,
# then wait for Enter, loop

# Input key will not echo
isstdio ~ [ false inecho ] ifcall
Expand All @@ -18,21 +19,25 @@ isstdio ~ [ false inecho ] ifcall
dup isinte ~ [ "ERROR: data file not read" putl pop retall ] ifcall
# Number of entries must be evena and > 0
dup 0 = [ "ERROR: empty data file" putl pop retall ] ifcall
dup 2 % 0 = ~ [ "ERROR: invalid data file" putl ssize popn retall ] ifcall
2 / N popr
dup 3 % 0 = ~ [ "ERROR: invalid data file" putl ssize popn retall ] ifcall
3 / N popr

1
# Store a department: number in n[Index] and name in N[Index]
# Store a department: number in n[Index], name in N[Index]
# and prefecture in P[Index]
# Stop after storing Index = N
# Input stack is: Index "Num" "Name", output stack is Index + 1
[
# Save index
i copyr
# Store num
n swap popa
# Store num
# Store name
i pushr
N swap popa
# Store prefecture
i pushr
P swap popa
# Stop after inserting Nth pair
i pushr copye N pushr = ifret
# Increment index
Expand All @@ -41,10 +46,11 @@ i pushr 1 +
S pushr retacal
] S copyr call

# Dump: Index Number Name (used for debug)
# Dump: Index Number Name Prefecture (used for debug)
3 format
[
dup put " " put dup n swap pusha put " " put dup N swap pusha putl
dup put " " put dup n swap pusha put " " put dup N swap pusha put " " put
dup P swap pusha putl
# Stop loop after putting index N
dup N pushr = ifret
# Increment index
Expand All @@ -59,8 +65,12 @@ D pushr retacal ] D popr
rnd N pushr toreal * trunc 1 +
# Put its Num during some seconds or any input
dup n swap pusha put ": " put a pushr I pushr call
# Put its Name and wait for some seconds or any input
N swap pusha putl b pushr I pushr call
# Put its Name and Prefecture
dup N swap pusha put " -> " put
P swap pusha putl
# Wait for some seconds or any input
b pushr I pushr call

# Loop
M pushr retacal ] M copyr call

0 comments on commit 9850d3b

Please sign in to comment.