src/HOL/List.thy
changeset 21079 747d716e98d0
parent 21061 580dfc999ef6
child 21103 367b4ad7c7cc
equal deleted inserted replaced
21078:101aefd61aac 21079:747d716e98d0
  2646   (Haskell infixl 4 "==")
  2646   (Haskell infixl 4 "==")
  2647 
  2647 
  2648 code_const "Code_Generator.eq \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
  2648 code_const "Code_Generator.eq \<Colon> char \<Rightarrow> char \<Rightarrow> bool"
  2649   (Haskell infixl 4 "==")
  2649   (Haskell infixl 4 "==")
  2650 
  2650 
       
  2651 code_reserved SML
       
  2652   list char
       
  2653 
       
  2654 code_reserved Haskell
       
  2655   Char
       
  2656 
  2651 setup {*
  2657 setup {*
  2652 let
  2658 let
  2653 
  2659 
  2654 fun list_codegen thy defs gr dep thyname b t =
  2660 fun list_codegen thy defs gr dep thyname b t =
  2655   let val (gr', ps) = foldl_map (Codegen.invoke_codegen thy defs dep thyname false)
  2661   let val (gr', ps) = foldl_map (Codegen.invoke_codegen thy defs dep thyname false)
  2680 
  2686 
  2681 
  2687 
  2682 subsubsection {* Generation of efficient code *}
  2688 subsubsection {* Generation of efficient code *}
  2683 
  2689 
  2684 consts
  2690 consts
  2685   mem :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" (infixl 55)
  2691   memberl :: "'a \<Rightarrow> 'a list \<Rightarrow> bool" (infixl "mem" 55)
  2686   null:: "'a list \<Rightarrow> bool"
  2692   null:: "'a list \<Rightarrow> bool"
  2687   list_inter :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
  2693   list_inter :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
  2688   list_ex :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool"
  2694   list_ex :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> bool"
  2689   list_all :: "('a \<Rightarrow> bool) \<Rightarrow> ('a list \<Rightarrow> bool)"
  2695   list_all :: "('a \<Rightarrow> bool) \<Rightarrow> ('a list \<Rightarrow> bool)"
  2690   itrev :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
  2696   itrev :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
  2691   filtermap :: "('a \<Rightarrow> 'b option) \<Rightarrow> 'a list \<Rightarrow> 'b list"
  2697   filtermap :: "('a \<Rightarrow> 'b option) \<Rightarrow> 'a list \<Rightarrow> 'b list"
  2692   map_filter :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> 'b list"
  2698   map_filter :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> 'b list"
  2693 
  2699 
  2694 primrec
  2700 primrec
  2695   "x mem [] = False"
  2701   "x mem [] = False"
  2696   "x mem (y#ys) = (if y = x then True else x mem ys)"
  2702   "x mem (y#ys) = (x = y \<or> x mem ys)"
  2697 
  2703 
  2698 primrec
  2704 primrec
  2699   "null [] = True"
  2705   "null [] = True"
  2700   "null (x#xs) = False"
  2706   "null (x#xs) = False"
  2701 
  2707