equal
deleted
inserted
replaced
343 |
343 |
344 lemma array_make: |
344 lemma array_make: |
345 "new n x = make n (\<lambda>_. x)" |
345 "new n x = make n (\<lambda>_. x)" |
346 by (rule Heap_eqI) (simp add: map_replicate_trivial execute_simps) |
346 by (rule Heap_eqI) (simp add: map_replicate_trivial execute_simps) |
347 |
347 |
348 lemma array_of_list_make: |
348 lemma array_of_list_make [code]: |
349 "of_list xs = make (List.length xs) (\<lambda>n. xs ! n)" |
349 "of_list xs = make (List.length xs) (\<lambda>n. xs ! n)" |
350 by (rule Heap_eqI) (simp add: map_nth execute_simps) |
350 by (rule Heap_eqI) (simp add: map_nth execute_simps) |
351 |
351 |
352 hide_const (open) present get set alloc length update noteq new of_list make len nth upd map_entry swap freeze |
352 hide_const (open) present get set alloc length update noteq new of_list make len nth upd map_entry swap freeze |
353 |
353 |
480 code_const Array.upd' (Haskell "Heap.writeArray") |
480 code_const Array.upd' (Haskell "Heap.writeArray") |
481 |
481 |
482 |
482 |
483 text {* Scala *} |
483 text {* Scala *} |
484 |
484 |
485 code_type array (Scala "!Array[_]") |
485 code_type array (Scala "!collection.mutable.ArraySeq[_]") |
486 code_const Array (Scala "!error(\"bare Array\")") |
486 code_const Array (Scala "!error(\"bare Array\")") |
487 code_const Array.new' (Scala "('_: Unit)/ => / Array.fill((_))((_))") |
487 code_const Array.new' (Scala "('_: Unit)/ => / collection.mutable.ArraySeq.fill((_))((_))") |
488 code_const Array.of_list (Scala "('_: Unit)/ =>/ _.toArray") |
488 code_const Array.make' (Scala "('_: Unit)/ =>/ collection.mutable.ArraySeq.tabulate((_))((_))") |
489 code_const Array.make' (Scala "('_: Unit)/ =>/ Array.tabulate((_),/ (_))") |
|
490 code_const Array.len' (Scala "('_: Unit)/ =>/ _.length") |
489 code_const Array.len' (Scala "('_: Unit)/ =>/ _.length") |
491 code_const Array.nth' (Scala "('_: Unit)/ =>/ _((_))") |
490 code_const Array.nth' (Scala "('_: Unit)/ =>/ _((_))") |
492 code_const Array.upd' (Scala "('_: Unit)/ =>/ _.update((_),/ (_))") |
491 code_const Array.upd' (Scala "('_: Unit)/ =>/ _.update((_),/ (_))") |
493 code_const Array.freeze (Scala "('_: Unit)/ =>/ _.toList") |
492 code_const Array.freeze (Scala "('_: Unit)/ =>/ _.toList") |
494 |
493 |