{ meth Vec fmap:
    "Goldberg & Robson, 1989. p215"
    nc= / cls new .
    / do: [ x .
      nc ap: ( a runArg: x ) ] .
    nc
}

{ meth Vec select:
    "Goldberg & Robson, 1989. p216"
    nc= / cls new .
    / do: [ x .
      ( a runArg: x ) ye: [
        nc ap: x ] ] .
    nc
}

{ class App Usr }
{ class TopApp App }

{ meth TopApp handle:
  "Default class for handling '/'."

  Map new  at: 'type' pu: 'list'
  	, at 'title' pu a
  	, at 'value' pu [
	  [ 'link:/Browse:Browse' . 'Browse Classes.' ] vec
	  [ 'link:/Cls:Cls' . 'The class named <Cls>.' ] vec
	] vec
	.
}

{ class Browse App }
{ meth Browse handle:
  ww= a spli: '[.]' .  "It's a regexp."
  wl= ww len .
  gm= Sys globalMap .

  v= [ [ 'link:/:UP' . 'UP to TOP.' ] vec ] vec .  "The List."
  gk= gm keys_ select: [ i . AND{ gm at: i , cls nam ends: 'Cls' . gm at: i , nam ends: 'Cls' , not } ] . "good keys"
  gk do: [ k .
      kc= gm at: k .
      kn= kc nam .
      v ap: [ ( 'link:/Browse.' ap: kn , ap: ':' , ap: kn ) . kc meths str . ] vec .
      ] .

  ( wl eq: 1 ) ye: [
    z= Map new  at: 'type' pu: 'list'
  	, at 'title' pu 'Browsing All Classes'
  	, at 'extra' pu ( gm )
  	, at 'extraKeys' pu ( gm keys_ )
  	, at 'extraFmap' pu ( gm keys_ fmap: [ i . ( gm at: i ) cls cls nam ] )
  	, at 'extraSelect' pu gk
  	, at 'value' pu v
	.
  ] .
  
  ( wl eq: 2 ) ye: [
    cn= ww at: 1 .
    z= Map new  at: 'type' pu: 'list'
  	, at 'title' pu ( 'Browsing Class' ap: cn )
  	, at 'extra' pu ( Sys globalMap )
  	, at 'value' pu [
	  [ 'link:/Browse:Browse' . 'Browse Classes.' ] vec
	] vec
	.
  ] .
  z .
}
