arctrl 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arctrl/__init__.py +23 -0
- arctrl/cwl.py +12 -0
- arctrl/py/CWL/__init__.py +0 -0
- arctrl/py/CWL/cwlprocessing_unit.py +221 -0
- arctrl/py/CWL/cwltypes.py +364 -0
- arctrl/py/CWL/decode.py +3532 -0
- arctrl/py/CWL/encode.py +1905 -0
- arctrl/py/CWL/expression_tool_description.py +192 -0
- arctrl/py/CWL/hash_helpers.py +60 -0
- arctrl/py/CWL/inputs.py +122 -0
- arctrl/py/CWL/operation_description.py +169 -0
- arctrl/py/CWL/outputs.py +171 -0
- arctrl/py/CWL/parameter_reference.py +74 -0
- arctrl/py/CWL/requirements.py +350 -0
- arctrl/py/CWL/tool_description.py +192 -0
- arctrl/py/CWL/workflow_description.py +181 -0
- arctrl/py/CWL/workflow_steps.py +354 -0
- arctrl/py/Contract/__init__.py +0 -0
- arctrl/py/Contract/arc.py +89 -0
- arctrl/py/Contract/arc_assay.py +125 -0
- arctrl/py/Contract/arc_investigation.py +88 -0
- arctrl/py/Contract/arc_run.py +291 -0
- arctrl/py/Contract/arc_study.py +126 -0
- arctrl/py/Contract/arc_workflow.py +213 -0
- arctrl/py/Contract/contract.py +153 -0
- arctrl/py/Contract/datamap.py +396 -0
- arctrl/py/Contract/git.py +116 -0
- arctrl/py/Contract/license.py +58 -0
- arctrl/py/Contract/validation_packages_config.py +107 -0
- arctrl/py/ContractIO/__init__.py +0 -0
- arctrl/py/ContractIO/contract_io.py +350 -0
- arctrl/py/ContractIO/file_system_helper.py +264 -0
- arctrl/py/Conversion/__init__.py +0 -0
- arctrl/py/Conversion/assay.py +151 -0
- arctrl/py/Conversion/basic.py +559 -0
- arctrl/py/Conversion/column_index.py +91 -0
- arctrl/py/Conversion/datamap.py +36 -0
- arctrl/py/Conversion/date_time.py +32 -0
- arctrl/py/Conversion/investigation.py +171 -0
- arctrl/py/Conversion/person.py +148 -0
- arctrl/py/Conversion/process.py +828 -0
- arctrl/py/Conversion/run.py +367 -0
- arctrl/py/Conversion/scholarly_article.py +163 -0
- arctrl/py/Conversion/study.py +99 -0
- arctrl/py/Conversion/table.py +229 -0
- arctrl/py/Conversion/workflow.py +680 -0
- arctrl/py/Core/Helper/__init__.py +0 -0
- arctrl/py/Core/Helper/collections_.py +512 -0
- arctrl/py/Core/Helper/date_time.py +26 -0
- arctrl/py/Core/Helper/hash_codes.py +60 -0
- arctrl/py/Core/Helper/identifier.py +290 -0
- arctrl/py/Core/Helper/orcid.py +42 -0
- arctrl/py/Core/Helper/printer.py +13 -0
- arctrl/py/Core/Helper/regex.py +554 -0
- arctrl/py/Core/Helper/sem_ver.py +71 -0
- arctrl/py/Core/Helper/url.py +148 -0
- arctrl/py/Core/Process/__init__.py +0 -0
- arctrl/py/Core/Process/column_index.py +280 -0
- arctrl/py/Core/Process/component.py +200 -0
- arctrl/py/Core/Process/factor.py +151 -0
- arctrl/py/Core/Process/factor_value.py +182 -0
- arctrl/py/Core/Process/material.py +74 -0
- arctrl/py/Core/Process/material_attribute.py +95 -0
- arctrl/py/Core/Process/material_attribute_value.py +184 -0
- arctrl/py/Core/Process/material_type.py +45 -0
- arctrl/py/Core/Process/process.py +477 -0
- arctrl/py/Core/Process/process_input.py +265 -0
- arctrl/py/Core/Process/process_output.py +235 -0
- arctrl/py/Core/Process/process_parameter_value.py +200 -0
- arctrl/py/Core/Process/process_sequence.py +435 -0
- arctrl/py/Core/Process/protocol.py +175 -0
- arctrl/py/Core/Process/protocol_parameter.py +98 -0
- arctrl/py/Core/Process/sample.py +82 -0
- arctrl/py/Core/Process/source.py +62 -0
- arctrl/py/Core/Table/__init__.py +0 -0
- arctrl/py/Core/Table/arc_table.py +1206 -0
- arctrl/py/Core/Table/arc_table_aux.py +1308 -0
- arctrl/py/Core/Table/arc_tables.py +574 -0
- arctrl/py/Core/Table/composite_cell.py +319 -0
- arctrl/py/Core/Table/composite_column.py +73 -0
- arctrl/py/Core/Table/composite_header.py +739 -0
- arctrl/py/Core/__init__.py +0 -0
- arctrl/py/Core/arc_types.py +5312 -0
- arctrl/py/Core/comment.py +128 -0
- arctrl/py/Core/comment_list.py +127 -0
- arctrl/py/Core/conversion.py +1375 -0
- arctrl/py/Core/data.py +247 -0
- arctrl/py/Core/data_context.py +157 -0
- arctrl/py/Core/data_file.py +112 -0
- arctrl/py/Core/datamap.py +217 -0
- arctrl/py/Core/identifier_setters.py +43 -0
- arctrl/py/Core/iproperty_value.py +36 -0
- arctrl/py/Core/ontology_annotation.py +298 -0
- arctrl/py/Core/ontology_source_reference.py +114 -0
- arctrl/py/Core/person.py +259 -0
- arctrl/py/Core/publication.py +161 -0
- arctrl/py/Core/template.py +231 -0
- arctrl/py/Core/templates.py +148 -0
- arctrl/py/Core/uri.py +11 -0
- arctrl/py/Core/value.py +188 -0
- arctrl/py/FileSystem/__init__.py +0 -0
- arctrl/py/FileSystem/commit.py +21 -0
- arctrl/py/FileSystem/default_gitattributes.py +1 -0
- arctrl/py/FileSystem/default_gitignore.py +1 -0
- arctrl/py/FileSystem/default_license.py +1 -0
- arctrl/py/FileSystem/file_system.py +58 -0
- arctrl/py/FileSystem/file_system_tree.py +483 -0
- arctrl/py/FileSystem/path.py +266 -0
- arctrl/py/Json/Datamap/__init__.py +0 -0
- arctrl/py/Json/Datamap/data_context.py +101 -0
- arctrl/py/Json/Datamap/datamap.py +53 -0
- arctrl/py/Json/Process/__init__.py +0 -0
- arctrl/py/Json/Process/assay_materials.py +46 -0
- arctrl/py/Json/Process/component.py +125 -0
- arctrl/py/Json/Process/factor.py +107 -0
- arctrl/py/Json/Process/factor_value.py +101 -0
- arctrl/py/Json/Process/material.py +226 -0
- arctrl/py/Json/Process/material_attribute.py +79 -0
- arctrl/py/Json/Process/material_attribute_value.py +101 -0
- arctrl/py/Json/Process/material_type.py +53 -0
- arctrl/py/Json/Process/process.py +296 -0
- arctrl/py/Json/Process/process_input.py +83 -0
- arctrl/py/Json/Process/process_output.py +67 -0
- arctrl/py/Json/Process/process_parameter_value.py +81 -0
- arctrl/py/Json/Process/protocol.py +354 -0
- arctrl/py/Json/Process/protocol_parameter.py +91 -0
- arctrl/py/Json/Process/sample.py +277 -0
- arctrl/py/Json/Process/source.py +214 -0
- arctrl/py/Json/Process/study_materials.py +52 -0
- arctrl/py/Json/Process/value.py +56 -0
- arctrl/py/Json/ROCrate/__init__.py +0 -0
- arctrl/py/Json/ROCrate/ldcontext.py +143 -0
- arctrl/py/Json/ROCrate/ldgraph.py +117 -0
- arctrl/py/Json/ROCrate/ldnode.py +304 -0
- arctrl/py/Json/ROCrate/ldref.py +44 -0
- arctrl/py/Json/ROCrate/ldvalue.py +102 -0
- arctrl/py/Json/Table/__init__.py +0 -0
- arctrl/py/Json/Table/arc_table.py +375 -0
- arctrl/py/Json/Table/cell_table.py +83 -0
- arctrl/py/Json/Table/composite_cell.py +136 -0
- arctrl/py/Json/Table/composite_header.py +67 -0
- arctrl/py/Json/Table/iotype.py +24 -0
- arctrl/py/Json/Table/oatable.py +82 -0
- arctrl/py/Json/Table/templates.py +281 -0
- arctrl/py/Json/__init__.py +0 -0
- arctrl/py/Json/assay.py +600 -0
- arctrl/py/Json/comment.py +206 -0
- arctrl/py/Json/context/rocrate/__init__.py +0 -0
- arctrl/py/Json/context/rocrate/isa_assay_context.py +101 -0
- arctrl/py/Json/context/rocrate/isa_comment_context.py +60 -0
- arctrl/py/Json/context/rocrate/isa_component_context.py +77 -0
- arctrl/py/Json/context/rocrate/isa_data_context.py +74 -0
- arctrl/py/Json/context/rocrate/isa_factor_context.py +74 -0
- arctrl/py/Json/context/rocrate/isa_factor_value_context.py +84 -0
- arctrl/py/Json/context/rocrate/isa_investigation_context.py +110 -0
- arctrl/py/Json/context/rocrate/isa_material_attribute_context.py +64 -0
- arctrl/py/Json/context/rocrate/isa_material_attribute_value_context.py +80 -0
- arctrl/py/Json/context/rocrate/isa_material_context.py +71 -0
- arctrl/py/Json/context/rocrate/isa_ontology_annotation_context.py +68 -0
- arctrl/py/Json/context/rocrate/isa_ontology_source_reference_context.py +75 -0
- arctrl/py/Json/context/rocrate/isa_organization_context.py +55 -0
- arctrl/py/Json/context/rocrate/isa_person_context.py +131 -0
- arctrl/py/Json/context/rocrate/isa_process_context.py +94 -0
- arctrl/py/Json/context/rocrate/isa_process_parameter_value_context.py +80 -0
- arctrl/py/Json/context/rocrate/isa_protocol_context.py +97 -0
- arctrl/py/Json/context/rocrate/isa_protocol_parameter_context.py +64 -0
- arctrl/py/Json/context/rocrate/isa_publication_context.py +78 -0
- arctrl/py/Json/context/rocrate/isa_sample_context.py +65 -0
- arctrl/py/Json/context/rocrate/isa_source_context.py +66 -0
- arctrl/py/Json/context/rocrate/isa_study_context.py +125 -0
- arctrl/py/Json/context/rocrate/property_value_context.py +73 -0
- arctrl/py/Json/context/rocrate/rocrate_context.py +81 -0
- arctrl/py/Json/converter_options.py +23 -0
- arctrl/py/Json/data.py +356 -0
- arctrl/py/Json/data_file.py +63 -0
- arctrl/py/Json/decode.py +271 -0
- arctrl/py/Json/encode.py +140 -0
- arctrl/py/Json/idtable.py +44 -0
- arctrl/py/Json/investigation.py +695 -0
- arctrl/py/Json/ontology_annotation.py +404 -0
- arctrl/py/Json/ontology_source_reference.py +255 -0
- arctrl/py/Json/person.py +658 -0
- arctrl/py/Json/property_value.py +359 -0
- arctrl/py/Json/publication.py +279 -0
- arctrl/py/Json/run.py +275 -0
- arctrl/py/Json/string_table.py +87 -0
- arctrl/py/Json/study.py +793 -0
- arctrl/py/Json/workflow.py +307 -0
- arctrl/py/JsonIO/Process/__init__.py +0 -0
- arctrl/py/JsonIO/Process/component.py +60 -0
- arctrl/py/JsonIO/Process/factor.py +36 -0
- arctrl/py/JsonIO/Process/factor_value.py +38 -0
- arctrl/py/JsonIO/Process/material.py +60 -0
- arctrl/py/JsonIO/Process/material_attribute.py +38 -0
- arctrl/py/JsonIO/Process/material_attribute_value.py +60 -0
- arctrl/py/JsonIO/Process/material_type.py +36 -0
- arctrl/py/JsonIO/Process/process.py +60 -0
- arctrl/py/JsonIO/Process/process_input.py +38 -0
- arctrl/py/JsonIO/Process/process_output.py +60 -0
- arctrl/py/JsonIO/Process/process_parameter_value.py +60 -0
- arctrl/py/JsonIO/Process/process_sequence.py +71 -0
- arctrl/py/JsonIO/Process/protocol.py +60 -0
- arctrl/py/JsonIO/Process/protocol_parameter.py +36 -0
- arctrl/py/JsonIO/Process/sample.py +60 -0
- arctrl/py/JsonIO/Process/source.py +60 -0
- arctrl/py/JsonIO/Process/study_materials.py +52 -0
- arctrl/py/JsonIO/Process/value.py +32 -0
- arctrl/py/JsonIO/Table/__init__.py +0 -0
- arctrl/py/JsonIO/Table/arc_table.py +103 -0
- arctrl/py/JsonIO/Table/composite_cell.py +36 -0
- arctrl/py/JsonIO/Table/composite_header.py +36 -0
- arctrl/py/JsonIO/Table/compression.py +67 -0
- arctrl/py/JsonIO/Table/iotype.py +36 -0
- arctrl/py/JsonIO/Table/templates.py +113 -0
- arctrl/py/JsonIO/__init__.py +0 -0
- arctrl/py/JsonIO/assay.py +113 -0
- arctrl/py/JsonIO/comment.py +80 -0
- arctrl/py/JsonIO/data.py +60 -0
- arctrl/py/JsonIO/data_file.py +58 -0
- arctrl/py/JsonIO/datamap.py +36 -0
- arctrl/py/JsonIO/decode.py +9 -0
- arctrl/py/JsonIO/encode.py +1 -0
- arctrl/py/JsonIO/investigation.py +91 -0
- arctrl/py/JsonIO/ldobject.py +106 -0
- arctrl/py/JsonIO/ontology_annotation.py +80 -0
- arctrl/py/JsonIO/ontology_source_reference.py +80 -0
- arctrl/py/JsonIO/person.py +82 -0
- arctrl/py/JsonIO/publication.py +82 -0
- arctrl/py/JsonIO/run.py +68 -0
- arctrl/py/JsonIO/study.py +114 -0
- arctrl/py/JsonIO/workflow.py +68 -0
- arctrl/py/ROCrate/ISAProfile/__init__.py +0 -0
- arctrl/py/ROCrate/ISAProfile/assay.py +70 -0
- arctrl/py/ROCrate/ISAProfile/data.py +65 -0
- arctrl/py/ROCrate/ISAProfile/dataset.py +24 -0
- arctrl/py/ROCrate/ISAProfile/investigation.py +73 -0
- arctrl/py/ROCrate/ISAProfile/lab_process.py +162 -0
- arctrl/py/ROCrate/ISAProfile/lab_protocol.py +37 -0
- arctrl/py/ROCrate/ISAProfile/person.py +72 -0
- arctrl/py/ROCrate/ISAProfile/property_value.py +98 -0
- arctrl/py/ROCrate/ISAProfile/sample.py +64 -0
- arctrl/py/ROCrate/ISAProfile/scholarly_article.py +98 -0
- arctrl/py/ROCrate/ISAProfile/study.py +74 -0
- arctrl/py/ROCrate/LDTypes/__init__.py +0 -0
- arctrl/py/ROCrate/LDTypes/comment.py +131 -0
- arctrl/py/ROCrate/LDTypes/computational_workflow.py +455 -0
- arctrl/py/ROCrate/LDTypes/computer_language.py +269 -0
- arctrl/py/ROCrate/LDTypes/create_action.py +303 -0
- arctrl/py/ROCrate/LDTypes/creative_work.py +566 -0
- arctrl/py/ROCrate/LDTypes/dataset.py +943 -0
- arctrl/py/ROCrate/LDTypes/defined_term.py +131 -0
- arctrl/py/ROCrate/LDTypes/file.py +281 -0
- arctrl/py/ROCrate/LDTypes/formal_parameter.py +431 -0
- arctrl/py/ROCrate/LDTypes/lab_process.py +352 -0
- arctrl/py/ROCrate/LDTypes/lab_protocol.py +395 -0
- arctrl/py/ROCrate/LDTypes/organization.py +83 -0
- arctrl/py/ROCrate/LDTypes/person.py +484 -0
- arctrl/py/ROCrate/LDTypes/postal_address.py +195 -0
- arctrl/py/ROCrate/LDTypes/property_value.py +952 -0
- arctrl/py/ROCrate/LDTypes/sample.py +202 -0
- arctrl/py/ROCrate/LDTypes/scholarly_article.py +229 -0
- arctrl/py/ROCrate/LDTypes/software_source_code.py +310 -0
- arctrl/py/ROCrate/LDTypes/workflow_invocation.py +48 -0
- arctrl/py/ROCrate/LDTypes/workflow_protocol.py +52 -0
- arctrl/py/ROCrate/__init__.py +0 -0
- arctrl/py/ROCrate/arc_rocrate_metadata.py +39 -0
- arctrl/py/ROCrate/dyn_obj_extensions.py +1 -0
- arctrl/py/ROCrate/helper.py +8 -0
- arctrl/py/ROCrate/ldcontext.py +406 -0
- arctrl/py/ROCrate/ldobject.py +1247 -0
- arctrl/py/ROCrate/rocrate_context.py +51 -0
- arctrl/py/Spreadsheet/AnnotationTable/__init__.py +0 -0
- arctrl/py/Spreadsheet/AnnotationTable/arc_table.py +203 -0
- arctrl/py/Spreadsheet/AnnotationTable/composite_cell.py +78 -0
- arctrl/py/Spreadsheet/AnnotationTable/composite_column.py +305 -0
- arctrl/py/Spreadsheet/AnnotationTable/composite_header.py +623 -0
- arctrl/py/Spreadsheet/DatamapTable/__init__.py +0 -0
- arctrl/py/Spreadsheet/DatamapTable/datamap_column.py +114 -0
- arctrl/py/Spreadsheet/DatamapTable/datamap_header.py +621 -0
- arctrl/py/Spreadsheet/DatamapTable/datamap_table.py +118 -0
- arctrl/py/Spreadsheet/Metadata/__init__.py +0 -0
- arctrl/py/Spreadsheet/Metadata/assays.py +125 -0
- arctrl/py/Spreadsheet/Metadata/comment.py +77 -0
- arctrl/py/Spreadsheet/Metadata/contacts.py +134 -0
- arctrl/py/Spreadsheet/Metadata/conversions.py +190 -0
- arctrl/py/Spreadsheet/Metadata/design_descriptors.py +34 -0
- arctrl/py/Spreadsheet/Metadata/factors.py +107 -0
- arctrl/py/Spreadsheet/Metadata/ontology_annotation.py +88 -0
- arctrl/py/Spreadsheet/Metadata/ontology_source_reference.py +96 -0
- arctrl/py/Spreadsheet/Metadata/protocols.py +146 -0
- arctrl/py/Spreadsheet/Metadata/publication.py +122 -0
- arctrl/py/Spreadsheet/Metadata/run.py +122 -0
- arctrl/py/Spreadsheet/Metadata/sparse_table.py +499 -0
- arctrl/py/Spreadsheet/Metadata/study.py +312 -0
- arctrl/py/Spreadsheet/Metadata/workflow.py +159 -0
- arctrl/py/Spreadsheet/__init__.py +0 -0
- arctrl/py/Spreadsheet/arc_assay.py +233 -0
- arctrl/py/Spreadsheet/arc_investigation.py +435 -0
- arctrl/py/Spreadsheet/arc_run.py +190 -0
- arctrl/py/Spreadsheet/arc_study.py +144 -0
- arctrl/py/Spreadsheet/arc_workflow.py +177 -0
- arctrl/py/Spreadsheet/assembly_info.py +1 -0
- arctrl/py/Spreadsheet/collection_aux.py +167 -0
- arctrl/py/Spreadsheet/datamap.py +43 -0
- arctrl/py/Spreadsheet/template.py +460 -0
- arctrl/py/ValidationPackages/__init__.py +0 -0
- arctrl/py/ValidationPackages/validation_package.py +82 -0
- arctrl/py/ValidationPackages/validation_packages_config.py +132 -0
- arctrl/py/WebRequest/__init__.py +0 -0
- arctrl/py/WebRequest/web_request.py +9 -0
- arctrl/py/WebRequest/web_request_py.py +135 -0
- arctrl/py/WorkflowGraph/__init__.py +0 -0
- arctrl/py/WorkflowGraph/adapters.py +141 -0
- arctrl/py/WorkflowGraph/build_options.py +45 -0
- arctrl/py/WorkflowGraph/builder.py +720 -0
- arctrl/py/WorkflowGraph/graph_types.py +260 -0
- arctrl/py/WorkflowGraph/query_helpers.py +76 -0
- arctrl/py/WorkflowGraph/reference_parsing.py +59 -0
- arctrl/py/WorkflowGraph/visualization_siren.py +574 -0
- arctrl/py/WorkflowGraph/workflow_graph.py +119 -0
- arctrl/py/Yaml/__init__.py +0 -0
- arctrl/py/Yaml/decode.py +1 -0
- arctrl/py/Yaml/encode.py +10 -0
- arctrl/py/Yaml/validation_package.py +77 -0
- arctrl/py/Yaml/validation_packages_config.py +86 -0
- arctrl/py/__init__.py +0 -0
- arctrl/py/arc.py +1891 -0
- arctrl/py/column_index.py +280 -0
- arctrl/py/conversion.py +142 -0
- arctrl/py/cross_async.py +76 -0
- arctrl/py/cwlrun_resolver.py +228 -0
- arctrl/py/fable_modules/dynamic_obj/__init__.py +0 -0
- arctrl/py/fable_modules/dynamic_obj/dyn_obj.py +136 -0
- arctrl/py/fable_modules/dynamic_obj/dynamic_obj.py +415 -0
- arctrl/py/fable_modules/dynamic_obj/fable_js.py +1 -0
- arctrl/py/fable_modules/dynamic_obj/fable_py.py +288 -0
- arctrl/py/fable_modules/dynamic_obj/hash_codes.py +82 -0
- arctrl/py/fable_modules/dynamic_obj/property_helper.py +25 -0
- arctrl/py/fable_modules/dynamic_obj/reflection_utils.py +87 -0
- arctrl/py/fable_modules/fable_library/__init__.py +0 -0
- arctrl/py/fable_modules/fable_library/array_.py +1528 -0
- arctrl/py/fable_modules/fable_library/async_.py +377 -0
- arctrl/py/fable_modules/fable_library/async_builder.py +379 -0
- arctrl/py/fable_modules/fable_library/big_int.py +330 -0
- arctrl/py/fable_modules/fable_library/bit_converter.py +131 -0
- arctrl/py/fable_modules/fable_library/boolean.py +26 -0
- arctrl/py/fable_modules/fable_library/char.py +237 -0
- arctrl/py/fable_modules/fable_library/choice.py +212 -0
- arctrl/py/fable_modules/fable_library/date.py +779 -0
- arctrl/py/fable_modules/fable_library/date_offset.py +79 -0
- arctrl/py/fable_modules/fable_library/decimal_.py +190 -0
- arctrl/py/fable_modules/fable_library/diagnostics.py +54 -0
- arctrl/py/fable_modules/fable_library/double.py +87 -0
- arctrl/py/fable_modules/fable_library/encoding.py +41 -0
- arctrl/py/fable_modules/fable_library/event.py +206 -0
- arctrl/py/fable_modules/fable_library/file.py +107 -0
- arctrl/py/fable_modules/fable_library/fsharp_collections.py +52 -0
- arctrl/py/fable_modules/fable_library/fsharp_core.py +123 -0
- arctrl/py/fable_modules/fable_library/global_.py +63 -0
- arctrl/py/fable_modules/fable_library/guid.py +41 -0
- arctrl/py/fable_modules/fable_library/int32.py +73 -0
- arctrl/py/fable_modules/fable_library/list.py +1788 -0
- arctrl/py/fable_modules/fable_library/long.py +240 -0
- arctrl/py/fable_modules/fable_library/mailbox_processor.py +179 -0
- arctrl/py/fable_modules/fable_library/map.py +1854 -0
- arctrl/py/fable_modules/fable_library/map_util.py +148 -0
- arctrl/py/fable_modules/fable_library/mutable_map.py +397 -0
- arctrl/py/fable_modules/fable_library/mutable_set.py +279 -0
- arctrl/py/fable_modules/fable_library/native.py +45 -0
- arctrl/py/fable_modules/fable_library/numeric.py +46 -0
- arctrl/py/fable_modules/fable_library/observable.py +222 -0
- arctrl/py/fable_modules/fable_library/option.py +128 -0
- arctrl/py/fable_modules/fable_library/path.py +62 -0
- arctrl/py/fable_modules/fable_library/range.py +117 -0
- arctrl/py/fable_modules/fable_library/reflection.py +463 -0
- arctrl/py/fable_modules/fable_library/reg_exp.py +137 -0
- arctrl/py/fable_modules/fable_library/resize_array.py +31 -0
- arctrl/py/fable_modules/fable_library/result.py +212 -0
- arctrl/py/fable_modules/fable_library/seq.py +1979 -0
- arctrl/py/fable_modules/fable_library/seq2.py +221 -0
- arctrl/py/fable_modules/fable_library/set.py +2414 -0
- arctrl/py/fable_modules/fable_library/singleton_local_time_zone.py +36 -0
- arctrl/py/fable_modules/fable_library/string_.py +573 -0
- arctrl/py/fable_modules/fable_library/system_collections_generic.py +462 -0
- arctrl/py/fable_modules/fable_library/system_text.py +237 -0
- arctrl/py/fable_modules/fable_library/task.py +116 -0
- arctrl/py/fable_modules/fable_library/task_builder.py +122 -0
- arctrl/py/fable_modules/fable_library/thread.py +5 -0
- arctrl/py/fable_modules/fable_library/time_span.py +283 -0
- arctrl/py/fable_modules/fable_library/timer.py +24 -0
- arctrl/py/fable_modules/fable_library/types.py +401 -0
- arctrl/py/fable_modules/fable_library/uri.py +109 -0
- arctrl/py/fable_modules/fable_library/util.py +2735 -0
- arctrl/py/fable_modules/fable_openpyxl/__init__.py +0 -0
- arctrl/py/fable_modules/fable_openpyxl/openpyxl.py +362 -0
- arctrl/py/fable_modules/fable_python/cognite-sdk/__init__.py +0 -0
- arctrl/py/fable_modules/fable_python/cognite-sdk/cognite_sdk.py +22 -0
- arctrl/py/fable_modules/fable_python/flask/__init__.py +0 -0
- arctrl/py/fable_modules/fable_python/flask/flask.py +34 -0
- arctrl/py/fable_modules/fable_python/jupyter/__init__.py +0 -0
- arctrl/py/fable_modules/fable_python/jupyter/ipy_widgets.py +47 -0
- arctrl/py/fable_modules/fable_python/jupyter/ipython.py +13 -0
- arctrl/py/fable_modules/fable_python/stdlib/__init__.py +0 -0
- arctrl/py/fable_modules/fable_python/stdlib/ast.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/asyncio/__init__.py +0 -0
- arctrl/py/fable_modules/fable_python/stdlib/asyncio/events.py +17 -0
- arctrl/py/fable_modules/fable_python/stdlib/asyncio/futures.py +52 -0
- arctrl/py/fable_modules/fable_python/stdlib/asyncio/tasks.py +38 -0
- arctrl/py/fable_modules/fable_python/stdlib/base64_.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/builtins_.py +38 -0
- arctrl/py/fable_modules/fable_python/stdlib/html.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/json.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/math_.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/os_.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/queue_.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/string_.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/sys_.py +30 -0
- arctrl/py/fable_modules/fable_python/stdlib/time_.py +1 -0
- arctrl/py/fable_modules/fable_python/stdlib/tk_inter.py +1 -0
- arctrl/py/fable_modules/fs_spreadsheet/Cells/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet/Cells/fs_cell.py +340 -0
- arctrl/py/fable_modules/fs_spreadsheet/Cells/fs_cells_collection.py +466 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/cell_builder.py +214 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/column_builder.py +139 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/dsl.py +50 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/expression.py +65 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/operators.py +9 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/row_builder.py +139 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/sheet_builder.py +118 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/table_builder.py +122 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/transform.py +463 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/types.py +314 -0
- arctrl/py/fable_modules/fs_spreadsheet/DSL/workbook_builder.py +106 -0
- arctrl/py/fable_modules/fs_spreadsheet/Json/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet/Json/cell.py +103 -0
- arctrl/py/fable_modules/fs_spreadsheet/Json/column.py +70 -0
- arctrl/py/fable_modules/fs_spreadsheet/Json/row.py +70 -0
- arctrl/py/fable_modules/fs_spreadsheet/Json/table.py +54 -0
- arctrl/py/fable_modules/fs_spreadsheet/Json/value.py +93 -0
- arctrl/py/fable_modules/fs_spreadsheet/Json/workbook.py +71 -0
- arctrl/py/fable_modules/fs_spreadsheet/Json/worksheet.py +216 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range.py +43 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_address.py +190 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_base.py +92 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_column.py +77 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_row.py +48 -0
- arctrl/py/fable_modules/fs_spreadsheet/Tables/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet/Tables/fs_table.py +461 -0
- arctrl/py/fable_modules/fs_spreadsheet/Tables/fs_table_field.py +117 -0
- arctrl/py/fable_modules/fs_spreadsheet/Tables/fs_table_row.py +23 -0
- arctrl/py/fable_modules/fs_spreadsheet/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet/fs_address.py +236 -0
- arctrl/py/fable_modules/fs_spreadsheet/fs_column.py +172 -0
- arctrl/py/fable_modules/fs_spreadsheet/fs_row.py +183 -0
- arctrl/py/fable_modules/fs_spreadsheet/fs_workbook.py +192 -0
- arctrl/py/fable_modules/fs_spreadsheet/fs_worksheet.py +610 -0
- arctrl/py/fable_modules/fs_spreadsheet/hash_codes.py +60 -0
- arctrl/py/fable_modules/fs_spreadsheet/sheet_builder.py +329 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/cell.py +60 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/cell_type.py +50 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/fs_extension.py +60 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/json.py +47 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/table.py +54 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/workbook.py +41 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/worksheet.py +52 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/xlsx.py +37 -0
- arctrl/py/fable_modules/siren/__init__.py +0 -0
- arctrl/py/fable_modules/siren/config.py +1038 -0
- arctrl/py/fable_modules/siren/formatting.py +1121 -0
- arctrl/py/fable_modules/siren/siren.py +1941 -0
- arctrl/py/fable_modules/siren/siren_types.py +1229 -0
- arctrl/py/fable_modules/siren/theme_variables.py +517 -0
- arctrl/py/fable_modules/siren/util.py +37 -0
- arctrl/py/fable_modules/siren/yaml.py +101 -0
- arctrl/py/fable_modules/thoth_json_core/__init__.py +0 -0
- arctrl/py/fable_modules/thoth_json_core/decode.py +1614 -0
- arctrl/py/fable_modules/thoth_json_core/encode.py +305 -0
- arctrl/py/fable_modules/thoth_json_core/types.py +181 -0
- arctrl/py/fable_modules/thoth_json_python/__init__.py +0 -0
- arctrl/py/fable_modules/thoth_json_python/decode.py +112 -0
- arctrl/py/fable_modules/thoth_json_python/encode.py +72 -0
- arctrl/py/fable_modules/thoth_json_python/python.py +1 -0
- arctrl/py/fable_modules/yamlicious/Interop/__init__.py +0 -0
- arctrl/py/fable_modules/yamlicious/Interop/js_interop.py +1 -0
- arctrl/py/fable_modules/yamlicious/Interop/py_interop.py +7 -0
- arctrl/py/fable_modules/yamlicious/__init__.py +0 -0
- arctrl/py/fable_modules/yamlicious/decode.py +1784 -0
- arctrl/py/fable_modules/yamlicious/encode.py +84 -0
- arctrl/py/fable_modules/yamlicious/flow_to_block.py +994 -0
- arctrl/py/fable_modules/yamlicious/library.py +10 -0
- arctrl/py/fable_modules/yamlicious/persil.py +57 -0
- arctrl/py/fable_modules/yamlicious/preprocessing.py +99 -0
- arctrl/py/fable_modules/yamlicious/reader.py +739 -0
- arctrl/py/fable_modules/yamlicious/regex.py +29 -0
- arctrl/py/fable_modules/yamlicious/regex_active_patterns.py +265 -0
- arctrl/py/fable_modules/yamlicious/writer.py +175 -0
- arctrl/py/fable_modules/yamlicious/yamlicious_types.py +128 -0
- arctrl/py/json.py +389 -0
- arctrl/py/license.py +169 -0
- arctrl/py/rocrate_io.py +242 -0
- arctrl/py/template_web.py +23 -0
- arctrl/py/xlsx.py +212 -0
- arctrl/py/yaml.py +79 -0
- arctrl/rocrate.py +21 -0
- arctrl-3.0.0.dist-info/METADATA +157 -0
- arctrl-3.0.0.dist-info/RECORD +511 -0
- arctrl-3.0.0.dist-info/WHEEL +4 -0
- arctrl-3.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1528 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import builtins
|
|
4
|
+
import functools
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
from math import ceil
|
|
7
|
+
from typing import Any, TypeVar
|
|
8
|
+
|
|
9
|
+
from .double import divide
|
|
10
|
+
from .global_ import IGenericAdder_1, IGenericAverager_1, SR_indexOutOfBounds
|
|
11
|
+
from .native import Cons_1, Helpers_allocateArrayFromCons, Helpers_fillImpl, Helpers_spliceImpl
|
|
12
|
+
from .option import default_arg, some
|
|
13
|
+
from .option import map as map_1
|
|
14
|
+
from .option import value as value_1
|
|
15
|
+
from .types import Array
|
|
16
|
+
from .util import (
|
|
17
|
+
IComparer_1,
|
|
18
|
+
IEnumerable_1,
|
|
19
|
+
IEqualityComparer_1,
|
|
20
|
+
compare_primitives,
|
|
21
|
+
copy_to_array,
|
|
22
|
+
get_enumerator,
|
|
23
|
+
ignore,
|
|
24
|
+
)
|
|
25
|
+
from .util import equals as equals_1
|
|
26
|
+
from .util import max as max_1
|
|
27
|
+
from .util import min as min_1
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
_T = TypeVar("_T")
|
|
31
|
+
|
|
32
|
+
_U = TypeVar("_U")
|
|
33
|
+
|
|
34
|
+
_T1 = TypeVar("_T1")
|
|
35
|
+
|
|
36
|
+
_T2 = TypeVar("_T2")
|
|
37
|
+
|
|
38
|
+
_T3 = TypeVar("_T3")
|
|
39
|
+
|
|
40
|
+
_STATE = TypeVar("_STATE")
|
|
41
|
+
|
|
42
|
+
_RESULT = TypeVar("_RESULT")
|
|
43
|
+
|
|
44
|
+
__A = TypeVar("__A")
|
|
45
|
+
|
|
46
|
+
__B = TypeVar("__B")
|
|
47
|
+
|
|
48
|
+
_A = TypeVar("_A")
|
|
49
|
+
|
|
50
|
+
_B = TypeVar("_B")
|
|
51
|
+
|
|
52
|
+
__C = TypeVar("__C")
|
|
53
|
+
|
|
54
|
+
_V = TypeVar("_V")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def index_not_found(__unit: None = None) -> Any:
|
|
58
|
+
raise Exception("An index satisfying the predicate was not found in the collection.")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def different_lengths(__unit: None = None) -> Any:
|
|
62
|
+
raise Exception("Arrays had different lengths")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def append(array1: Array[Any], array2: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
66
|
+
len1: int = len(array1) or 0
|
|
67
|
+
len2: int = len(array2) or 0
|
|
68
|
+
new_array: Array[_T] = Helpers_allocateArrayFromCons(cons, len1 + len2)
|
|
69
|
+
for i in range(0, (len1 - 1) + 1, 1):
|
|
70
|
+
new_array[i] = array1[i]
|
|
71
|
+
for i_1 in range(0, (len2 - 1) + 1, 1):
|
|
72
|
+
new_array[i_1 + len1] = array2[i_1]
|
|
73
|
+
return new_array
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def filter(predicate: Callable[[_T], bool], array: Array[Any]) -> Array[Any]:
|
|
77
|
+
return list(builtins.filter(predicate, array))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def fill(target: Array[Any], target_index: int, count: int, value: Any) -> Array[Any]:
|
|
81
|
+
return Helpers_fillImpl(target, value, target_index, count)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def get_sub_array(array: Array[Any], start: int, count: int) -> Array[Any]:
|
|
85
|
+
return array[start : start + count]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def last(array: Array[Any]) -> Any:
|
|
89
|
+
if len(array) == 0:
|
|
90
|
+
raise Exception("The input array was empty\\nParameter name: array")
|
|
91
|
+
|
|
92
|
+
return array[len(array) - 1]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def try_last(array: Array[Any]) -> Any | None:
|
|
96
|
+
if len(array) == 0:
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
else:
|
|
100
|
+
return some(array[len(array) - 1])
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def map_indexed(f: Callable[[int, _T], _U], source: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
104
|
+
len_1: int = len(source) or 0
|
|
105
|
+
target: Array[_U] = Helpers_allocateArrayFromCons(cons, len_1)
|
|
106
|
+
for i in range(0, (len_1 - 1) + 1, 1):
|
|
107
|
+
target[i] = f(i, source[i])
|
|
108
|
+
return target
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def map(f: Callable[[_T], _U], source: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
112
|
+
len_1: int = len(source) or 0
|
|
113
|
+
target: Array[_U] = Helpers_allocateArrayFromCons(cons, len_1)
|
|
114
|
+
for i in range(0, (len_1 - 1) + 1, 1):
|
|
115
|
+
target[i] = f(source[i])
|
|
116
|
+
return target
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def map_indexed2(
|
|
120
|
+
f: Callable[[int, _T1, _T2], _U], source1: Array[Any], source2: Array[Any], cons: Cons_1[Any]
|
|
121
|
+
) -> Array[Any]:
|
|
122
|
+
if len(source1) != len(source2):
|
|
123
|
+
raise Exception("Arrays had different lengths")
|
|
124
|
+
|
|
125
|
+
result: Array[_U] = Helpers_allocateArrayFromCons(cons, len(source1))
|
|
126
|
+
for i in range(0, (len(source1) - 1) + 1, 1):
|
|
127
|
+
result[i] = f(i, source1[i], source2[i])
|
|
128
|
+
return result
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def map2(f: Callable[[_T1, _T2], _U], source1: Array[Any], source2: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
132
|
+
if len(source1) != len(source2):
|
|
133
|
+
raise Exception("Arrays had different lengths")
|
|
134
|
+
|
|
135
|
+
result: Array[_U] = Helpers_allocateArrayFromCons(cons, len(source1))
|
|
136
|
+
for i in range(0, (len(source1) - 1) + 1, 1):
|
|
137
|
+
result[i] = f(source1[i], source2[i])
|
|
138
|
+
return result
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def map_indexed3(
|
|
142
|
+
f: Callable[[int, _T1, _T2, _T3], _U],
|
|
143
|
+
source1: Array[Any],
|
|
144
|
+
source2: Array[Any],
|
|
145
|
+
source3: Array[Any],
|
|
146
|
+
cons: Cons_1[Any],
|
|
147
|
+
) -> Array[Any]:
|
|
148
|
+
if True if (len(source1) != len(source2)) else (len(source2) != len(source3)):
|
|
149
|
+
raise Exception("Arrays had different lengths")
|
|
150
|
+
|
|
151
|
+
result: Array[_U] = Helpers_allocateArrayFromCons(cons, len(source1))
|
|
152
|
+
for i in range(0, (len(source1) - 1) + 1, 1):
|
|
153
|
+
result[i] = f(i, source1[i], source2[i], source3[i])
|
|
154
|
+
return result
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def map3(
|
|
158
|
+
f: Callable[[_T1, _T2, _T3], _U], source1: Array[Any], source2: Array[Any], source3: Array[Any], cons: Cons_1[Any]
|
|
159
|
+
) -> Array[Any]:
|
|
160
|
+
if True if (len(source1) != len(source2)) else (len(source2) != len(source3)):
|
|
161
|
+
raise Exception("Arrays had different lengths")
|
|
162
|
+
|
|
163
|
+
result: Array[_U] = Helpers_allocateArrayFromCons(cons, len(source1))
|
|
164
|
+
for i in range(0, (len(source1) - 1) + 1, 1):
|
|
165
|
+
result[i] = f(source1[i], source2[i], source3[i])
|
|
166
|
+
return result
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def map_fold(
|
|
170
|
+
mapping: Callable[[_STATE, _T], tuple[_RESULT, _STATE]], state: Any, array: Array[Any], cons: Cons_1[Any]
|
|
171
|
+
) -> tuple[Array[_RESULT], _STATE]:
|
|
172
|
+
match_value: int = len(array) or 0
|
|
173
|
+
if match_value == 0:
|
|
174
|
+
return ([], state)
|
|
175
|
+
|
|
176
|
+
else:
|
|
177
|
+
acc: _STATE = state
|
|
178
|
+
res: Array[_RESULT] = Helpers_allocateArrayFromCons(cons, match_value)
|
|
179
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
180
|
+
pattern_input: tuple[_RESULT, _STATE] = mapping(acc, array[i])
|
|
181
|
+
res[i] = pattern_input[0]
|
|
182
|
+
acc = pattern_input[1]
|
|
183
|
+
return (res, acc)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def map_fold_back(
|
|
187
|
+
mapping: Callable[[_T, _STATE], tuple[_RESULT, _STATE]], array: Array[Any], state: Any, cons: Cons_1[Any]
|
|
188
|
+
) -> tuple[Array[_RESULT], _STATE]:
|
|
189
|
+
match_value: int = len(array) or 0
|
|
190
|
+
if match_value == 0:
|
|
191
|
+
return ([], state)
|
|
192
|
+
|
|
193
|
+
else:
|
|
194
|
+
acc: _STATE = state
|
|
195
|
+
res: Array[_RESULT] = Helpers_allocateArrayFromCons(cons, match_value)
|
|
196
|
+
for i in range(len(array) - 1, 0 - 1, -1):
|
|
197
|
+
pattern_input: tuple[_RESULT, _STATE] = mapping(array[i], acc)
|
|
198
|
+
res[i] = pattern_input[0]
|
|
199
|
+
acc = pattern_input[1]
|
|
200
|
+
return (res, acc)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def indexed(source: Array[Any]) -> Array[tuple[int, _T]]:
|
|
204
|
+
len_1: int = len(source) or 0
|
|
205
|
+
target: Array[tuple[int, _T]] = [None] * len_1
|
|
206
|
+
for i in range(0, (len_1 - 1) + 1, 1):
|
|
207
|
+
target[i] = (i, source[i])
|
|
208
|
+
return target
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def truncate(count: int, array: Array[Any]) -> Array[Any]:
|
|
212
|
+
def _arrow41(x: int, y: int, count: Any = count, array: Any = array) -> int:
|
|
213
|
+
return compare_primitives(x, y)
|
|
214
|
+
|
|
215
|
+
count_1: int = max_1(_arrow41, 0, count) or 0
|
|
216
|
+
return array[0 : 0 + count_1]
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def concat(arrays: IEnumerable_1[Array[Any]], cons: Cons_1[Any]) -> Array[Any]:
|
|
220
|
+
arrays_1: Array[Array[_T]] = arrays if (isinstance(arrays, list)) else (list(arrays))
|
|
221
|
+
match_value: int = len(arrays_1) or 0
|
|
222
|
+
if match_value == 0:
|
|
223
|
+
return Helpers_allocateArrayFromCons(cons, 0)
|
|
224
|
+
|
|
225
|
+
elif match_value == 1:
|
|
226
|
+
return arrays_1[0]
|
|
227
|
+
|
|
228
|
+
else:
|
|
229
|
+
total_idx: int = 0
|
|
230
|
+
total_length: int = 0
|
|
231
|
+
for idx in range(0, (len(arrays_1) - 1) + 1, 1):
|
|
232
|
+
arr_1: Array[_T] = arrays_1[idx]
|
|
233
|
+
total_length = (total_length + len(arr_1)) or 0
|
|
234
|
+
result: Array[_T] = Helpers_allocateArrayFromCons(cons, total_length)
|
|
235
|
+
for idx_1 in range(0, (len(arrays_1) - 1) + 1, 1):
|
|
236
|
+
arr_2: Array[_T] = arrays_1[idx_1]
|
|
237
|
+
for j in range(0, (len(arr_2) - 1) + 1, 1):
|
|
238
|
+
result[total_idx] = arr_2[j]
|
|
239
|
+
total_idx = (total_idx + 1) or 0
|
|
240
|
+
return result
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def collect(mapping: Callable[[_T], Array[_U]], array: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
244
|
+
return concat(map(mapping, array, None), cons)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def where(predicate: Callable[[__A], bool], array: Array[Any]) -> Array[Any]:
|
|
248
|
+
return list(builtins.filter(predicate, array))
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def index_of(array: Array[Any], item_1: Any, start: int | None, count: int | None, eq: IEqualityComparer_1[Any]) -> int:
|
|
252
|
+
start_1: int = default_arg(start, 0) or 0
|
|
253
|
+
|
|
254
|
+
def mapping(
|
|
255
|
+
c: int, array: Any = array, item_1: Any = item_1, start: Any = start, count: Any = count, eq: Any = eq
|
|
256
|
+
) -> int:
|
|
257
|
+
return start_1 + c
|
|
258
|
+
|
|
259
|
+
end_0027: int = default_arg(map_1(mapping, count), len(array)) or 0
|
|
260
|
+
|
|
261
|
+
def loop(
|
|
262
|
+
i_mut: int, array: Any = array, item_1: Any = item_1, start: Any = start, count: Any = count, eq: Any = eq
|
|
263
|
+
) -> int:
|
|
264
|
+
while True:
|
|
265
|
+
(i,) = (i_mut,)
|
|
266
|
+
if i >= end_0027:
|
|
267
|
+
return -1
|
|
268
|
+
|
|
269
|
+
elif eq.Equals(item_1, array[i]):
|
|
270
|
+
return i
|
|
271
|
+
|
|
272
|
+
else:
|
|
273
|
+
i_mut = i + 1
|
|
274
|
+
continue
|
|
275
|
+
|
|
276
|
+
break
|
|
277
|
+
|
|
278
|
+
return loop(start_1)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def contains(value: Any, array: Array[Any], eq: IEqualityComparer_1[Any]) -> bool:
|
|
282
|
+
return index_of(array, value, None, None, eq) >= 0
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def empty(cons: Cons_1[Any]) -> Array[Any]:
|
|
286
|
+
return Helpers_allocateArrayFromCons(cons, 0)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def singleton(value: Any, cons: Cons_1[Any]) -> Array[Any]:
|
|
290
|
+
ar: Array[_T] = Helpers_allocateArrayFromCons(cons, 1)
|
|
291
|
+
ar[0] = value
|
|
292
|
+
return ar
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def initialize(count: int, initializer: Callable[[int], _T], cons: Cons_1[Any]) -> Array[Any]:
|
|
296
|
+
if count < 0:
|
|
297
|
+
raise Exception("The input must be non-negative\\nParameter name: count")
|
|
298
|
+
|
|
299
|
+
result: Array[_T] = Helpers_allocateArrayFromCons(cons, count)
|
|
300
|
+
for i in range(0, (count - 1) + 1, 1):
|
|
301
|
+
result[i] = initializer(i)
|
|
302
|
+
return result
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def pairwise(array: Array[Any]) -> Array[tuple[_T, _T]]:
|
|
306
|
+
if len(array) < 2:
|
|
307
|
+
return []
|
|
308
|
+
|
|
309
|
+
else:
|
|
310
|
+
count: int = (len(array) - 1) or 0
|
|
311
|
+
result: Array[tuple[_T, _T]] = [None] * count
|
|
312
|
+
for i in range(0, (count - 1) + 1, 1):
|
|
313
|
+
result[i] = (array[i], array[i + 1])
|
|
314
|
+
return result
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def replicate(count: int, initial: Any, cons: Cons_1[Any]) -> Array[Any]:
|
|
318
|
+
if count < 0:
|
|
319
|
+
raise Exception("The input must be non-negative\\nParameter name: count")
|
|
320
|
+
|
|
321
|
+
result: Array[_T] = Helpers_allocateArrayFromCons(cons, count)
|
|
322
|
+
for i in range(0, (len(result) - 1) + 1, 1):
|
|
323
|
+
result[i] = initial
|
|
324
|
+
return result
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def copy(array: Array[Any]) -> Array[Any]:
|
|
328
|
+
return array[:]
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def copy_to(source: Array[Any], source_index: int, target: Array[Any], target_index: int, count: int) -> None:
|
|
332
|
+
copy_to_array(source, source_index, target, target_index, count)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def reverse(array: Array[Any]) -> Array[Any]:
|
|
336
|
+
array_1: Array[_T] = array[:]
|
|
337
|
+
return array_1[::-1]
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def scan(folder: Callable[[_STATE, _T], _STATE], state: Any, array: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
341
|
+
res: Array[_STATE] = Helpers_allocateArrayFromCons(cons, len(array) + 1)
|
|
342
|
+
res[0] = state
|
|
343
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
344
|
+
res[i + 1] = folder(res[i], array[i])
|
|
345
|
+
return res
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def scan_back(folder: Callable[[_T, _STATE], _STATE], array: Array[Any], state: Any, cons: Cons_1[Any]) -> Array[Any]:
|
|
349
|
+
res: Array[_STATE] = Helpers_allocateArrayFromCons(cons, len(array) + 1)
|
|
350
|
+
res[len(array)] = state
|
|
351
|
+
for i in range(len(array) - 1, 0 - 1, -1):
|
|
352
|
+
res[i] = folder(array[i], res[i + 1])
|
|
353
|
+
return res
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def skip(count: int, array: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
357
|
+
if count > len(array):
|
|
358
|
+
raise Exception("count is greater than array length\\nParameter name: count")
|
|
359
|
+
|
|
360
|
+
if count == len(array):
|
|
361
|
+
return Helpers_allocateArrayFromCons(cons, 0)
|
|
362
|
+
|
|
363
|
+
else:
|
|
364
|
+
count_1: int = (0 if (count < 0) else count) or 0
|
|
365
|
+
return array[count_1:]
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def skip_while(predicate: Callable[[_T], bool], array: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
369
|
+
count: int = 0
|
|
370
|
+
while predicate(array[count]) if (count < len(array)) else False:
|
|
371
|
+
count = (count + 1) or 0
|
|
372
|
+
if count == len(array):
|
|
373
|
+
return Helpers_allocateArrayFromCons(cons, 0)
|
|
374
|
+
|
|
375
|
+
else:
|
|
376
|
+
return array[count:]
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def take(count: int, array: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
380
|
+
if count < 0:
|
|
381
|
+
raise Exception("The input must be non-negative\\nParameter name: count")
|
|
382
|
+
|
|
383
|
+
if count > len(array):
|
|
384
|
+
raise Exception("count is greater than array length\\nParameter name: count")
|
|
385
|
+
|
|
386
|
+
if count == 0:
|
|
387
|
+
return Helpers_allocateArrayFromCons(cons, 0)
|
|
388
|
+
|
|
389
|
+
else:
|
|
390
|
+
return array[0 : 0 + count]
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def take_while(predicate: Callable[[_T], bool], array: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
394
|
+
count: int = 0
|
|
395
|
+
while predicate(array[count]) if (count < len(array)) else False:
|
|
396
|
+
count = (count + 1) or 0
|
|
397
|
+
if count == 0:
|
|
398
|
+
return Helpers_allocateArrayFromCons(cons, 0)
|
|
399
|
+
|
|
400
|
+
else:
|
|
401
|
+
return array[0 : 0 + count]
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
def add_in_place(x: Any, array: Array[Any]) -> None:
|
|
405
|
+
ignore(array.append(x))
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def add_range_in_place(range: IEnumerable_1[Any], array: Array[Any]) -> None:
|
|
409
|
+
with get_enumerator(range) as enumerator:
|
|
410
|
+
while enumerator.System_Collections_IEnumerator_MoveNext():
|
|
411
|
+
add_in_place(enumerator.System_Collections_Generic_IEnumerator_1_get_Current(), array)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
def insert_range_in_place(index: int, range: IEnumerable_1[Any], array: Array[Any]) -> None:
|
|
415
|
+
i: int = index or 0
|
|
416
|
+
with get_enumerator(range) as enumerator:
|
|
417
|
+
while enumerator.System_Collections_IEnumerator_MoveNext():
|
|
418
|
+
x: _T = enumerator.System_Collections_Generic_IEnumerator_1_get_Current()
|
|
419
|
+
|
|
420
|
+
def _arrow42(__unit: None = None, index: Any = index, range: Any = range, array: Any = array) -> Array[_T]:
|
|
421
|
+
array_1: Array[_T] = array
|
|
422
|
+
index_1: int = i or 0
|
|
423
|
+
array_1.insert(index_1, x)
|
|
424
|
+
return array_1
|
|
425
|
+
|
|
426
|
+
ignore(_arrow42())
|
|
427
|
+
i = (i + 1) or 0
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
def remove_in_place(item_1: Any, array: Array[Any], eq: IEqualityComparer_1[Any]) -> bool:
|
|
431
|
+
i: int = index_of(array, item_1, None, None, eq) or 0
|
|
432
|
+
if i > -1:
|
|
433
|
+
ignore(Helpers_spliceImpl(array, i, 1))
|
|
434
|
+
return True
|
|
435
|
+
|
|
436
|
+
else:
|
|
437
|
+
return False
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
def remove_all_in_place(predicate: Callable[[_T], bool], array: Array[Any]) -> int:
|
|
441
|
+
def count_remove_all(count: int, predicate: Any = predicate, array: Any = array) -> int:
|
|
442
|
+
i: int = (next((i for i, x in enumerate(array) if (predicate)(x)), -1)) or 0
|
|
443
|
+
if i > -1:
|
|
444
|
+
ignore(Helpers_spliceImpl(array, i, 1))
|
|
445
|
+
return count_remove_all(count) + 1
|
|
446
|
+
|
|
447
|
+
else:
|
|
448
|
+
return count
|
|
449
|
+
|
|
450
|
+
return count_remove_all(0)
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def partition(f: Callable[[_T], bool], source: Array[Any], cons: Cons_1[Any]) -> tuple[Array[_T], Array[_T]]:
|
|
454
|
+
len_1: int = len(source) or 0
|
|
455
|
+
res1: Array[_T] = Helpers_allocateArrayFromCons(cons, len_1)
|
|
456
|
+
res2: Array[_T] = Helpers_allocateArrayFromCons(cons, len_1)
|
|
457
|
+
i_true: int = 0
|
|
458
|
+
i_false: int = 0
|
|
459
|
+
for i in range(0, (len_1 - 1) + 1, 1):
|
|
460
|
+
if f(source[i]):
|
|
461
|
+
res1[i_true] = source[i]
|
|
462
|
+
i_true = (i_true + 1) or 0
|
|
463
|
+
|
|
464
|
+
else:
|
|
465
|
+
res2[i_false] = source[i]
|
|
466
|
+
i_false = (i_false + 1) or 0
|
|
467
|
+
|
|
468
|
+
return (truncate(i_true, res1), truncate(i_false, res2))
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def find(predicate: Callable[[_T], bool], array: Array[Any]) -> Any:
|
|
472
|
+
match_value: _T | None = next((x for x in array if (predicate)(x)), None)
|
|
473
|
+
if match_value is None:
|
|
474
|
+
return index_not_found()
|
|
475
|
+
|
|
476
|
+
else:
|
|
477
|
+
return value_1(match_value)
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def try_find(predicate: Callable[[_T], bool], array: Array[Any]) -> Any | None:
|
|
481
|
+
return next((x for x in array if (predicate)(x)), None)
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
def find_index(predicate: Callable[[_T], bool], array: Array[Any]) -> int:
|
|
485
|
+
match_value: int = (next((i for i, x in enumerate(array) if (predicate)(x)), -1)) or 0
|
|
486
|
+
if match_value > -1:
|
|
487
|
+
return match_value
|
|
488
|
+
|
|
489
|
+
else:
|
|
490
|
+
index_not_found()
|
|
491
|
+
return -1
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
def try_find_index(predicate: Callable[[_T], bool], array: Array[Any]) -> int | None:
|
|
495
|
+
match_value: int = (next((i for i, x in enumerate(array) if (predicate)(x)), -1)) or 0
|
|
496
|
+
if match_value > -1:
|
|
497
|
+
return match_value
|
|
498
|
+
|
|
499
|
+
else:
|
|
500
|
+
return None
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def pick(chooser: Callable[[__A], __B | None], array: Array[Any]) -> Any:
|
|
504
|
+
def loop(i_mut: int, chooser: Any = chooser, array: Any = array) -> __B:
|
|
505
|
+
while True:
|
|
506
|
+
(i,) = (i_mut,)
|
|
507
|
+
if i >= len(array):
|
|
508
|
+
return index_not_found()
|
|
509
|
+
|
|
510
|
+
else:
|
|
511
|
+
match_value: __B | None = chooser(array[i])
|
|
512
|
+
if match_value is not None:
|
|
513
|
+
return value_1(match_value)
|
|
514
|
+
|
|
515
|
+
else:
|
|
516
|
+
i_mut = i + 1
|
|
517
|
+
continue
|
|
518
|
+
|
|
519
|
+
break
|
|
520
|
+
|
|
521
|
+
return loop(0)
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
def try_pick(chooser: Callable[[__A], __B | None], array: Array[Any]) -> Any | None:
|
|
525
|
+
def loop(i_mut: int, chooser: Any = chooser, array: Any = array) -> __B | None:
|
|
526
|
+
while True:
|
|
527
|
+
(i,) = (i_mut,)
|
|
528
|
+
if i >= len(array):
|
|
529
|
+
return None
|
|
530
|
+
|
|
531
|
+
else:
|
|
532
|
+
match_value: __B | None = chooser(array[i])
|
|
533
|
+
if match_value is None:
|
|
534
|
+
i_mut = i + 1
|
|
535
|
+
continue
|
|
536
|
+
|
|
537
|
+
else:
|
|
538
|
+
return match_value
|
|
539
|
+
|
|
540
|
+
break
|
|
541
|
+
|
|
542
|
+
return loop(0)
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
def find_back(predicate: Callable[[__A], bool], array: Array[Any]) -> Any:
|
|
546
|
+
def loop(i_mut: int, predicate: Any = predicate, array: Any = array) -> __A:
|
|
547
|
+
while True:
|
|
548
|
+
(i,) = (i_mut,)
|
|
549
|
+
if i < 0:
|
|
550
|
+
return index_not_found()
|
|
551
|
+
|
|
552
|
+
elif predicate(array[i]):
|
|
553
|
+
return array[i]
|
|
554
|
+
|
|
555
|
+
else:
|
|
556
|
+
i_mut = i - 1
|
|
557
|
+
continue
|
|
558
|
+
|
|
559
|
+
break
|
|
560
|
+
|
|
561
|
+
return loop(len(array) - 1)
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def try_find_back(predicate: Callable[[__A], bool], array: Array[Any]) -> Any | None:
|
|
565
|
+
def loop(i_mut: int, predicate: Any = predicate, array: Any = array) -> __A | None:
|
|
566
|
+
while True:
|
|
567
|
+
(i,) = (i_mut,)
|
|
568
|
+
if i < 0:
|
|
569
|
+
return None
|
|
570
|
+
|
|
571
|
+
elif predicate(array[i]):
|
|
572
|
+
return some(array[i])
|
|
573
|
+
|
|
574
|
+
else:
|
|
575
|
+
i_mut = i - 1
|
|
576
|
+
continue
|
|
577
|
+
|
|
578
|
+
break
|
|
579
|
+
|
|
580
|
+
return loop(len(array) - 1)
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def find_last_index(predicate: Callable[[__A], bool], array: Array[Any]) -> int:
|
|
584
|
+
def loop(i_mut: int, predicate: Any = predicate, array: Any = array) -> int:
|
|
585
|
+
while True:
|
|
586
|
+
(i,) = (i_mut,)
|
|
587
|
+
if i < 0:
|
|
588
|
+
return -1
|
|
589
|
+
|
|
590
|
+
elif predicate(array[i]):
|
|
591
|
+
return i
|
|
592
|
+
|
|
593
|
+
else:
|
|
594
|
+
i_mut = i - 1
|
|
595
|
+
continue
|
|
596
|
+
|
|
597
|
+
break
|
|
598
|
+
|
|
599
|
+
return loop(len(array) - 1)
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
def find_index_back(predicate: Callable[[__A], bool], array: Array[Any]) -> int:
|
|
603
|
+
def loop(i_mut: int, predicate: Any = predicate, array: Any = array) -> int:
|
|
604
|
+
while True:
|
|
605
|
+
(i,) = (i_mut,)
|
|
606
|
+
if i < 0:
|
|
607
|
+
index_not_found()
|
|
608
|
+
return -1
|
|
609
|
+
|
|
610
|
+
elif predicate(array[i]):
|
|
611
|
+
return i
|
|
612
|
+
|
|
613
|
+
else:
|
|
614
|
+
i_mut = i - 1
|
|
615
|
+
continue
|
|
616
|
+
|
|
617
|
+
break
|
|
618
|
+
|
|
619
|
+
return loop(len(array) - 1)
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
def try_find_index_back(predicate: Callable[[__A], bool], array: Array[Any]) -> int | None:
|
|
623
|
+
def loop(i_mut: int, predicate: Any = predicate, array: Any = array) -> int | None:
|
|
624
|
+
while True:
|
|
625
|
+
(i,) = (i_mut,)
|
|
626
|
+
if i < 0:
|
|
627
|
+
return None
|
|
628
|
+
|
|
629
|
+
elif predicate(array[i]):
|
|
630
|
+
return i
|
|
631
|
+
|
|
632
|
+
else:
|
|
633
|
+
i_mut = i - 1
|
|
634
|
+
continue
|
|
635
|
+
|
|
636
|
+
break
|
|
637
|
+
|
|
638
|
+
return loop(len(array) - 1)
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
def choose(chooser: Callable[[_T], _U | None], array: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
642
|
+
res: Array[_U] = []
|
|
643
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
644
|
+
match_value: _U | None = chooser(array[i])
|
|
645
|
+
if match_value is not None:
|
|
646
|
+
y: _U = value_1(match_value)
|
|
647
|
+
ignore(res.append(y))
|
|
648
|
+
|
|
649
|
+
if equals_1(cons, None):
|
|
650
|
+
return res
|
|
651
|
+
|
|
652
|
+
else:
|
|
653
|
+
|
|
654
|
+
def _arrow43(x: _U | None = None, chooser: Any = chooser, array: Any = array, cons: Any = cons) -> _U | None:
|
|
655
|
+
return x
|
|
656
|
+
|
|
657
|
+
return map(_arrow43, res, cons)
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def fold_indexed(folder: Callable[[int, _STATE, _T], _STATE], state: Any, array: Array[Any]) -> Any:
|
|
661
|
+
def _arrow44(
|
|
662
|
+
delegate_arg: _STATE,
|
|
663
|
+
delegate_arg_1: _T,
|
|
664
|
+
delegate_arg_2: int,
|
|
665
|
+
folder: Any = folder,
|
|
666
|
+
state: Any = state,
|
|
667
|
+
array: Any = array,
|
|
668
|
+
) -> _STATE:
|
|
669
|
+
return folder(delegate_arg_2, delegate_arg, delegate_arg_1)
|
|
670
|
+
|
|
671
|
+
return array.reduce((_arrow44, state))
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
def fold(folder: Callable[[_STATE, _T], _STATE], state: Any, array: Array[Any]) -> Any:
|
|
675
|
+
return functools.reduce(folder, array, state)
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
def iterate(action: Callable[[_T], None], array: Array[Any]) -> None:
|
|
679
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
680
|
+
action(array[i])
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
def iterate_indexed(action: Callable[[int, _T], None], array: Array[Any]) -> None:
|
|
684
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
685
|
+
action(i, array[i])
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
def iterate2(action: Callable[[_T1, _T2], None], array1: Array[Any], array2: Array[Any]) -> None:
|
|
689
|
+
if len(array1) != len(array2):
|
|
690
|
+
different_lengths()
|
|
691
|
+
|
|
692
|
+
for i in range(0, (len(array1) - 1) + 1, 1):
|
|
693
|
+
action(array1[i], array2[i])
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
def iterate_indexed2(action: Callable[[int, _T1, _T2], None], array1: Array[Any], array2: Array[Any]) -> None:
|
|
697
|
+
if len(array1) != len(array2):
|
|
698
|
+
different_lengths()
|
|
699
|
+
|
|
700
|
+
for i in range(0, (len(array1) - 1) + 1, 1):
|
|
701
|
+
action(i, array1[i], array2[i])
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
def is_empty(array: Array[Any]) -> bool:
|
|
705
|
+
return len(array) == 0
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
def for_all(predicate: Callable[[_T], bool], array: Array[Any]) -> bool:
|
|
709
|
+
return all([predicate(x) for x in array])
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
def permute(f: Callable[[int], int], array: Array[Any]) -> Array[Any]:
|
|
713
|
+
size: int = len(array) or 0
|
|
714
|
+
res: Array[_T] = array[:]
|
|
715
|
+
check_flags: Array[int] = [None] * size
|
|
716
|
+
|
|
717
|
+
def _arrow45(i: int, x: _T, f: Any = f, array: Any = array) -> None:
|
|
718
|
+
j: int = f(i) or 0
|
|
719
|
+
if True if (j < 0) else (j >= size):
|
|
720
|
+
raise Exception("Not a valid permutation")
|
|
721
|
+
|
|
722
|
+
res[j] = x
|
|
723
|
+
check_flags[j] = 1
|
|
724
|
+
|
|
725
|
+
iterate_indexed(_arrow45, array)
|
|
726
|
+
|
|
727
|
+
def predicate(y: int, f: Any = f, array: Any = array) -> bool:
|
|
728
|
+
return 1 == y
|
|
729
|
+
|
|
730
|
+
if not (all([predicate(x) for x in check_flags])):
|
|
731
|
+
raise Exception("Not a valid permutation")
|
|
732
|
+
|
|
733
|
+
return res
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
def set_slice(target: Array[Any], lower: int | None, upper: int | None, source: Array[Any]) -> None:
|
|
737
|
+
lower_1: int = default_arg(lower, 0) or 0
|
|
738
|
+
upper_1: int = default_arg(upper, -1) or 0
|
|
739
|
+
length: int = ((upper_1 if (upper_1 >= 0) else (len(target) - 1)) - lower_1) or 0
|
|
740
|
+
for i in range(0, length + 1, 1):
|
|
741
|
+
target[i + lower_1] = source[i]
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
def sort_in_place_by(projection: Callable[[_A], _B], xs: Array[Any], comparer: IComparer_1[Any]) -> None:
|
|
745
|
+
def _arrow46(x: _A, y: _A, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
746
|
+
return comparer.Compare(projection(x), projection(y))
|
|
747
|
+
|
|
748
|
+
xs.sort(key=functools.cmp_to_key(_arrow46))
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
def sort_in_place(xs: Array[Any], comparer: IComparer_1[Any]) -> None:
|
|
752
|
+
def _arrow47(x: _T, y: _T, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
753
|
+
return comparer.Compare(x, y)
|
|
754
|
+
|
|
755
|
+
xs.sort(key=functools.cmp_to_key(_arrow47))
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
def sort_in_place_with(comparer: Callable[[_T, _T], int], xs: Array[Any]) -> Array[Any]:
|
|
759
|
+
xs.sort(key=functools.cmp_to_key(comparer))
|
|
760
|
+
return xs
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
def sort(xs: Array[Any], comparer: IComparer_1[Any]) -> Array[Any]:
|
|
764
|
+
def _arrow48(x: _T, y: _T, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
765
|
+
return comparer.Compare(x, y)
|
|
766
|
+
|
|
767
|
+
return sorted(xs, key=functools.cmp_to_key(_arrow48))
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
def sort_by(projection: Callable[[_A], _B], xs: Array[Any], comparer: IComparer_1[Any]) -> Array[Any]:
|
|
771
|
+
def _arrow49(x: _A, y: _A, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
772
|
+
return comparer.Compare(projection(x), projection(y))
|
|
773
|
+
|
|
774
|
+
return sorted(xs, key=functools.cmp_to_key(_arrow49))
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
def sort_descending(xs: Array[Any], comparer: IComparer_1[Any]) -> Array[Any]:
|
|
778
|
+
def _arrow50(x: _T, y: _T, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
779
|
+
return comparer.Compare(x, y) * -1
|
|
780
|
+
|
|
781
|
+
return sorted(xs, key=functools.cmp_to_key(_arrow50))
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
def sort_by_descending(projection: Callable[[_A], _B], xs: Array[Any], comparer: IComparer_1[Any]) -> Array[Any]:
|
|
785
|
+
def _arrow51(x: _A, y: _A, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
786
|
+
return comparer.Compare(projection(x), projection(y)) * -1
|
|
787
|
+
|
|
788
|
+
return sorted(xs, key=functools.cmp_to_key(_arrow51))
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
def sort_with(comparer: Callable[[_T, _T], int], xs: Array[Any]) -> Array[Any]:
|
|
792
|
+
return sorted(xs, key=functools.cmp_to_key(comparer))
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
def all_pairs(xs: Array[Any], ys: Array[Any]) -> Array[tuple[_T1, _T2]]:
|
|
796
|
+
len1: int = len(xs) or 0
|
|
797
|
+
len2: int = len(ys) or 0
|
|
798
|
+
res: Array[tuple[_T1, _T2]] = [None] * (len1 * len2)
|
|
799
|
+
for i in range(0, (len(xs) - 1) + 1, 1):
|
|
800
|
+
for j in range(0, (len(ys) - 1) + 1, 1):
|
|
801
|
+
res[(i * len2) + j] = (xs[i], ys[j])
|
|
802
|
+
return res
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
def unfold(generator: Callable[[_STATE], tuple[_T, _STATE] | None], state: Any) -> Array[Any]:
|
|
806
|
+
res: Array[_T] = []
|
|
807
|
+
|
|
808
|
+
def loop(state_1_mut: _STATE | None = None, generator: Any = generator, state: Any = state) -> None:
|
|
809
|
+
while True:
|
|
810
|
+
(state_1,) = (state_1_mut,)
|
|
811
|
+
match_value: tuple[_T, _STATE] | None = generator(state_1)
|
|
812
|
+
if match_value is not None:
|
|
813
|
+
x: _T = match_value[0]
|
|
814
|
+
s: _STATE = match_value[1]
|
|
815
|
+
ignore(res.append(x))
|
|
816
|
+
state_1_mut = s
|
|
817
|
+
continue
|
|
818
|
+
|
|
819
|
+
break
|
|
820
|
+
|
|
821
|
+
loop(state)
|
|
822
|
+
return res
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
def unzip(array: Array[tuple[__A, __B]]) -> tuple[Array[__A], Array[__B]]:
|
|
826
|
+
len_1: int = len(array) or 0
|
|
827
|
+
res1: Array[__A] = [None] * len_1
|
|
828
|
+
res2: Array[__B] = [None] * len_1
|
|
829
|
+
|
|
830
|
+
def _arrow52(i: int, tupled_arg: tuple[__A, __B], array: Any = array) -> None:
|
|
831
|
+
res1[i] = tupled_arg[0]
|
|
832
|
+
res2[i] = tupled_arg[1]
|
|
833
|
+
|
|
834
|
+
iterate_indexed(_arrow52, array)
|
|
835
|
+
return (res1, res2)
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
def unzip3(array: Array[tuple[__A, __B, __C]]) -> tuple[Array[__A], Array[__B], Array[__C]]:
|
|
839
|
+
len_1: int = len(array) or 0
|
|
840
|
+
res1: Array[__A] = [None] * len_1
|
|
841
|
+
res2: Array[__B] = [None] * len_1
|
|
842
|
+
res3: Array[__C] = [None] * len_1
|
|
843
|
+
|
|
844
|
+
def _arrow53(i: int, tupled_arg: tuple[__A, __B, __C], array: Any = array) -> None:
|
|
845
|
+
res1[i] = tupled_arg[0]
|
|
846
|
+
res2[i] = tupled_arg[1]
|
|
847
|
+
res3[i] = tupled_arg[2]
|
|
848
|
+
|
|
849
|
+
iterate_indexed(_arrow53, array)
|
|
850
|
+
return (res1, res2, res3)
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
def zip(array1: Array[Any], array2: Array[Any]) -> Array[tuple[_T, _U]]:
|
|
854
|
+
if len(array1) != len(array2):
|
|
855
|
+
different_lengths()
|
|
856
|
+
|
|
857
|
+
result: Array[tuple[_T, _U]] = [None] * len(array1)
|
|
858
|
+
for i in range(0, (len(array1) - 1) + 1, 1):
|
|
859
|
+
result[i] = (array1[i], array2[i])
|
|
860
|
+
return result
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
def zip3(array1: Array[Any], array2: Array[Any], array3: Array[Any]) -> Array[tuple[_T, _U, _V]]:
|
|
864
|
+
if True if (len(array1) != len(array2)) else (len(array2) != len(array3)):
|
|
865
|
+
different_lengths()
|
|
866
|
+
|
|
867
|
+
result: Array[tuple[_T, _U, _V]] = [None] * len(array1)
|
|
868
|
+
for i in range(0, (len(array1) - 1) + 1, 1):
|
|
869
|
+
result[i] = (array1[i], array2[i], array3[i])
|
|
870
|
+
return result
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
def chunk_by_size(chunk_size: int, array: Array[Any]) -> Array[Array[Any]]:
|
|
874
|
+
if chunk_size < 1:
|
|
875
|
+
raise Exception("The input must be positive.\\nParameter name: size")
|
|
876
|
+
|
|
877
|
+
if len(array) == 0:
|
|
878
|
+
return [[]]
|
|
879
|
+
|
|
880
|
+
else:
|
|
881
|
+
result: Array[Array[_T]] = []
|
|
882
|
+
for x in range(0, (int(ceil(divide(len(array), chunk_size))) - 1) + 1, 1):
|
|
883
|
+
start: int = (x * chunk_size) or 0
|
|
884
|
+
slice: Array[_T] = array[start : start + chunk_size]
|
|
885
|
+
ignore(result.append(slice))
|
|
886
|
+
return result
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
def split_at(index: int, array: Array[Any]) -> tuple[Array[_T], Array[_T]]:
|
|
890
|
+
if True if (index < 0) else (index > len(array)):
|
|
891
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
892
|
+
|
|
893
|
+
return (array[0 : 0 + index], array[index:])
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
def compare_with(comparer: Callable[[_T, _T], int], source1: Array[Any], source2: Array[Any]) -> int:
|
|
897
|
+
if source1 is None:
|
|
898
|
+
if source2 is None:
|
|
899
|
+
return 0
|
|
900
|
+
|
|
901
|
+
else:
|
|
902
|
+
return -1
|
|
903
|
+
|
|
904
|
+
elif source2 is None:
|
|
905
|
+
return 1
|
|
906
|
+
|
|
907
|
+
else:
|
|
908
|
+
len1: int = len(source1) or 0
|
|
909
|
+
len2: int = len(source2) or 0
|
|
910
|
+
len_1: int = (len1 if (len1 < len2) else len2) or 0
|
|
911
|
+
i: int = 0
|
|
912
|
+
res: int = 0
|
|
913
|
+
while (i < len_1) if (res == 0) else False:
|
|
914
|
+
res = comparer(source1[i], source2[i]) or 0
|
|
915
|
+
i = (i + 1) or 0
|
|
916
|
+
if res != 0:
|
|
917
|
+
return res
|
|
918
|
+
|
|
919
|
+
elif len1 > len2:
|
|
920
|
+
return 1
|
|
921
|
+
|
|
922
|
+
elif len1 < len2:
|
|
923
|
+
return -1
|
|
924
|
+
|
|
925
|
+
else:
|
|
926
|
+
return 0
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
def compare_to(comparer: Callable[[_T, _T], int], source1: Array[Any], source2: Array[Any]) -> int:
|
|
930
|
+
if source1 is None:
|
|
931
|
+
if source2 is None:
|
|
932
|
+
return 0
|
|
933
|
+
|
|
934
|
+
else:
|
|
935
|
+
return -1
|
|
936
|
+
|
|
937
|
+
elif source2 is None:
|
|
938
|
+
return 1
|
|
939
|
+
|
|
940
|
+
else:
|
|
941
|
+
len1: int = len(source1) or 0
|
|
942
|
+
len2: int = len(source2) or 0
|
|
943
|
+
if len1 > len2:
|
|
944
|
+
return 1
|
|
945
|
+
|
|
946
|
+
elif len1 < len2:
|
|
947
|
+
return -1
|
|
948
|
+
|
|
949
|
+
else:
|
|
950
|
+
i: int = 0
|
|
951
|
+
res: int = 0
|
|
952
|
+
while (i < len1) if (res == 0) else False:
|
|
953
|
+
res = comparer(source1[i], source2[i]) or 0
|
|
954
|
+
i = (i + 1) or 0
|
|
955
|
+
return res
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
def equals_with(equals: Callable[[_T, _T], bool], array1: Array[Any], array2: Array[Any]) -> bool:
|
|
959
|
+
if array1 is None:
|
|
960
|
+
if array2 is None:
|
|
961
|
+
return True
|
|
962
|
+
|
|
963
|
+
else:
|
|
964
|
+
return False
|
|
965
|
+
|
|
966
|
+
elif array2 is None:
|
|
967
|
+
return False
|
|
968
|
+
|
|
969
|
+
else:
|
|
970
|
+
i: int = 0
|
|
971
|
+
result: bool = True
|
|
972
|
+
length1: int = len(array1) or 0
|
|
973
|
+
length2: int = len(array2) or 0
|
|
974
|
+
if length1 > length2:
|
|
975
|
+
return False
|
|
976
|
+
|
|
977
|
+
elif length1 < length2:
|
|
978
|
+
return False
|
|
979
|
+
|
|
980
|
+
else:
|
|
981
|
+
while result if (i < length1) else False:
|
|
982
|
+
result = equals(array1[i], array2[i])
|
|
983
|
+
i = (i + 1) or 0
|
|
984
|
+
return result
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
def exactly_one(array: Array[Any]) -> Any:
|
|
988
|
+
if len(array) == 1:
|
|
989
|
+
return array[0]
|
|
990
|
+
|
|
991
|
+
elif len(array) == 0:
|
|
992
|
+
raise Exception("The input sequence was empty\\nParameter name: array")
|
|
993
|
+
|
|
994
|
+
else:
|
|
995
|
+
raise Exception("Input array too long\\nParameter name: array")
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
def try_exactly_one(array: Array[Any]) -> Any | None:
|
|
999
|
+
if len(array) == 1:
|
|
1000
|
+
return some(array[0])
|
|
1001
|
+
|
|
1002
|
+
else:
|
|
1003
|
+
return None
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
def head(array: Array[Any]) -> Any:
|
|
1007
|
+
if len(array) == 0:
|
|
1008
|
+
raise Exception("The input array was empty\\nParameter name: array")
|
|
1009
|
+
|
|
1010
|
+
else:
|
|
1011
|
+
return array[0]
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
def try_head(array: Array[Any]) -> Any | None:
|
|
1015
|
+
if len(array) == 0:
|
|
1016
|
+
return None
|
|
1017
|
+
|
|
1018
|
+
else:
|
|
1019
|
+
return some(array[0])
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
def tail(array: Array[Any]) -> Array[Any]:
|
|
1023
|
+
if len(array) == 0:
|
|
1024
|
+
raise Exception("Not enough elements\\nParameter name: array")
|
|
1025
|
+
|
|
1026
|
+
return array[1:]
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
def item(index: int, array: Array[Any]) -> Any:
|
|
1030
|
+
return array[index]
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
def try_item(index: int, array: Array[Any]) -> Any | None:
|
|
1034
|
+
if True if (index < 0) else (index >= len(array)):
|
|
1035
|
+
return None
|
|
1036
|
+
|
|
1037
|
+
else:
|
|
1038
|
+
return some(array[index])
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
def fold_back_indexed(folder: Callable[[int, _T, _STATE], _STATE], array: Array[Any], state: Any) -> Any:
|
|
1042
|
+
def _arrow54(
|
|
1043
|
+
delegate_arg: _STATE,
|
|
1044
|
+
delegate_arg_1: _T,
|
|
1045
|
+
delegate_arg_2: int,
|
|
1046
|
+
folder: Any = folder,
|
|
1047
|
+
array: Any = array,
|
|
1048
|
+
state: Any = state,
|
|
1049
|
+
) -> _STATE:
|
|
1050
|
+
return folder(delegate_arg_2, delegate_arg_1, delegate_arg)
|
|
1051
|
+
|
|
1052
|
+
return array.reduceRight((_arrow54, state))
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
def fold_back(folder: Callable[[_T, _STATE], _STATE], array: Array[Any], state: Any) -> Any:
|
|
1056
|
+
def _arrow55(acc: _STATE, x: _T, folder: Any = folder, array: Any = array, state: Any = state) -> _STATE:
|
|
1057
|
+
return folder(x, acc)
|
|
1058
|
+
|
|
1059
|
+
return functools.reduce(_arrow55, array[::-1], state)
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
def fold_indexed2(
|
|
1063
|
+
folder: Callable[[int, __A, __B, __C], __A], state: Any, array1: Array[Any], array2: Array[Any]
|
|
1064
|
+
) -> Any:
|
|
1065
|
+
acc: __A = state
|
|
1066
|
+
if len(array1) != len(array2):
|
|
1067
|
+
raise Exception("Arrays have different lengths")
|
|
1068
|
+
|
|
1069
|
+
for i in range(0, (len(array1) - 1) + 1, 1):
|
|
1070
|
+
acc = folder(i, acc, array1[i], array2[i])
|
|
1071
|
+
return acc
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
def fold2(folder: Callable[[_STATE, _T1, _T2], _STATE], state: Any, array1: Array[Any], array2: Array[Any]) -> Any:
|
|
1075
|
+
def _arrow56(
|
|
1076
|
+
_arg: int,
|
|
1077
|
+
acc: _STATE,
|
|
1078
|
+
x: _T1,
|
|
1079
|
+
y: _T2,
|
|
1080
|
+
folder: Any = folder,
|
|
1081
|
+
state: Any = state,
|
|
1082
|
+
array1: Any = array1,
|
|
1083
|
+
array2: Any = array2,
|
|
1084
|
+
) -> _STATE:
|
|
1085
|
+
return folder(acc, x, y)
|
|
1086
|
+
|
|
1087
|
+
return fold_indexed2(_arrow56, state, array1, array2)
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
def fold_back_indexed2(
|
|
1091
|
+
folder: Callable[[int, _T1, _T2, _STATE], _STATE], array1: Array[Any], array2: Array[Any], state: Any
|
|
1092
|
+
) -> Any:
|
|
1093
|
+
acc: _STATE = state
|
|
1094
|
+
if len(array1) != len(array2):
|
|
1095
|
+
different_lengths()
|
|
1096
|
+
|
|
1097
|
+
size: int = len(array1) or 0
|
|
1098
|
+
for i in range(1, size + 1, 1):
|
|
1099
|
+
acc = folder(i - 1, array1[size - i], array2[size - i], acc)
|
|
1100
|
+
return acc
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
def fold_back2(f: Callable[[_T1, _T2, _STATE], _STATE], array1: Array[Any], array2: Array[Any], state: Any) -> Any:
|
|
1104
|
+
def _arrow57(
|
|
1105
|
+
_arg: int,
|
|
1106
|
+
x: _T1,
|
|
1107
|
+
y: _T2,
|
|
1108
|
+
acc: _STATE,
|
|
1109
|
+
f: Any = f,
|
|
1110
|
+
array1: Any = array1,
|
|
1111
|
+
array2: Any = array2,
|
|
1112
|
+
state: Any = state,
|
|
1113
|
+
) -> _STATE:
|
|
1114
|
+
return f(x, y, acc)
|
|
1115
|
+
|
|
1116
|
+
return fold_back_indexed2(_arrow57, array1, array2, state)
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
def reduce(reduction: Callable[[_T, _T], _T], array: Array[Any]) -> Any:
|
|
1120
|
+
if len(array) == 0:
|
|
1121
|
+
raise Exception("The input array was empty")
|
|
1122
|
+
|
|
1123
|
+
return functools.reduce(reduction, array)
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
def reduce_back(reduction: Callable[[_T, _T], _T], array: Array[Any]) -> Any:
|
|
1127
|
+
if len(array) == 0:
|
|
1128
|
+
raise Exception("The input array was empty")
|
|
1129
|
+
|
|
1130
|
+
return functools.reduce(reduction, array[::-1])
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
def for_all2(predicate: Callable[[__A, __B], bool], array1: Array[Any], array2: Array[Any]) -> bool:
|
|
1134
|
+
def _arrow58(
|
|
1135
|
+
acc: bool, x: __A, y: __B, predicate: Any = predicate, array1: Any = array1, array2: Any = array2
|
|
1136
|
+
) -> bool:
|
|
1137
|
+
return predicate(x, y) if acc else False
|
|
1138
|
+
|
|
1139
|
+
return fold2(_arrow58, True, array1, array2)
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
def exists_offset(predicate_mut: Callable[[_T], bool], array_mut: Array[Any], index_mut: int) -> bool:
|
|
1143
|
+
while True:
|
|
1144
|
+
(predicate, array, index) = (predicate_mut, array_mut, index_mut)
|
|
1145
|
+
if index == len(array):
|
|
1146
|
+
return False
|
|
1147
|
+
|
|
1148
|
+
elif predicate(array[index]):
|
|
1149
|
+
return True
|
|
1150
|
+
|
|
1151
|
+
else:
|
|
1152
|
+
predicate_mut = predicate
|
|
1153
|
+
array_mut = array
|
|
1154
|
+
index_mut = index + 1
|
|
1155
|
+
continue
|
|
1156
|
+
|
|
1157
|
+
break
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
def exists(predicate: Callable[[__A], bool], array: Array[Any]) -> bool:
|
|
1161
|
+
return exists_offset(predicate, array, 0)
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
def exists_offset2(
|
|
1165
|
+
predicate_mut: Callable[[__A, __B], bool], array1_mut: Array[Any], array2_mut: Array[Any], index_mut: int
|
|
1166
|
+
) -> bool:
|
|
1167
|
+
while True:
|
|
1168
|
+
(predicate, array1, array2, index) = (predicate_mut, array1_mut, array2_mut, index_mut)
|
|
1169
|
+
if index == len(array1):
|
|
1170
|
+
return False
|
|
1171
|
+
|
|
1172
|
+
elif predicate(array1[index], array2[index]):
|
|
1173
|
+
return True
|
|
1174
|
+
|
|
1175
|
+
else:
|
|
1176
|
+
predicate_mut = predicate
|
|
1177
|
+
array1_mut = array1
|
|
1178
|
+
array2_mut = array2
|
|
1179
|
+
index_mut = index + 1
|
|
1180
|
+
continue
|
|
1181
|
+
|
|
1182
|
+
break
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
def exists2(predicate: Callable[[__A, __B], bool], array1: Array[Any], array2: Array[Any]) -> bool:
|
|
1186
|
+
if len(array1) != len(array2):
|
|
1187
|
+
different_lengths()
|
|
1188
|
+
|
|
1189
|
+
return exists_offset2(predicate, array1, array2, 0)
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
def sum(array: Array[Any], adder: IGenericAdder_1[Any]) -> Any:
|
|
1193
|
+
acc: _T = adder.GetZero()
|
|
1194
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
1195
|
+
acc = adder.Add(acc, array[i])
|
|
1196
|
+
return acc
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
def sum_by(projection: Callable[[_T], _T2], array: Array[Any], adder: IGenericAdder_1[Any]) -> Any:
|
|
1200
|
+
acc: _T2 = adder.GetZero()
|
|
1201
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
1202
|
+
acc = adder.Add(acc, projection(array[i]))
|
|
1203
|
+
return acc
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
def max_by(projection: Callable[[_A], _B], xs: Array[Any], comparer: IComparer_1[Any]) -> Any:
|
|
1207
|
+
def _arrow59(x: _A, y: _A, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> _A:
|
|
1208
|
+
return y if (comparer.Compare(projection(y), projection(x)) > 0) else x
|
|
1209
|
+
|
|
1210
|
+
return reduce(_arrow59, xs)
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
def max(xs: Array[Any], comparer: IComparer_1[Any]) -> Any:
|
|
1214
|
+
def _arrow60(x: _A, y: _A, xs: Any = xs, comparer: Any = comparer) -> _A:
|
|
1215
|
+
return y if (comparer.Compare(y, x) > 0) else x
|
|
1216
|
+
|
|
1217
|
+
return reduce(_arrow60, xs)
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
def min_by(projection: Callable[[_A], _B], xs: Array[Any], comparer: IComparer_1[Any]) -> Any:
|
|
1221
|
+
def _arrow61(x: _A, y: _A, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> _A:
|
|
1222
|
+
return x if (comparer.Compare(projection(y), projection(x)) > 0) else y
|
|
1223
|
+
|
|
1224
|
+
return reduce(_arrow61, xs)
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
def min(xs: Array[Any], comparer: IComparer_1[Any]) -> Any:
|
|
1228
|
+
def _arrow62(x: _A, y: _A, xs: Any = xs, comparer: Any = comparer) -> _A:
|
|
1229
|
+
return x if (comparer.Compare(y, x) > 0) else y
|
|
1230
|
+
|
|
1231
|
+
return reduce(_arrow62, xs)
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
def average(array: Array[Any], averager: IGenericAverager_1[Any]) -> Any:
|
|
1235
|
+
if len(array) == 0:
|
|
1236
|
+
raise Exception("The input array was empty\\nParameter name: array")
|
|
1237
|
+
|
|
1238
|
+
total: _T = averager.GetZero()
|
|
1239
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
1240
|
+
total = averager.Add(total, array[i])
|
|
1241
|
+
return averager.DivideByInt(total, len(array))
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
def average_by(projection: Callable[[_T], _T2], array: Array[Any], averager: IGenericAverager_1[Any]) -> Any:
|
|
1245
|
+
if len(array) == 0:
|
|
1246
|
+
raise Exception("The input array was empty\\nParameter name: array")
|
|
1247
|
+
|
|
1248
|
+
total: _T2 = averager.GetZero()
|
|
1249
|
+
for i in range(0, (len(array) - 1) + 1, 1):
|
|
1250
|
+
total = averager.Add(total, projection(array[i]))
|
|
1251
|
+
return averager.DivideByInt(total, len(array))
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
def windowed(window_size: int, source: Array[Any]) -> Array[Array[Any]]:
|
|
1255
|
+
if window_size <= 0:
|
|
1256
|
+
raise Exception("windowSize must be positive")
|
|
1257
|
+
|
|
1258
|
+
res: Array[Array[_T]]
|
|
1259
|
+
|
|
1260
|
+
def _arrow63(x: int, y: int, window_size: Any = window_size, source: Any = source) -> int:
|
|
1261
|
+
return compare_primitives(x, y)
|
|
1262
|
+
|
|
1263
|
+
len_1: int = max_1(_arrow63, 0, (len(source) - window_size) + 1) or 0
|
|
1264
|
+
res = [None] * len_1
|
|
1265
|
+
for i in range(window_size, len(source) + 1, 1):
|
|
1266
|
+
res[i - window_size] = source[i - window_size : (i - 1) + 1]
|
|
1267
|
+
return res
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
def split_into(chunks: int, array: Array[Any]) -> Array[Array[Any]]:
|
|
1271
|
+
if chunks < 1:
|
|
1272
|
+
raise Exception("The input must be positive.\\nParameter name: chunks")
|
|
1273
|
+
|
|
1274
|
+
if len(array) == 0:
|
|
1275
|
+
return [[]]
|
|
1276
|
+
|
|
1277
|
+
else:
|
|
1278
|
+
result: Array[Array[_T]] = []
|
|
1279
|
+
|
|
1280
|
+
def _arrow64(x: int, y: int, chunks: Any = chunks, array: Any = array) -> int:
|
|
1281
|
+
return compare_primitives(x, y)
|
|
1282
|
+
|
|
1283
|
+
chunks_1: int = min_1(_arrow64, chunks, len(array)) or 0
|
|
1284
|
+
min_chunk_size: int = (len(array) // chunks_1) or 0
|
|
1285
|
+
chunks_with_extra_item: int = (len(array) % chunks_1) or 0
|
|
1286
|
+
for i in range(0, (chunks_1 - 1) + 1, 1):
|
|
1287
|
+
chunk_size: int = ((min_chunk_size + 1) if (i < chunks_with_extra_item) else min_chunk_size) or 0
|
|
1288
|
+
|
|
1289
|
+
def _arrow65(x_1: int, y_1: int, chunks: Any = chunks, array: Any = array) -> int:
|
|
1290
|
+
return compare_primitives(x_1, y_1)
|
|
1291
|
+
|
|
1292
|
+
start: int = ((i * min_chunk_size) + min_1(_arrow65, chunks_with_extra_item, i)) or 0
|
|
1293
|
+
slice: Array[_T] = array[start : start + chunk_size]
|
|
1294
|
+
ignore(result.append(slice))
|
|
1295
|
+
return result
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
def transpose(arrays: IEnumerable_1[Array[Any]], cons: Cons_1[Any]) -> Array[Array[Any]]:
|
|
1299
|
+
arrays_1: Array[Array[_T]] = arrays if (isinstance(arrays, list)) else (list(arrays))
|
|
1300
|
+
len_1: int = len(arrays_1) or 0
|
|
1301
|
+
if len_1 == 0:
|
|
1302
|
+
return [None] * 0
|
|
1303
|
+
|
|
1304
|
+
else:
|
|
1305
|
+
len_inner: int = len(arrays_1[0]) or 0
|
|
1306
|
+
|
|
1307
|
+
def predicate(a: Array[_T], arrays: Any = arrays, cons: Any = cons) -> bool:
|
|
1308
|
+
return len(a) == len_inner
|
|
1309
|
+
|
|
1310
|
+
if not for_all(predicate, arrays_1):
|
|
1311
|
+
different_lengths()
|
|
1312
|
+
|
|
1313
|
+
result: Array[Array[_T]] = [None] * len_inner
|
|
1314
|
+
for i in range(0, (len_inner - 1) + 1, 1):
|
|
1315
|
+
result[i] = Helpers_allocateArrayFromCons(cons, len_1)
|
|
1316
|
+
for j in range(0, (len_1 - 1) + 1, 1):
|
|
1317
|
+
result[i][j] = arrays_1[j][i]
|
|
1318
|
+
return result
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
def insert_at(index: int, y: Any, xs: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
1322
|
+
len_1: int = len(xs) or 0
|
|
1323
|
+
if True if (index < 0) else (index > len_1):
|
|
1324
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1325
|
+
|
|
1326
|
+
target: Array[_T] = Helpers_allocateArrayFromCons(cons, len_1 + 1)
|
|
1327
|
+
for i in range(0, (index - 1) + 1, 1):
|
|
1328
|
+
target[i] = xs[i]
|
|
1329
|
+
target[index] = y
|
|
1330
|
+
for i_1 in range(index, (len_1 - 1) + 1, 1):
|
|
1331
|
+
target[i_1 + 1] = xs[i_1]
|
|
1332
|
+
return target
|
|
1333
|
+
|
|
1334
|
+
|
|
1335
|
+
def insert_many_at(index: int, ys: IEnumerable_1[Any], xs: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
1336
|
+
len_1: int = len(xs) or 0
|
|
1337
|
+
if True if (index < 0) else (index > len_1):
|
|
1338
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1339
|
+
|
|
1340
|
+
ys_1: Array[_T] = list(ys)
|
|
1341
|
+
len2: int = len(ys_1) or 0
|
|
1342
|
+
target: Array[_T] = Helpers_allocateArrayFromCons(cons, len_1 + len2)
|
|
1343
|
+
for i in range(0, (index - 1) + 1, 1):
|
|
1344
|
+
target[i] = xs[i]
|
|
1345
|
+
for i_1 in range(0, (len2 - 1) + 1, 1):
|
|
1346
|
+
target[index + i_1] = ys_1[i_1]
|
|
1347
|
+
for i_2 in range(index, (len_1 - 1) + 1, 1):
|
|
1348
|
+
target[i_2 + len2] = xs[i_2]
|
|
1349
|
+
return target
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
def remove_at(index: int, xs: Array[Any]) -> Array[Any]:
|
|
1353
|
+
if True if (index < 0) else (index >= len(xs)):
|
|
1354
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1355
|
+
|
|
1356
|
+
i: int = -1
|
|
1357
|
+
|
|
1358
|
+
def predicate(_arg: _T | None = None, index: Any = index, xs: Any = xs) -> bool:
|
|
1359
|
+
nonlocal i
|
|
1360
|
+
i = (i + 1) or 0
|
|
1361
|
+
return i != index
|
|
1362
|
+
|
|
1363
|
+
return filter(predicate, xs)
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
def remove_many_at(index: int, count: int, xs: Array[Any]) -> Array[Any]:
|
|
1367
|
+
i: int = -1
|
|
1368
|
+
status: int = -1
|
|
1369
|
+
|
|
1370
|
+
def predicate(_arg: _T | None = None, index: Any = index, count: Any = count, xs: Any = xs) -> bool:
|
|
1371
|
+
nonlocal i, status
|
|
1372
|
+
i = (i + 1) or 0
|
|
1373
|
+
if i == index:
|
|
1374
|
+
status = 0
|
|
1375
|
+
return False
|
|
1376
|
+
|
|
1377
|
+
elif i > index:
|
|
1378
|
+
if i < (index + count):
|
|
1379
|
+
return False
|
|
1380
|
+
|
|
1381
|
+
else:
|
|
1382
|
+
status = 1
|
|
1383
|
+
return True
|
|
1384
|
+
|
|
1385
|
+
else:
|
|
1386
|
+
return True
|
|
1387
|
+
|
|
1388
|
+
ys: Array[_T] = filter(predicate, xs)
|
|
1389
|
+
status_1: int = (1 if (((i + 1) == (index + count)) if (status == 0) else False) else status) or 0
|
|
1390
|
+
if status_1 < 1:
|
|
1391
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + ("index" if (status_1 < 0) else "count"))
|
|
1392
|
+
|
|
1393
|
+
return ys
|
|
1394
|
+
|
|
1395
|
+
|
|
1396
|
+
def update_at(index: int, y: Any, xs: Array[Any], cons: Cons_1[Any]) -> Array[Any]:
|
|
1397
|
+
len_1: int = len(xs) or 0
|
|
1398
|
+
if True if (index < 0) else (index >= len_1):
|
|
1399
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1400
|
+
|
|
1401
|
+
target: Array[_T] = Helpers_allocateArrayFromCons(cons, len_1)
|
|
1402
|
+
for i in range(0, (len_1 - 1) + 1, 1):
|
|
1403
|
+
target[i] = y if (i == index) else xs[i]
|
|
1404
|
+
return target
|
|
1405
|
+
|
|
1406
|
+
|
|
1407
|
+
__all__ = [
|
|
1408
|
+
"index_not_found",
|
|
1409
|
+
"different_lengths",
|
|
1410
|
+
"append",
|
|
1411
|
+
"filter",
|
|
1412
|
+
"fill",
|
|
1413
|
+
"get_sub_array",
|
|
1414
|
+
"last",
|
|
1415
|
+
"try_last",
|
|
1416
|
+
"map_indexed",
|
|
1417
|
+
"map",
|
|
1418
|
+
"map_indexed2",
|
|
1419
|
+
"map2",
|
|
1420
|
+
"map_indexed3",
|
|
1421
|
+
"map3",
|
|
1422
|
+
"map_fold",
|
|
1423
|
+
"map_fold_back",
|
|
1424
|
+
"indexed",
|
|
1425
|
+
"truncate",
|
|
1426
|
+
"concat",
|
|
1427
|
+
"collect",
|
|
1428
|
+
"where",
|
|
1429
|
+
"index_of",
|
|
1430
|
+
"contains",
|
|
1431
|
+
"empty",
|
|
1432
|
+
"singleton",
|
|
1433
|
+
"initialize",
|
|
1434
|
+
"pairwise",
|
|
1435
|
+
"replicate",
|
|
1436
|
+
"copy",
|
|
1437
|
+
"copy_to",
|
|
1438
|
+
"reverse",
|
|
1439
|
+
"scan",
|
|
1440
|
+
"scan_back",
|
|
1441
|
+
"skip",
|
|
1442
|
+
"skip_while",
|
|
1443
|
+
"take",
|
|
1444
|
+
"take_while",
|
|
1445
|
+
"add_in_place",
|
|
1446
|
+
"add_range_in_place",
|
|
1447
|
+
"insert_range_in_place",
|
|
1448
|
+
"remove_in_place",
|
|
1449
|
+
"remove_all_in_place",
|
|
1450
|
+
"partition",
|
|
1451
|
+
"find",
|
|
1452
|
+
"try_find",
|
|
1453
|
+
"find_index",
|
|
1454
|
+
"try_find_index",
|
|
1455
|
+
"pick",
|
|
1456
|
+
"try_pick",
|
|
1457
|
+
"find_back",
|
|
1458
|
+
"try_find_back",
|
|
1459
|
+
"find_last_index",
|
|
1460
|
+
"find_index_back",
|
|
1461
|
+
"try_find_index_back",
|
|
1462
|
+
"choose",
|
|
1463
|
+
"fold_indexed",
|
|
1464
|
+
"fold",
|
|
1465
|
+
"iterate",
|
|
1466
|
+
"iterate_indexed",
|
|
1467
|
+
"iterate2",
|
|
1468
|
+
"iterate_indexed2",
|
|
1469
|
+
"is_empty",
|
|
1470
|
+
"for_all",
|
|
1471
|
+
"permute",
|
|
1472
|
+
"set_slice",
|
|
1473
|
+
"sort_in_place_by",
|
|
1474
|
+
"sort_in_place",
|
|
1475
|
+
"sort_in_place_with",
|
|
1476
|
+
"sort",
|
|
1477
|
+
"sort_by",
|
|
1478
|
+
"sort_descending",
|
|
1479
|
+
"sort_by_descending",
|
|
1480
|
+
"sort_with",
|
|
1481
|
+
"all_pairs",
|
|
1482
|
+
"unfold",
|
|
1483
|
+
"unzip",
|
|
1484
|
+
"unzip3",
|
|
1485
|
+
"zip",
|
|
1486
|
+
"zip3",
|
|
1487
|
+
"chunk_by_size",
|
|
1488
|
+
"split_at",
|
|
1489
|
+
"compare_with",
|
|
1490
|
+
"compare_to",
|
|
1491
|
+
"equals_with",
|
|
1492
|
+
"exactly_one",
|
|
1493
|
+
"try_exactly_one",
|
|
1494
|
+
"head",
|
|
1495
|
+
"try_head",
|
|
1496
|
+
"tail",
|
|
1497
|
+
"item",
|
|
1498
|
+
"try_item",
|
|
1499
|
+
"fold_back_indexed",
|
|
1500
|
+
"fold_back",
|
|
1501
|
+
"fold_indexed2",
|
|
1502
|
+
"fold2",
|
|
1503
|
+
"fold_back_indexed2",
|
|
1504
|
+
"fold_back2",
|
|
1505
|
+
"reduce",
|
|
1506
|
+
"reduce_back",
|
|
1507
|
+
"for_all2",
|
|
1508
|
+
"exists_offset",
|
|
1509
|
+
"exists",
|
|
1510
|
+
"exists_offset2",
|
|
1511
|
+
"exists2",
|
|
1512
|
+
"sum",
|
|
1513
|
+
"sum_by",
|
|
1514
|
+
"max_by",
|
|
1515
|
+
"max",
|
|
1516
|
+
"min_by",
|
|
1517
|
+
"min",
|
|
1518
|
+
"average",
|
|
1519
|
+
"average_by",
|
|
1520
|
+
"windowed",
|
|
1521
|
+
"split_into",
|
|
1522
|
+
"transpose",
|
|
1523
|
+
"insert_at",
|
|
1524
|
+
"insert_many_at",
|
|
1525
|
+
"remove_at",
|
|
1526
|
+
"remove_many_at",
|
|
1527
|
+
"update_at",
|
|
1528
|
+
]
|