arctrl 3.0.0a3__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 +18 -0
- arctrl/py/CWL/__init__.py +0 -0
- arctrl/py/CWL/cwltypes.py +150 -0
- arctrl/py/CWL/decode.py +973 -0
- arctrl/py/CWL/encode.py +1 -0
- arctrl/py/CWL/inputs.py +88 -0
- arctrl/py/CWL/outputs.py +85 -0
- arctrl/py/CWL/requirements.py +77 -0
- arctrl/py/CWL/tool_description.py +103 -0
- arctrl/py/CWL/workflow_description.py +104 -0
- arctrl/py/CWL/workflow_steps.py +113 -0
- arctrl/py/Contract/__init__.py +0 -0
- arctrl/py/Contract/arc.py +60 -0
- arctrl/py/Contract/arc_assay.py +125 -0
- arctrl/py/Contract/arc_investigation.py +88 -0
- arctrl/py/Contract/arc_run.py +125 -0
- arctrl/py/Contract/arc_study.py +126 -0
- arctrl/py/Contract/arc_workflow.py +125 -0
- arctrl/py/Contract/contract.py +153 -0
- arctrl/py/Contract/datamap.py +372 -0
- arctrl/py/Contract/git.py +118 -0
- arctrl/py/Contract/validation_packages_config.py +107 -0
- arctrl/py/ContractIO/__init__.py +0 -0
- arctrl/py/ContractIO/contract_io.py +344 -0
- arctrl/py/ContractIO/file_system_helper.py +264 -0
- arctrl/py/Core/Helper/__init__.py +0 -0
- arctrl/py/Core/Helper/collections_.py +438 -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 +248 -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 +1264 -0
- arctrl/py/Core/Table/arc_table_aux.py +575 -0
- arctrl/py/Core/Table/arc_tables.py +591 -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 +5064 -0
- arctrl/py/Core/comment.py +128 -0
- arctrl/py/Core/comment_list.py +127 -0
- arctrl/py/Core/conversion.py +1313 -0
- arctrl/py/Core/data.py +245 -0
- arctrl/py/Core/data_context.py +157 -0
- arctrl/py/Core/data_file.py +112 -0
- arctrl/py/Core/data_map.py +225 -0
- arctrl/py/Core/identifier_setters.py +31 -0
- arctrl/py/Core/iproperty_value.py +36 -0
- arctrl/py/Core/ontology_annotation.py +299 -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 +5 -0
- arctrl/py/FileSystem/default_gitignore.py +5 -0
- arctrl/py/FileSystem/file_system.py +58 -0
- arctrl/py/FileSystem/file_system_tree.py +426 -0
- arctrl/py/FileSystem/path.py +64 -0
- arctrl/py/Json/DataMap/__init__.py +0 -0
- arctrl/py/Json/DataMap/data_context.py +101 -0
- arctrl/py/Json/DataMap/data_map.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 +79 -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 +79 -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 +133 -0
- arctrl/py/Json/ROCrate/ldgraph.py +111 -0
- arctrl/py/Json/ROCrate/ldnode.py +290 -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 +393 -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 +155 -0
- arctrl/py/Json/encode.py +92 -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/string_table.py +76 -0
- arctrl/py/Json/study.py +793 -0
- arctrl/py/JsonIO/DataMap/__init__.py +0 -0
- arctrl/py/JsonIO/DataMap/data_map.py +53 -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 +121 -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 +85 -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/decode.py +9 -0
- arctrl/py/JsonIO/encode.py +1 -0
- arctrl/py/JsonIO/investigation.py +113 -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/study.py +114 -0
- arctrl/py/ROCrate/Generic/__init__.py +0 -0
- arctrl/py/ROCrate/Generic/comment.py +131 -0
- arctrl/py/ROCrate/Generic/dataset.py +817 -0
- arctrl/py/ROCrate/Generic/defined_term.py +131 -0
- arctrl/py/ROCrate/Generic/file.py +237 -0
- arctrl/py/ROCrate/Generic/lab_process.py +324 -0
- arctrl/py/ROCrate/Generic/lab_protocol.py +338 -0
- arctrl/py/ROCrate/Generic/organization.py +83 -0
- arctrl/py/ROCrate/Generic/person.py +484 -0
- arctrl/py/ROCrate/Generic/postal_address.py +195 -0
- arctrl/py/ROCrate/Generic/property_value.py +696 -0
- arctrl/py/ROCrate/Generic/sample.py +202 -0
- arctrl/py/ROCrate/Generic/scholarly_article.py +229 -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/__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 +362 -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 +193 -0
- arctrl/py/Spreadsheet/AnnotationTable/composite_cell.py +78 -0
- arctrl/py/Spreadsheet/AnnotationTable/composite_column.py +210 -0
- arctrl/py/Spreadsheet/AnnotationTable/composite_header.py +623 -0
- arctrl/py/Spreadsheet/DataMapTable/__init__.py +0 -0
- arctrl/py/Spreadsheet/DataMapTable/data_map_column.py +114 -0
- arctrl/py/Spreadsheet/DataMapTable/data_map_header.py +618 -0
- arctrl/py/Spreadsheet/DataMapTable/data_map_table.py +119 -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 +508 -0
- arctrl/py/Spreadsheet/Metadata/study.py +312 -0
- arctrl/py/Spreadsheet/Metadata/workflow.py +151 -0
- arctrl/py/Spreadsheet/__init__.py +0 -0
- arctrl/py/Spreadsheet/arc_assay.py +233 -0
- arctrl/py/Spreadsheet/arc_investigation.py +418 -0
- arctrl/py/Spreadsheet/arc_run.py +190 -0
- arctrl/py/Spreadsheet/arc_study.py +144 -0
- arctrl/py/Spreadsheet/arc_workflow.py +176 -0
- arctrl/py/Spreadsheet/assembly_info.py +1 -0
- arctrl/py/Spreadsheet/collection_aux.py +167 -0
- arctrl/py/Spreadsheet/data_map.py +44 -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/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 +1400 -0
- arctrl/py/column_index.py +280 -0
- arctrl/py/conversion.py +2184 -0
- arctrl/py/cross_async.py +76 -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 +338 -0
- arctrl/py/fable_modules/fs_spreadsheet/Cells/fs_cells_collection.py +469 -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 +464 -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 +57 -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 +217 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range.py +47 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_address.py +186 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_base.py +90 -0
- arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_column.py +78 -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 +393 -0
- arctrl/py/fable_modules/fs_spreadsheet/Tables/fs_table_field.py +127 -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 +218 -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 +180 -0
- arctrl/py/fable_modules/fs_spreadsheet/fs_worksheet.py +600 -0
- arctrl/py/fable_modules/fs_spreadsheet/sheet_builder.py +330 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/__init__.py +0 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/cell.py +63 -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 +53 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/workbook.py +40 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/worksheet.py +54 -0
- arctrl/py/fable_modules/fs_spreadsheet_py/xlsx.py +37 -0
- arctrl/py/fable_modules/thoth_json_core/__init__.py +0 -0
- arctrl/py/fable_modules/thoth_json_core/decode.py +1588 -0
- arctrl/py/fable_modules/thoth_json_core/encode.py +261 -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/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 +665 -0
- arctrl/py/fable_modules/yamlicious/regex.py +21 -0
- arctrl/py/fable_modules/yamlicious/regex_active_patterns.py +256 -0
- arctrl/py/fable_modules/yamlicious/writer.py +175 -0
- arctrl/py/fable_modules/yamlicious/yamlicious_types.py +128 -0
- arctrl/py/json.py +213 -0
- arctrl/py/rocrate_io.py +72 -0
- arctrl/py/template_web.py +23 -0
- arctrl/py/xlsx.py +148 -0
- arctrl/rocrate.py +21 -0
- arctrl-3.0.0a3.dist-info/LICENSE +21 -0
- arctrl-3.0.0a3.dist-info/METADATA +119 -0
- arctrl-3.0.0a3.dist-info/RECORD +456 -0
- arctrl-3.0.0a3.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,1979 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from typing import Any, Generic, TypeVar
|
|
5
|
+
|
|
6
|
+
from .array_ import chunk_by_size as chunk_by_size_1
|
|
7
|
+
from .array_ import fold_back as fold_back_1
|
|
8
|
+
from .array_ import fold_back2 as fold_back2_1
|
|
9
|
+
from .array_ import map as map_1
|
|
10
|
+
from .array_ import map_fold as map_fold_1
|
|
11
|
+
from .array_ import map_fold_back as map_fold_back_1
|
|
12
|
+
from .array_ import pairwise as pairwise_1
|
|
13
|
+
from .array_ import permute as permute_1
|
|
14
|
+
from .array_ import reduce_back as reduce_back_1
|
|
15
|
+
from .array_ import reverse as reverse_1
|
|
16
|
+
from .array_ import scan_back as scan_back_1
|
|
17
|
+
from .array_ import singleton as singleton_1
|
|
18
|
+
from .array_ import sort_in_place_with
|
|
19
|
+
from .array_ import split_into as split_into_1
|
|
20
|
+
from .array_ import transpose as transpose_1
|
|
21
|
+
from .array_ import try_find_back as try_find_back_1
|
|
22
|
+
from .array_ import try_find_index_back as try_find_index_back_1
|
|
23
|
+
from .array_ import try_head as try_head_1
|
|
24
|
+
from .array_ import try_item as try_item_1
|
|
25
|
+
from .array_ import windowed as windowed_1
|
|
26
|
+
from .fsharp_core import Operators_NullArg
|
|
27
|
+
from .global_ import IGenericAdder_1, IGenericAverager_1, SR_indexOutOfBounds
|
|
28
|
+
from .list import FSharpList
|
|
29
|
+
from .list import is_empty as is_empty_1
|
|
30
|
+
from .list import length as length_1
|
|
31
|
+
from .list import of_array as of_array_1
|
|
32
|
+
from .list import of_seq as of_seq_1
|
|
33
|
+
from .list import to_array as to_array_1
|
|
34
|
+
from .list import try_head as try_head_2
|
|
35
|
+
from .list import try_item as try_item_2
|
|
36
|
+
from .option import some
|
|
37
|
+
from .option import value as value_1
|
|
38
|
+
from .reflection import TypeInfo, class_type
|
|
39
|
+
from .types import Array, to_string
|
|
40
|
+
from .util import (
|
|
41
|
+
IComparer_1,
|
|
42
|
+
IDisposable,
|
|
43
|
+
IEnumerable_1,
|
|
44
|
+
IEnumerator,
|
|
45
|
+
IEqualityComparer_1,
|
|
46
|
+
clear,
|
|
47
|
+
equals,
|
|
48
|
+
get_enumerator,
|
|
49
|
+
ignore,
|
|
50
|
+
is_array_like,
|
|
51
|
+
is_disposable,
|
|
52
|
+
lock,
|
|
53
|
+
to_enumerable,
|
|
54
|
+
to_iterator,
|
|
55
|
+
)
|
|
56
|
+
from .util import dispose as dispose_2
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
_T = TypeVar("_T")
|
|
60
|
+
|
|
61
|
+
_U = TypeVar("_U")
|
|
62
|
+
|
|
63
|
+
_STATE = TypeVar("_STATE")
|
|
64
|
+
|
|
65
|
+
__B = TypeVar("__B")
|
|
66
|
+
|
|
67
|
+
__A = TypeVar("__A")
|
|
68
|
+
|
|
69
|
+
_T1 = TypeVar("_T1")
|
|
70
|
+
|
|
71
|
+
_T2 = TypeVar("_T2")
|
|
72
|
+
|
|
73
|
+
_T3 = TypeVar("_T3")
|
|
74
|
+
|
|
75
|
+
_RESULT = TypeVar("_RESULT")
|
|
76
|
+
|
|
77
|
+
_COLLECTION = TypeVar("_COLLECTION")
|
|
78
|
+
|
|
79
|
+
SR_enumerationAlreadyFinished: str = "Enumeration already finished."
|
|
80
|
+
|
|
81
|
+
SR_enumerationNotStarted: str = "Enumeration has not started. Call MoveNext."
|
|
82
|
+
|
|
83
|
+
SR_inputSequenceEmpty: str = "The input sequence was empty."
|
|
84
|
+
|
|
85
|
+
SR_inputSequenceTooLong: str = "The input sequence contains more than one element."
|
|
86
|
+
|
|
87
|
+
SR_keyNotFoundAlt: str = "An index satisfying the predicate was not found in the collection."
|
|
88
|
+
|
|
89
|
+
SR_notEnoughElements: str = "The input sequence has an insufficient number of elements."
|
|
90
|
+
|
|
91
|
+
SR_resetNotSupported: str = "Reset is not supported on this enumerator."
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def Enumerator_noReset(__unit: None = None) -> Any:
|
|
95
|
+
raise Exception(SR_resetNotSupported)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def Enumerator_notStarted(__unit: None = None) -> Any:
|
|
99
|
+
raise Exception(SR_enumerationNotStarted)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def Enumerator_alreadyFinished(__unit: None = None) -> Any:
|
|
103
|
+
raise Exception(SR_enumerationAlreadyFinished)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _expr134(gen0: TypeInfo) -> TypeInfo:
|
|
107
|
+
return class_type("SeqModule.Enumerator.Seq", [gen0], Enumerator_Seq)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class Enumerator_Seq(Generic[_T]):
|
|
111
|
+
def __init__(self, f: Callable[[], IEnumerator[_T]]) -> None:
|
|
112
|
+
self.f: Callable[[], IEnumerator[_T]] = f
|
|
113
|
+
|
|
114
|
+
def __str__(self, __unit: None = None) -> str:
|
|
115
|
+
xs: Enumerator_Seq[_T] = self
|
|
116
|
+
i: int = 0
|
|
117
|
+
str_1: str = "seq ["
|
|
118
|
+
with get_enumerator(xs) as e:
|
|
119
|
+
while e.System_Collections_IEnumerator_MoveNext() if (i < 4) else False:
|
|
120
|
+
if i > 0:
|
|
121
|
+
str_1 = str_1 + "; "
|
|
122
|
+
|
|
123
|
+
str_1 = str_1 + to_string(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
124
|
+
i = (i + 1) or 0
|
|
125
|
+
if i == 4:
|
|
126
|
+
str_1 = str_1 + "; ..."
|
|
127
|
+
|
|
128
|
+
return str_1 + "]"
|
|
129
|
+
|
|
130
|
+
def GetEnumerator(self, __unit: None = None) -> IEnumerator[_T]:
|
|
131
|
+
x: Enumerator_Seq[_T] = self
|
|
132
|
+
return x.f(None)
|
|
133
|
+
|
|
134
|
+
def __iter__(self) -> IEnumerator[_T]:
|
|
135
|
+
return to_iterator(self.GetEnumerator())
|
|
136
|
+
|
|
137
|
+
def System_Collections_IEnumerable_GetEnumerator(self, __unit: None = None) -> IEnumerator[Any]:
|
|
138
|
+
x: Enumerator_Seq[_T] = self
|
|
139
|
+
return x.f(None)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
Enumerator_Seq_reflection = _expr134
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def Enumerator_Seq__ctor_673A07F2(f: Callable[[], IEnumerator[_T]]) -> Enumerator_Seq[_T]:
|
|
146
|
+
return Enumerator_Seq(f)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _expr135(gen0: TypeInfo) -> TypeInfo:
|
|
150
|
+
return class_type("SeqModule.Enumerator.FromFunctions`1", [gen0], Enumerator_FromFunctions_1)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class Enumerator_FromFunctions_1(IDisposable, Generic[_T]):
|
|
154
|
+
def __init__(self, current: Callable[[], _T], next_1: Callable[[], bool], dispose: Callable[[], None]) -> None:
|
|
155
|
+
self.current: Callable[[], _T] = current
|
|
156
|
+
self.next: Callable[[], bool] = next_1
|
|
157
|
+
self.dispose: Callable[[], None] = dispose
|
|
158
|
+
|
|
159
|
+
def System_Collections_Generic_IEnumerator_1_get_Current(self, __unit: None = None) -> _T:
|
|
160
|
+
_: Enumerator_FromFunctions_1[_T] = self
|
|
161
|
+
return _.current(None)
|
|
162
|
+
|
|
163
|
+
def System_Collections_IEnumerator_get_Current(self, __unit: None = None) -> Any:
|
|
164
|
+
_: Enumerator_FromFunctions_1[_T] = self
|
|
165
|
+
return _.current(None)
|
|
166
|
+
|
|
167
|
+
def System_Collections_IEnumerator_MoveNext(self, __unit: None = None) -> bool:
|
|
168
|
+
_: Enumerator_FromFunctions_1[_T] = self
|
|
169
|
+
return _.next(None)
|
|
170
|
+
|
|
171
|
+
def System_Collections_IEnumerator_Reset(self, __unit: None = None) -> None:
|
|
172
|
+
Enumerator_noReset()
|
|
173
|
+
|
|
174
|
+
def Dispose(self, __unit: None = None) -> None:
|
|
175
|
+
_: Enumerator_FromFunctions_1[_T] = self
|
|
176
|
+
_.dispose(None)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
Enumerator_FromFunctions_1_reflection = _expr135
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def Enumerator_FromFunctions_1__ctor_58C54629(
|
|
183
|
+
current: Callable[[], _T], next_1: Callable[[], bool], dispose: Callable[[], None]
|
|
184
|
+
) -> Enumerator_FromFunctions_1[_T]:
|
|
185
|
+
return Enumerator_FromFunctions_1(current, next_1, dispose)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def Enumerator_cast(e: IEnumerator[Any]) -> IEnumerator[Any]:
|
|
189
|
+
def current(__unit: None = None, e: Any = e) -> _T:
|
|
190
|
+
return e.System_Collections_Generic_IEnumerator_1_get_Current()
|
|
191
|
+
|
|
192
|
+
def next_1(__unit: None = None, e: Any = e) -> bool:
|
|
193
|
+
return e.System_Collections_IEnumerator_MoveNext()
|
|
194
|
+
|
|
195
|
+
def dispose(__unit: None = None, e: Any = e) -> None:
|
|
196
|
+
dispose_2(e)
|
|
197
|
+
|
|
198
|
+
return Enumerator_FromFunctions_1__ctor_58C54629(current, next_1, dispose)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def Enumerator_concat(sources: IEnumerable_1[Any]) -> IEnumerator[Any]:
|
|
202
|
+
outer_opt: IEnumerator[_U] | None = None
|
|
203
|
+
inner_opt: IEnumerator[_T] | None = None
|
|
204
|
+
started: bool = False
|
|
205
|
+
finished: bool = False
|
|
206
|
+
curr: _T | None = None
|
|
207
|
+
|
|
208
|
+
def finish(__unit: None = None, sources: Any = sources) -> None:
|
|
209
|
+
nonlocal finished, inner_opt, outer_opt
|
|
210
|
+
finished = True
|
|
211
|
+
if inner_opt is not None:
|
|
212
|
+
inner: IEnumerator[_T] = inner_opt
|
|
213
|
+
try:
|
|
214
|
+
dispose_2(inner)
|
|
215
|
+
|
|
216
|
+
finally:
|
|
217
|
+
inner_opt = None
|
|
218
|
+
|
|
219
|
+
if outer_opt is not None:
|
|
220
|
+
outer: IEnumerator[_U] = outer_opt
|
|
221
|
+
try:
|
|
222
|
+
dispose_2(outer)
|
|
223
|
+
|
|
224
|
+
finally:
|
|
225
|
+
outer_opt = None
|
|
226
|
+
|
|
227
|
+
def current(__unit: None = None, sources: Any = sources) -> _T:
|
|
228
|
+
if not started:
|
|
229
|
+
Enumerator_notStarted()
|
|
230
|
+
|
|
231
|
+
elif finished:
|
|
232
|
+
Enumerator_alreadyFinished()
|
|
233
|
+
|
|
234
|
+
if curr is not None:
|
|
235
|
+
return value_1(curr)
|
|
236
|
+
|
|
237
|
+
else:
|
|
238
|
+
return Enumerator_alreadyFinished()
|
|
239
|
+
|
|
240
|
+
def next_1(__unit: None = None, sources: Any = sources) -> bool:
|
|
241
|
+
nonlocal started
|
|
242
|
+
if not started:
|
|
243
|
+
started = True
|
|
244
|
+
|
|
245
|
+
if finished:
|
|
246
|
+
return False
|
|
247
|
+
|
|
248
|
+
else:
|
|
249
|
+
res: bool | None = None
|
|
250
|
+
while res is None:
|
|
251
|
+
nonlocal curr, inner_opt, outer_opt
|
|
252
|
+
outer_opt_1: IEnumerator[_U] | None = outer_opt
|
|
253
|
+
inner_opt_1: IEnumerator[_T] | None = inner_opt
|
|
254
|
+
if outer_opt_1 is not None:
|
|
255
|
+
if inner_opt_1 is not None:
|
|
256
|
+
inner_1: IEnumerator[_T] = inner_opt_1
|
|
257
|
+
if inner_1.System_Collections_IEnumerator_MoveNext():
|
|
258
|
+
curr = some(inner_1.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
259
|
+
res = True
|
|
260
|
+
|
|
261
|
+
else:
|
|
262
|
+
try:
|
|
263
|
+
dispose_2(inner_1)
|
|
264
|
+
|
|
265
|
+
finally:
|
|
266
|
+
inner_opt = None
|
|
267
|
+
|
|
268
|
+
else:
|
|
269
|
+
outer_1: IEnumerator[_U] = outer_opt_1
|
|
270
|
+
if outer_1.System_Collections_IEnumerator_MoveNext():
|
|
271
|
+
ie: _U = outer_1.System_Collections_Generic_IEnumerator_1_get_Current()
|
|
272
|
+
|
|
273
|
+
def _arrow136(__unit: None = None) -> IEnumerator[_T]:
|
|
274
|
+
copy_of_struct: _U = ie
|
|
275
|
+
return get_enumerator(copy_of_struct)
|
|
276
|
+
|
|
277
|
+
inner_opt = _arrow136()
|
|
278
|
+
|
|
279
|
+
else:
|
|
280
|
+
finish(None)
|
|
281
|
+
res = False
|
|
282
|
+
|
|
283
|
+
else:
|
|
284
|
+
outer_opt = get_enumerator(sources)
|
|
285
|
+
|
|
286
|
+
return value_1(res)
|
|
287
|
+
|
|
288
|
+
def dispose(__unit: None = None, sources: Any = sources) -> None:
|
|
289
|
+
if not finished:
|
|
290
|
+
finish(None)
|
|
291
|
+
|
|
292
|
+
return Enumerator_FromFunctions_1__ctor_58C54629(current, next_1, dispose)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def Enumerator_enumerateThenFinally(f: Callable[[], None], e: IEnumerator[Any]) -> IEnumerator[Any]:
|
|
296
|
+
def current(__unit: None = None, f: Any = f, e: Any = e) -> _T:
|
|
297
|
+
return e.System_Collections_Generic_IEnumerator_1_get_Current()
|
|
298
|
+
|
|
299
|
+
def next_1(__unit: None = None, f: Any = f, e: Any = e) -> bool:
|
|
300
|
+
return e.System_Collections_IEnumerator_MoveNext()
|
|
301
|
+
|
|
302
|
+
def dispose(__unit: None = None, f: Any = f, e: Any = e) -> None:
|
|
303
|
+
try:
|
|
304
|
+
dispose_2(e)
|
|
305
|
+
|
|
306
|
+
finally:
|
|
307
|
+
f(None)
|
|
308
|
+
|
|
309
|
+
return Enumerator_FromFunctions_1__ctor_58C54629(current, next_1, dispose)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def Enumerator_generateWhileSome(
|
|
313
|
+
openf: Callable[[], _T], compute: Callable[[_T], _U | None], closef: Callable[[_T], None]
|
|
314
|
+
) -> IEnumerator[Any]:
|
|
315
|
+
started: bool = False
|
|
316
|
+
curr: _U | None = None
|
|
317
|
+
state: _T | None = some(openf(None))
|
|
318
|
+
|
|
319
|
+
def dispose(__unit: None = None, openf: Any = openf, compute: Any = compute, closef: Any = closef) -> None:
|
|
320
|
+
nonlocal state
|
|
321
|
+
if state is not None:
|
|
322
|
+
x_1: _T = value_1(state)
|
|
323
|
+
try:
|
|
324
|
+
closef(x_1)
|
|
325
|
+
|
|
326
|
+
finally:
|
|
327
|
+
state = None
|
|
328
|
+
|
|
329
|
+
def finish(__unit: None = None, openf: Any = openf, compute: Any = compute, closef: Any = closef) -> None:
|
|
330
|
+
nonlocal curr
|
|
331
|
+
try:
|
|
332
|
+
dispose(None)
|
|
333
|
+
|
|
334
|
+
finally:
|
|
335
|
+
curr = None
|
|
336
|
+
|
|
337
|
+
def current(__unit: None = None, openf: Any = openf, compute: Any = compute, closef: Any = closef) -> _U:
|
|
338
|
+
if not started:
|
|
339
|
+
Enumerator_notStarted()
|
|
340
|
+
|
|
341
|
+
if curr is not None:
|
|
342
|
+
return value_1(curr)
|
|
343
|
+
|
|
344
|
+
else:
|
|
345
|
+
return Enumerator_alreadyFinished()
|
|
346
|
+
|
|
347
|
+
def next_1(__unit: None = None, openf: Any = openf, compute: Any = compute, closef: Any = closef) -> bool:
|
|
348
|
+
nonlocal started, curr
|
|
349
|
+
if not started:
|
|
350
|
+
started = True
|
|
351
|
+
|
|
352
|
+
if state is not None:
|
|
353
|
+
s: _T = value_1(state)
|
|
354
|
+
match_value_1: _U | None
|
|
355
|
+
try:
|
|
356
|
+
match_value_1 = compute(s)
|
|
357
|
+
|
|
358
|
+
except Exception as match_value:
|
|
359
|
+
finish(None)
|
|
360
|
+
raise match_value
|
|
361
|
+
|
|
362
|
+
if match_value_1 is not None:
|
|
363
|
+
curr = match_value_1
|
|
364
|
+
return True
|
|
365
|
+
|
|
366
|
+
else:
|
|
367
|
+
finish(None)
|
|
368
|
+
return False
|
|
369
|
+
|
|
370
|
+
else:
|
|
371
|
+
return False
|
|
372
|
+
|
|
373
|
+
return Enumerator_FromFunctions_1__ctor_58C54629(current, next_1, dispose)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def Enumerator_unfold(f: Callable[[_STATE], tuple[_T, _STATE] | None], state: Any) -> IEnumerator[Any]:
|
|
377
|
+
curr: tuple[_T, _STATE] | None = None
|
|
378
|
+
acc: _STATE = state
|
|
379
|
+
|
|
380
|
+
def current(__unit: None = None, f: Any = f, state: Any = state) -> _T:
|
|
381
|
+
if curr is not None:
|
|
382
|
+
x: _T = curr[0]
|
|
383
|
+
st: _STATE = curr[1]
|
|
384
|
+
return x
|
|
385
|
+
|
|
386
|
+
else:
|
|
387
|
+
return Enumerator_notStarted()
|
|
388
|
+
|
|
389
|
+
def next_1(__unit: None = None, f: Any = f, state: Any = state) -> bool:
|
|
390
|
+
nonlocal curr, acc
|
|
391
|
+
curr = f(acc)
|
|
392
|
+
if curr is not None:
|
|
393
|
+
x_1: _T = curr[0]
|
|
394
|
+
st_1: _STATE = curr[1]
|
|
395
|
+
acc = st_1
|
|
396
|
+
return True
|
|
397
|
+
|
|
398
|
+
else:
|
|
399
|
+
return False
|
|
400
|
+
|
|
401
|
+
def dispose(__unit: None = None, f: Any = f, state: Any = state) -> None:
|
|
402
|
+
pass
|
|
403
|
+
|
|
404
|
+
return Enumerator_FromFunctions_1__ctor_58C54629(current, next_1, dispose)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def index_not_found(__unit: None = None) -> Any:
|
|
408
|
+
raise Exception(SR_keyNotFoundAlt)
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
def check_non_null(arg_name: str, arg: Any) -> None:
|
|
412
|
+
if arg is None:
|
|
413
|
+
Operators_NullArg(arg_name)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def mk_seq(f: Callable[[], IEnumerator[_T]]) -> IEnumerable_1[Any]:
|
|
417
|
+
return Enumerator_Seq__ctor_673A07F2(f)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def of_seq(xs: IEnumerable_1[Any]) -> IEnumerator[Any]:
|
|
421
|
+
check_non_null("source", xs)
|
|
422
|
+
return get_enumerator(xs)
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
def delay(generator: Callable[[], IEnumerable_1[_T]]) -> IEnumerable_1[Any]:
|
|
426
|
+
def _arrow137(__unit: None = None, generator: Any = generator) -> IEnumerator[_T]:
|
|
427
|
+
return get_enumerator(generator(None))
|
|
428
|
+
|
|
429
|
+
return mk_seq(_arrow137)
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
def concat(sources: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
433
|
+
def _arrow138(__unit: None = None, sources: Any = sources) -> IEnumerator[_T]:
|
|
434
|
+
return Enumerator_concat(sources)
|
|
435
|
+
|
|
436
|
+
return mk_seq(_arrow138)
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
def unfold(generator: Callable[[_STATE], tuple[_T, _STATE] | None], state: Any) -> IEnumerable_1[Any]:
|
|
440
|
+
def _arrow139(__unit: None = None, generator: Any = generator, state: Any = state) -> IEnumerator[_T]:
|
|
441
|
+
return Enumerator_unfold(generator, state)
|
|
442
|
+
|
|
443
|
+
return mk_seq(_arrow139)
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def empty(__unit: None = None) -> IEnumerable_1[Any]:
|
|
447
|
+
def _arrow140(__unit: None = None) -> IEnumerable_1[_T]:
|
|
448
|
+
return [0] * 0
|
|
449
|
+
|
|
450
|
+
return delay(_arrow140)
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def singleton(x: Any | None = None) -> IEnumerable_1[Any]:
|
|
454
|
+
def _arrow141(__unit: None = None, x: Any = x) -> IEnumerable_1[_T]:
|
|
455
|
+
return singleton_1(x, None)
|
|
456
|
+
|
|
457
|
+
return delay(_arrow141)
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def of_array(arr: Array[Any]) -> IEnumerable_1[Any]:
|
|
461
|
+
return arr
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
def to_array(xs: IEnumerable_1[Any]) -> Array[Any]:
|
|
465
|
+
if isinstance(xs, FSharpList):
|
|
466
|
+
return to_array_1(xs)
|
|
467
|
+
|
|
468
|
+
else:
|
|
469
|
+
return list(xs)
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
def of_list(xs: FSharpList[Any]) -> IEnumerable_1[Any]:
|
|
473
|
+
return xs
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def to_list(xs: IEnumerable_1[Any]) -> FSharpList[Any]:
|
|
477
|
+
if is_array_like(xs):
|
|
478
|
+
return of_array_1(xs)
|
|
479
|
+
|
|
480
|
+
elif isinstance(xs, FSharpList):
|
|
481
|
+
return xs
|
|
482
|
+
|
|
483
|
+
else:
|
|
484
|
+
return of_seq_1(xs)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def generate(
|
|
488
|
+
create: Callable[[], __A], compute: Callable[[__A], __B | None], dispose: Callable[[__A], None]
|
|
489
|
+
) -> IEnumerable_1[Any]:
|
|
490
|
+
def _arrow142(
|
|
491
|
+
__unit: None = None, create: Any = create, compute: Any = compute, dispose: Any = dispose
|
|
492
|
+
) -> IEnumerator[__B]:
|
|
493
|
+
return Enumerator_generateWhileSome(create, compute, dispose)
|
|
494
|
+
|
|
495
|
+
return mk_seq(_arrow142)
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
def generate_indexed(
|
|
499
|
+
create: Callable[[], __A], compute: Callable[[int, __A], __B | None], dispose: Callable[[__A], None]
|
|
500
|
+
) -> IEnumerable_1[Any]:
|
|
501
|
+
def _arrow144(
|
|
502
|
+
__unit: None = None, create: Any = create, compute: Any = compute, dispose: Any = dispose
|
|
503
|
+
) -> IEnumerator[__B]:
|
|
504
|
+
i: int = -1
|
|
505
|
+
|
|
506
|
+
def _arrow143(x: __A | None = None) -> __B | None:
|
|
507
|
+
nonlocal i
|
|
508
|
+
i = (i + 1) or 0
|
|
509
|
+
return compute(i, x)
|
|
510
|
+
|
|
511
|
+
return Enumerator_generateWhileSome(create, _arrow143, dispose)
|
|
512
|
+
|
|
513
|
+
return mk_seq(_arrow144)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
def append(xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
517
|
+
return concat(to_enumerable([xs, ys]))
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def cast(xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
521
|
+
def _arrow145(__unit: None = None, xs: Any = xs) -> IEnumerator[_T]:
|
|
522
|
+
check_non_null("source", xs)
|
|
523
|
+
return Enumerator_cast(get_enumerator(xs))
|
|
524
|
+
|
|
525
|
+
return mk_seq(_arrow145)
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
def choose(chooser: Callable[[_T], _U | None], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
529
|
+
def _arrow146(__unit: None = None, chooser: Any = chooser, xs: Any = xs) -> IEnumerator[_T]:
|
|
530
|
+
return of_seq(xs)
|
|
531
|
+
|
|
532
|
+
def _arrow147(e: IEnumerator[_T], chooser: Any = chooser, xs: Any = xs) -> _U | None:
|
|
533
|
+
curr: _U | None = None
|
|
534
|
+
while e.System_Collections_IEnumerator_MoveNext() if (curr is None) else False:
|
|
535
|
+
curr = chooser(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
536
|
+
return curr
|
|
537
|
+
|
|
538
|
+
def _arrow148(e_1: IEnumerator[_T], chooser: Any = chooser, xs: Any = xs) -> None:
|
|
539
|
+
dispose_2(e_1)
|
|
540
|
+
|
|
541
|
+
return generate(_arrow146, _arrow147, _arrow148)
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
def compare_with(comparer: Callable[[_T, _T], int], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> int:
|
|
545
|
+
with of_seq(xs) as e1:
|
|
546
|
+
with of_seq(ys) as e2:
|
|
547
|
+
c: int = 0
|
|
548
|
+
b1: bool = e1.System_Collections_IEnumerator_MoveNext()
|
|
549
|
+
b2: bool = e2.System_Collections_IEnumerator_MoveNext()
|
|
550
|
+
while b2 if (b1 if (c == 0) else False) else False:
|
|
551
|
+
c = (
|
|
552
|
+
comparer(
|
|
553
|
+
e1.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
554
|
+
e2.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
555
|
+
)
|
|
556
|
+
or 0
|
|
557
|
+
)
|
|
558
|
+
if c == 0:
|
|
559
|
+
b1 = e1.System_Collections_IEnumerator_MoveNext()
|
|
560
|
+
b2 = e2.System_Collections_IEnumerator_MoveNext()
|
|
561
|
+
|
|
562
|
+
if c != 0:
|
|
563
|
+
return c
|
|
564
|
+
|
|
565
|
+
elif b1:
|
|
566
|
+
return 1
|
|
567
|
+
|
|
568
|
+
elif b2:
|
|
569
|
+
return -1
|
|
570
|
+
|
|
571
|
+
else:
|
|
572
|
+
return 0
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
def contains(value: Any, xs: IEnumerable_1[Any], comparer: IEqualityComparer_1[Any]) -> bool:
|
|
576
|
+
with of_seq(xs) as e:
|
|
577
|
+
found: bool = False
|
|
578
|
+
while e.System_Collections_IEnumerator_MoveNext() if (not found) else False:
|
|
579
|
+
found = comparer.Equals(value, e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
580
|
+
return found
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def enumerate_from_functions(
|
|
584
|
+
create: Callable[[], __A], move_next: Callable[[__A], bool], current: Callable[[__A], __B]
|
|
585
|
+
) -> IEnumerable_1[Any]:
|
|
586
|
+
def _arrow149(
|
|
587
|
+
x: __A | None = None, create: Any = create, move_next: Any = move_next, current: Any = current
|
|
588
|
+
) -> __B | None:
|
|
589
|
+
return some(current(x)) if move_next(x) else None
|
|
590
|
+
|
|
591
|
+
def _arrow150(
|
|
592
|
+
x_1: __A | None = None, create: Any = create, move_next: Any = move_next, current: Any = current
|
|
593
|
+
) -> None:
|
|
594
|
+
match_value: Any = x_1
|
|
595
|
+
if is_disposable(match_value):
|
|
596
|
+
dispose_2(match_value)
|
|
597
|
+
|
|
598
|
+
return generate(create, _arrow149, _arrow150)
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
def enumerate_then_finally(source: IEnumerable_1[Any], compensation: Callable[[], None]) -> IEnumerable_1[Any]:
|
|
602
|
+
compensation_1: Callable[[], None] = compensation
|
|
603
|
+
|
|
604
|
+
def _arrow151(__unit: None = None, source: Any = source, compensation: Any = compensation) -> IEnumerator[_T]:
|
|
605
|
+
try:
|
|
606
|
+
return Enumerator_enumerateThenFinally(compensation_1, of_seq(source))
|
|
607
|
+
|
|
608
|
+
except Exception as match_value:
|
|
609
|
+
compensation_1(None)
|
|
610
|
+
raise match_value
|
|
611
|
+
|
|
612
|
+
return mk_seq(_arrow151)
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
def enumerate_using(resource: Any, source: Callable[[_T], __A]) -> IEnumerable_1[Any]:
|
|
616
|
+
def compensation(__unit: None = None, resource: Any = resource, source: Any = source) -> None:
|
|
617
|
+
if equals(resource, None):
|
|
618
|
+
pass
|
|
619
|
+
|
|
620
|
+
else:
|
|
621
|
+
copy_of_struct: _T = resource
|
|
622
|
+
dispose_2(copy_of_struct)
|
|
623
|
+
|
|
624
|
+
def _arrow152(__unit: None = None, resource: Any = resource, source: Any = source) -> IEnumerator[_U]:
|
|
625
|
+
try:
|
|
626
|
+
return Enumerator_enumerateThenFinally(compensation, of_seq(source(resource)))
|
|
627
|
+
|
|
628
|
+
except Exception as match_value_1:
|
|
629
|
+
compensation(None)
|
|
630
|
+
raise match_value_1
|
|
631
|
+
|
|
632
|
+
return mk_seq(_arrow152)
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
def enumerate_while(guard: Callable[[], bool], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
636
|
+
def _arrow153(i: int, guard: Any = guard, xs: Any = xs) -> tuple[IEnumerable_1[_T], int] | None:
|
|
637
|
+
return ((xs, i + 1)) if guard(None) else None
|
|
638
|
+
|
|
639
|
+
return concat(unfold(_arrow153, 0))
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
def filter(f: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
643
|
+
def chooser(x: _T | None = None, f: Any = f, xs: Any = xs) -> _T | None:
|
|
644
|
+
if f(x):
|
|
645
|
+
return some(x)
|
|
646
|
+
|
|
647
|
+
else:
|
|
648
|
+
return None
|
|
649
|
+
|
|
650
|
+
return choose(chooser, xs)
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
def exists(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> bool:
|
|
654
|
+
with of_seq(xs) as e:
|
|
655
|
+
found: bool = False
|
|
656
|
+
while e.System_Collections_IEnumerator_MoveNext() if (not found) else False:
|
|
657
|
+
found = predicate(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
658
|
+
return found
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def exists2(predicate: Callable[[_T1, _T2], bool], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> bool:
|
|
662
|
+
with of_seq(xs) as e1:
|
|
663
|
+
with of_seq(ys) as e2:
|
|
664
|
+
found: bool = False
|
|
665
|
+
while (
|
|
666
|
+
e2.System_Collections_IEnumerator_MoveNext()
|
|
667
|
+
if (e1.System_Collections_IEnumerator_MoveNext() if (not found) else False)
|
|
668
|
+
else False
|
|
669
|
+
):
|
|
670
|
+
found = predicate(
|
|
671
|
+
e1.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
672
|
+
e2.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
673
|
+
)
|
|
674
|
+
return found
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
def exactly_one(xs: IEnumerable_1[Any]) -> Any:
|
|
678
|
+
with of_seq(xs) as e:
|
|
679
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
680
|
+
v: _T = e.System_Collections_Generic_IEnumerator_1_get_Current()
|
|
681
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
682
|
+
raise Exception((SR_inputSequenceTooLong + "\\nParameter name: ") + "source")
|
|
683
|
+
|
|
684
|
+
else:
|
|
685
|
+
return v
|
|
686
|
+
|
|
687
|
+
else:
|
|
688
|
+
raise Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "source")
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
def try_exactly_one(xs: IEnumerable_1[Any]) -> Any | None:
|
|
692
|
+
with of_seq(xs) as e:
|
|
693
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
694
|
+
v: _T = e.System_Collections_Generic_IEnumerator_1_get_Current()
|
|
695
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
696
|
+
return None
|
|
697
|
+
|
|
698
|
+
else:
|
|
699
|
+
return some(v)
|
|
700
|
+
|
|
701
|
+
else:
|
|
702
|
+
return None
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
def try_find(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> Any | None:
|
|
706
|
+
with of_seq(xs) as e:
|
|
707
|
+
res: _T | None = None
|
|
708
|
+
while e.System_Collections_IEnumerator_MoveNext() if (res is None) else False:
|
|
709
|
+
c: _T = e.System_Collections_Generic_IEnumerator_1_get_Current()
|
|
710
|
+
if predicate(c):
|
|
711
|
+
res = some(c)
|
|
712
|
+
|
|
713
|
+
return res
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
def find(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> Any:
|
|
717
|
+
match_value: _T | None = try_find(predicate, xs)
|
|
718
|
+
if match_value is None:
|
|
719
|
+
return index_not_found()
|
|
720
|
+
|
|
721
|
+
else:
|
|
722
|
+
return value_1(match_value)
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
def try_find_back(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> Any | None:
|
|
726
|
+
return try_find_back_1(predicate, to_array(xs))
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
def find_back(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> Any:
|
|
730
|
+
match_value: _T | None = try_find_back(predicate, xs)
|
|
731
|
+
if match_value is None:
|
|
732
|
+
return index_not_found()
|
|
733
|
+
|
|
734
|
+
else:
|
|
735
|
+
return value_1(match_value)
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
def try_find_index(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> int | None:
|
|
739
|
+
with of_seq(xs) as e:
|
|
740
|
+
|
|
741
|
+
def loop(i_mut: int, predicate: Any = predicate, xs: Any = xs) -> int | None:
|
|
742
|
+
while True:
|
|
743
|
+
(i,) = (i_mut,)
|
|
744
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
745
|
+
if predicate(e.System_Collections_Generic_IEnumerator_1_get_Current()):
|
|
746
|
+
return i
|
|
747
|
+
|
|
748
|
+
else:
|
|
749
|
+
i_mut = i + 1
|
|
750
|
+
continue
|
|
751
|
+
|
|
752
|
+
else:
|
|
753
|
+
return None
|
|
754
|
+
|
|
755
|
+
break
|
|
756
|
+
|
|
757
|
+
return loop(0)
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
def find_index(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> int:
|
|
761
|
+
match_value: int | None = try_find_index(predicate, xs)
|
|
762
|
+
if match_value is None:
|
|
763
|
+
index_not_found()
|
|
764
|
+
return -1
|
|
765
|
+
|
|
766
|
+
else:
|
|
767
|
+
return match_value
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
def try_find_index_back(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> int | None:
|
|
771
|
+
return try_find_index_back_1(predicate, to_array(xs))
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
def find_index_back(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> int:
|
|
775
|
+
match_value: int | None = try_find_index_back(predicate, xs)
|
|
776
|
+
if match_value is None:
|
|
777
|
+
index_not_found()
|
|
778
|
+
return -1
|
|
779
|
+
|
|
780
|
+
else:
|
|
781
|
+
return match_value
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
def fold(folder: Callable[[_STATE, _T], _STATE], state: Any, xs: IEnumerable_1[Any]) -> Any:
|
|
785
|
+
with of_seq(xs) as e:
|
|
786
|
+
acc: _STATE = state
|
|
787
|
+
while e.System_Collections_IEnumerator_MoveNext():
|
|
788
|
+
acc = folder(acc, e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
789
|
+
return acc
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
def fold_back(folder: Callable[[_T, Any], Any], xs: IEnumerable_1[Any], state: Any = None) -> Any:
|
|
793
|
+
return fold_back_1(folder, to_array(xs), state)
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
def fold2(
|
|
797
|
+
folder: Callable[[_STATE, _T1, _T2], _STATE], state: Any, xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]
|
|
798
|
+
) -> Any:
|
|
799
|
+
with of_seq(xs) as e1:
|
|
800
|
+
with of_seq(ys) as e2:
|
|
801
|
+
acc: _STATE = state
|
|
802
|
+
while (
|
|
803
|
+
e2.System_Collections_IEnumerator_MoveNext() if e1.System_Collections_IEnumerator_MoveNext() else False
|
|
804
|
+
):
|
|
805
|
+
acc = folder(
|
|
806
|
+
acc,
|
|
807
|
+
e1.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
808
|
+
e2.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
809
|
+
)
|
|
810
|
+
return acc
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
def fold_back2(
|
|
814
|
+
folder: Callable[[_T1, _T2, _STATE], _STATE], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any], state: Any
|
|
815
|
+
) -> Any:
|
|
816
|
+
return fold_back2_1(folder, to_array(xs), to_array(ys), state)
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
def for_all(predicate: Callable[[__A], bool], xs: IEnumerable_1[Any]) -> bool:
|
|
820
|
+
def _arrow154(x: __A | None = None, predicate: Any = predicate, xs: Any = xs) -> bool:
|
|
821
|
+
return not predicate(x)
|
|
822
|
+
|
|
823
|
+
return not exists(_arrow154, xs)
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
def for_all2(predicate: Callable[[__A, __B], bool], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> bool:
|
|
827
|
+
def _arrow155(x: __A, y: __B, predicate: Any = predicate, xs: Any = xs, ys: Any = ys) -> bool:
|
|
828
|
+
return not predicate(x, y)
|
|
829
|
+
|
|
830
|
+
return not exists2(_arrow155, xs, ys)
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
def try_head(xs: IEnumerable_1[Any]) -> Any | None:
|
|
834
|
+
if is_array_like(xs):
|
|
835
|
+
return try_head_1(xs)
|
|
836
|
+
|
|
837
|
+
elif isinstance(xs, FSharpList):
|
|
838
|
+
return try_head_2(xs)
|
|
839
|
+
|
|
840
|
+
else:
|
|
841
|
+
with of_seq(xs) as e:
|
|
842
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
843
|
+
return some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
844
|
+
|
|
845
|
+
else:
|
|
846
|
+
return None
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
def head(xs: IEnumerable_1[Any]) -> Any:
|
|
850
|
+
match_value: _T | None = try_head(xs)
|
|
851
|
+
if match_value is None:
|
|
852
|
+
raise Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "source")
|
|
853
|
+
|
|
854
|
+
else:
|
|
855
|
+
return value_1(match_value)
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
def initialize(count: int, f: Callable[[int], __A]) -> IEnumerable_1[Any]:
|
|
859
|
+
def _arrow156(i: int, count: Any = count, f: Any = f) -> tuple[__A, int] | None:
|
|
860
|
+
return ((f(i), i + 1)) if (i < count) else None
|
|
861
|
+
|
|
862
|
+
return unfold(_arrow156, 0)
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
def initialize_infinite(f: Callable[[int], __A]) -> IEnumerable_1[Any]:
|
|
866
|
+
return initialize(2147483647, f)
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
def is_empty(xs: IEnumerable_1[Any]) -> bool:
|
|
870
|
+
if is_array_like(xs):
|
|
871
|
+
return len(xs) == 0
|
|
872
|
+
|
|
873
|
+
elif isinstance(xs, FSharpList):
|
|
874
|
+
return is_empty_1(xs)
|
|
875
|
+
|
|
876
|
+
else:
|
|
877
|
+
with of_seq(xs) as e:
|
|
878
|
+
return not e.System_Collections_IEnumerator_MoveNext()
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
def try_item(index: int, xs: IEnumerable_1[Any]) -> Any | None:
|
|
882
|
+
if is_array_like(xs):
|
|
883
|
+
return try_item_1(index, xs)
|
|
884
|
+
|
|
885
|
+
elif isinstance(xs, FSharpList):
|
|
886
|
+
return try_item_2(index, xs)
|
|
887
|
+
|
|
888
|
+
else:
|
|
889
|
+
with of_seq(xs) as e:
|
|
890
|
+
|
|
891
|
+
def loop(index_1_mut: int, index: Any = index, xs: Any = xs) -> _T | None:
|
|
892
|
+
while True:
|
|
893
|
+
(index_1,) = (index_1_mut,)
|
|
894
|
+
if not e.System_Collections_IEnumerator_MoveNext():
|
|
895
|
+
return None
|
|
896
|
+
|
|
897
|
+
elif index_1 == 0:
|
|
898
|
+
return some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
899
|
+
|
|
900
|
+
else:
|
|
901
|
+
index_1_mut = index_1 - 1
|
|
902
|
+
continue
|
|
903
|
+
|
|
904
|
+
break
|
|
905
|
+
|
|
906
|
+
return loop(index)
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
def item(index: int, xs: IEnumerable_1[Any]) -> Any:
|
|
910
|
+
match_value: _T | None = try_item(index, xs)
|
|
911
|
+
if match_value is None:
|
|
912
|
+
raise Exception((SR_notEnoughElements + "\\nParameter name: ") + "index")
|
|
913
|
+
|
|
914
|
+
else:
|
|
915
|
+
return value_1(match_value)
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
def iterate(action: Callable[[__A], None], xs: IEnumerable_1[Any]) -> None:
|
|
919
|
+
def _arrow157(unit_var: None, x: __A, action: Any = action, xs: Any = xs) -> None:
|
|
920
|
+
action(x)
|
|
921
|
+
|
|
922
|
+
fold(_arrow157, None, xs)
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
def iterate2(action: Callable[[__A, __B], None], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> None:
|
|
926
|
+
def _arrow158(unit_var: None, x: __A, y: __B, action: Any = action, xs: Any = xs, ys: Any = ys) -> None:
|
|
927
|
+
action(x, y)
|
|
928
|
+
|
|
929
|
+
fold2(_arrow158, None, xs, ys)
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
def iterate_indexed(action: Callable[[int, __A], None], xs: IEnumerable_1[Any]) -> None:
|
|
933
|
+
def _arrow159(i: int, x: __A, action: Any = action, xs: Any = xs) -> int:
|
|
934
|
+
action(i, x)
|
|
935
|
+
return i + 1
|
|
936
|
+
|
|
937
|
+
ignore(fold(_arrow159, 0, xs))
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
def iterate_indexed2(action: Callable[[int, __A, __B], None], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> None:
|
|
941
|
+
def _arrow160(i: int, x: __A, y: __B, action: Any = action, xs: Any = xs, ys: Any = ys) -> int:
|
|
942
|
+
action(i, x, y)
|
|
943
|
+
return i + 1
|
|
944
|
+
|
|
945
|
+
ignore(fold2(_arrow160, 0, xs, ys))
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
def try_last(xs: IEnumerable_1[Any]) -> Any | None:
|
|
949
|
+
with of_seq(xs) as e:
|
|
950
|
+
|
|
951
|
+
def loop(acc_mut: _T | None = None, xs: Any = xs) -> _T | None:
|
|
952
|
+
while True:
|
|
953
|
+
(acc,) = (acc_mut,)
|
|
954
|
+
if not e.System_Collections_IEnumerator_MoveNext():
|
|
955
|
+
return acc
|
|
956
|
+
|
|
957
|
+
else:
|
|
958
|
+
acc_mut = e.System_Collections_Generic_IEnumerator_1_get_Current()
|
|
959
|
+
continue
|
|
960
|
+
|
|
961
|
+
break
|
|
962
|
+
|
|
963
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
964
|
+
return some(loop(e.System_Collections_Generic_IEnumerator_1_get_Current()))
|
|
965
|
+
|
|
966
|
+
else:
|
|
967
|
+
return None
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
def last(xs: IEnumerable_1[Any]) -> Any:
|
|
971
|
+
match_value: _T | None = try_last(xs)
|
|
972
|
+
if match_value is None:
|
|
973
|
+
raise Exception((SR_notEnoughElements + "\\nParameter name: ") + "source")
|
|
974
|
+
|
|
975
|
+
else:
|
|
976
|
+
return value_1(match_value)
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
def length(xs: IEnumerable_1[Any]) -> int:
|
|
980
|
+
if is_array_like(xs):
|
|
981
|
+
return len(xs)
|
|
982
|
+
|
|
983
|
+
elif isinstance(xs, FSharpList):
|
|
984
|
+
return length_1(xs)
|
|
985
|
+
|
|
986
|
+
else:
|
|
987
|
+
with of_seq(xs) as e:
|
|
988
|
+
count: int = 0
|
|
989
|
+
while e.System_Collections_IEnumerator_MoveNext():
|
|
990
|
+
count = (count + 1) or 0
|
|
991
|
+
return count
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
def map(mapping: Callable[[_T], _U], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
995
|
+
def _arrow161(__unit: None = None, mapping: Any = mapping, xs: Any = xs) -> IEnumerator[_T]:
|
|
996
|
+
return of_seq(xs)
|
|
997
|
+
|
|
998
|
+
def _arrow162(e: IEnumerator[_T], mapping: Any = mapping, xs: Any = xs) -> _U | None:
|
|
999
|
+
return (
|
|
1000
|
+
some(mapping(e.System_Collections_Generic_IEnumerator_1_get_Current()))
|
|
1001
|
+
if e.System_Collections_IEnumerator_MoveNext()
|
|
1002
|
+
else None
|
|
1003
|
+
)
|
|
1004
|
+
|
|
1005
|
+
def _arrow163(e_1: IEnumerator[_T], mapping: Any = mapping, xs: Any = xs) -> None:
|
|
1006
|
+
dispose_2(e_1)
|
|
1007
|
+
|
|
1008
|
+
return generate(_arrow161, _arrow162, _arrow163)
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
def map_indexed(mapping: Callable[[int, _T], _U], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1012
|
+
def _arrow164(__unit: None = None, mapping: Any = mapping, xs: Any = xs) -> IEnumerator[_T]:
|
|
1013
|
+
return of_seq(xs)
|
|
1014
|
+
|
|
1015
|
+
def _arrow165(i: int, e: IEnumerator[_T], mapping: Any = mapping, xs: Any = xs) -> _U | None:
|
|
1016
|
+
return (
|
|
1017
|
+
some(mapping(i, e.System_Collections_Generic_IEnumerator_1_get_Current()))
|
|
1018
|
+
if e.System_Collections_IEnumerator_MoveNext()
|
|
1019
|
+
else None
|
|
1020
|
+
)
|
|
1021
|
+
|
|
1022
|
+
def _arrow166(e_1: IEnumerator[_T], mapping: Any = mapping, xs: Any = xs) -> None:
|
|
1023
|
+
dispose_2(e_1)
|
|
1024
|
+
|
|
1025
|
+
return generate_indexed(_arrow164, _arrow165, _arrow166)
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
def indexed(xs: IEnumerable_1[Any]) -> IEnumerable_1[tuple[int, _T]]:
|
|
1029
|
+
def mapping(i: int, x: _T, xs: Any = xs) -> tuple[int, _T]:
|
|
1030
|
+
return (i, x)
|
|
1031
|
+
|
|
1032
|
+
return map_indexed(mapping, xs)
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
def map2(mapping: Callable[[_T1, _T2], _U], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1036
|
+
def _arrow167(
|
|
1037
|
+
__unit: None = None, mapping: Any = mapping, xs: Any = xs, ys: Any = ys
|
|
1038
|
+
) -> tuple[IEnumerator[_T1], IEnumerator[_T2]]:
|
|
1039
|
+
return (of_seq(xs), of_seq(ys))
|
|
1040
|
+
|
|
1041
|
+
def _arrow168(
|
|
1042
|
+
tupled_arg: tuple[IEnumerator[_T1], IEnumerator[_T2]], mapping: Any = mapping, xs: Any = xs, ys: Any = ys
|
|
1043
|
+
) -> _U | None:
|
|
1044
|
+
e1: IEnumerator[_T1] = tupled_arg[0]
|
|
1045
|
+
e2: IEnumerator[_T2] = tupled_arg[1]
|
|
1046
|
+
return (
|
|
1047
|
+
some(
|
|
1048
|
+
mapping(
|
|
1049
|
+
e1.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
1050
|
+
e2.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
1051
|
+
)
|
|
1052
|
+
)
|
|
1053
|
+
if (e2.System_Collections_IEnumerator_MoveNext() if e1.System_Collections_IEnumerator_MoveNext() else False)
|
|
1054
|
+
else None
|
|
1055
|
+
)
|
|
1056
|
+
|
|
1057
|
+
def _arrow169(
|
|
1058
|
+
tupled_arg_1: tuple[IEnumerator[_T1], IEnumerator[_T2]], mapping: Any = mapping, xs: Any = xs, ys: Any = ys
|
|
1059
|
+
) -> None:
|
|
1060
|
+
try:
|
|
1061
|
+
dispose_2(tupled_arg_1[0])
|
|
1062
|
+
|
|
1063
|
+
finally:
|
|
1064
|
+
dispose_2(tupled_arg_1[1])
|
|
1065
|
+
|
|
1066
|
+
return generate(_arrow167, _arrow168, _arrow169)
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
def map_indexed2(
|
|
1070
|
+
mapping: Callable[[int, _T1, _T2], _U], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]
|
|
1071
|
+
) -> IEnumerable_1[Any]:
|
|
1072
|
+
def _arrow170(
|
|
1073
|
+
__unit: None = None, mapping: Any = mapping, xs: Any = xs, ys: Any = ys
|
|
1074
|
+
) -> tuple[IEnumerator[_T1], IEnumerator[_T2]]:
|
|
1075
|
+
return (of_seq(xs), of_seq(ys))
|
|
1076
|
+
|
|
1077
|
+
def _arrow171(
|
|
1078
|
+
i: int,
|
|
1079
|
+
tupled_arg: tuple[IEnumerator[_T1], IEnumerator[_T2]],
|
|
1080
|
+
mapping: Any = mapping,
|
|
1081
|
+
xs: Any = xs,
|
|
1082
|
+
ys: Any = ys,
|
|
1083
|
+
) -> _U | None:
|
|
1084
|
+
e1: IEnumerator[_T1] = tupled_arg[0]
|
|
1085
|
+
e2: IEnumerator[_T2] = tupled_arg[1]
|
|
1086
|
+
return (
|
|
1087
|
+
some(
|
|
1088
|
+
mapping(
|
|
1089
|
+
i,
|
|
1090
|
+
e1.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
1091
|
+
e2.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
1092
|
+
)
|
|
1093
|
+
)
|
|
1094
|
+
if (e2.System_Collections_IEnumerator_MoveNext() if e1.System_Collections_IEnumerator_MoveNext() else False)
|
|
1095
|
+
else None
|
|
1096
|
+
)
|
|
1097
|
+
|
|
1098
|
+
def _arrow172(
|
|
1099
|
+
tupled_arg_1: tuple[IEnumerator[_T1], IEnumerator[_T2]], mapping: Any = mapping, xs: Any = xs, ys: Any = ys
|
|
1100
|
+
) -> None:
|
|
1101
|
+
try:
|
|
1102
|
+
dispose_2(tupled_arg_1[0])
|
|
1103
|
+
|
|
1104
|
+
finally:
|
|
1105
|
+
dispose_2(tupled_arg_1[1])
|
|
1106
|
+
|
|
1107
|
+
return generate_indexed(_arrow170, _arrow171, _arrow172)
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
def map3(
|
|
1111
|
+
mapping: Callable[[_T1, _T2, _T3], _U], xs: IEnumerable_1[Any], ys: IEnumerable_1[Any], zs: IEnumerable_1[Any]
|
|
1112
|
+
) -> IEnumerable_1[Any]:
|
|
1113
|
+
def _arrow173(
|
|
1114
|
+
__unit: None = None, mapping: Any = mapping, xs: Any = xs, ys: Any = ys, zs: Any = zs
|
|
1115
|
+
) -> tuple[IEnumerator[_T1], IEnumerator[_T2], IEnumerator[_T3]]:
|
|
1116
|
+
return (of_seq(xs), of_seq(ys), of_seq(zs))
|
|
1117
|
+
|
|
1118
|
+
def _arrow174(
|
|
1119
|
+
tupled_arg: tuple[IEnumerator[_T1], IEnumerator[_T2], IEnumerator[_T3]],
|
|
1120
|
+
mapping: Any = mapping,
|
|
1121
|
+
xs: Any = xs,
|
|
1122
|
+
ys: Any = ys,
|
|
1123
|
+
zs: Any = zs,
|
|
1124
|
+
) -> _U | None:
|
|
1125
|
+
e1: IEnumerator[_T1] = tupled_arg[0]
|
|
1126
|
+
e2: IEnumerator[_T2] = tupled_arg[1]
|
|
1127
|
+
e3: IEnumerator[_T3] = tupled_arg[2]
|
|
1128
|
+
return (
|
|
1129
|
+
some(
|
|
1130
|
+
mapping(
|
|
1131
|
+
e1.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
1132
|
+
e2.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
1133
|
+
e3.System_Collections_Generic_IEnumerator_1_get_Current(),
|
|
1134
|
+
)
|
|
1135
|
+
)
|
|
1136
|
+
if (
|
|
1137
|
+
e3.System_Collections_IEnumerator_MoveNext()
|
|
1138
|
+
if (
|
|
1139
|
+
e2.System_Collections_IEnumerator_MoveNext()
|
|
1140
|
+
if e1.System_Collections_IEnumerator_MoveNext()
|
|
1141
|
+
else False
|
|
1142
|
+
)
|
|
1143
|
+
else False
|
|
1144
|
+
)
|
|
1145
|
+
else None
|
|
1146
|
+
)
|
|
1147
|
+
|
|
1148
|
+
def _arrow175(
|
|
1149
|
+
tupled_arg_1: tuple[IEnumerator[_T1], IEnumerator[_T2], IEnumerator[_T3]],
|
|
1150
|
+
mapping: Any = mapping,
|
|
1151
|
+
xs: Any = xs,
|
|
1152
|
+
ys: Any = ys,
|
|
1153
|
+
zs: Any = zs,
|
|
1154
|
+
) -> None:
|
|
1155
|
+
try:
|
|
1156
|
+
dispose_2(tupled_arg_1[0])
|
|
1157
|
+
|
|
1158
|
+
finally:
|
|
1159
|
+
try:
|
|
1160
|
+
dispose_2(tupled_arg_1[1])
|
|
1161
|
+
|
|
1162
|
+
finally:
|
|
1163
|
+
dispose_2(tupled_arg_1[2])
|
|
1164
|
+
|
|
1165
|
+
return generate(_arrow173, _arrow174, _arrow175)
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
def read_only(xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1169
|
+
check_non_null("source", xs)
|
|
1170
|
+
|
|
1171
|
+
def _arrow176(x: _T | None = None, xs: Any = xs) -> _T | None:
|
|
1172
|
+
return x
|
|
1173
|
+
|
|
1174
|
+
return map(_arrow176, xs)
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
def _expr177(gen0: TypeInfo) -> TypeInfo:
|
|
1178
|
+
return class_type("SeqModule.CachedSeq`1", [gen0], CachedSeq_1)
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
class CachedSeq_1(IDisposable, Generic[_T]):
|
|
1182
|
+
def __init__(self, cleanup: Callable[[], None], res: IEnumerable_1[Any]) -> None:
|
|
1183
|
+
self.cleanup: Callable[[], None] = cleanup
|
|
1184
|
+
self.res: IEnumerable_1[_T] = res
|
|
1185
|
+
|
|
1186
|
+
def Dispose(self, __unit: None = None) -> None:
|
|
1187
|
+
_: CachedSeq_1[_T] = self
|
|
1188
|
+
_.cleanup(None)
|
|
1189
|
+
|
|
1190
|
+
def GetEnumerator(self, __unit: None = None) -> IEnumerator[_T]:
|
|
1191
|
+
_: CachedSeq_1[_T] = self
|
|
1192
|
+
return get_enumerator(_.res)
|
|
1193
|
+
|
|
1194
|
+
def __iter__(self) -> IEnumerator[_T]:
|
|
1195
|
+
return to_iterator(self.GetEnumerator())
|
|
1196
|
+
|
|
1197
|
+
def System_Collections_IEnumerable_GetEnumerator(self, __unit: None = None) -> IEnumerator[Any]:
|
|
1198
|
+
_: CachedSeq_1[_T] = self
|
|
1199
|
+
return get_enumerator(_.res)
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
CachedSeq_1_reflection = _expr177
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
def CachedSeq_1__ctor_Z7A8347D4(cleanup: Callable[[], None], res: IEnumerable_1[Any]) -> CachedSeq_1[_T]:
|
|
1206
|
+
return CachedSeq_1(cleanup, res)
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
def CachedSeq_1__Clear(_: CachedSeq_1[Any]) -> None:
|
|
1210
|
+
_.cleanup(None)
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
def cache(source: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1214
|
+
check_non_null("source", source)
|
|
1215
|
+
prefix: Array[_T] = []
|
|
1216
|
+
enumerator_r: (IEnumerator[_T] | None) | None = None
|
|
1217
|
+
|
|
1218
|
+
def cleanup(__unit: None = None, source: Any = source) -> None:
|
|
1219
|
+
def action_1(__unit: None = None) -> None:
|
|
1220
|
+
nonlocal enumerator_r
|
|
1221
|
+
clear(prefix)
|
|
1222
|
+
(pattern_matching_result, e) = (None, None)
|
|
1223
|
+
if enumerator_r is not None:
|
|
1224
|
+
if value_1(enumerator_r) is not None:
|
|
1225
|
+
pattern_matching_result = 0
|
|
1226
|
+
e = value_1(enumerator_r)
|
|
1227
|
+
|
|
1228
|
+
else:
|
|
1229
|
+
pattern_matching_result = 1
|
|
1230
|
+
|
|
1231
|
+
else:
|
|
1232
|
+
pattern_matching_result = 1
|
|
1233
|
+
|
|
1234
|
+
if pattern_matching_result == 0:
|
|
1235
|
+
dispose_2(e)
|
|
1236
|
+
|
|
1237
|
+
enumerator_r = None
|
|
1238
|
+
|
|
1239
|
+
lock(prefix, action_1)
|
|
1240
|
+
|
|
1241
|
+
def _arrow178(i_1: int, source: Any = source) -> tuple[_T, int] | None:
|
|
1242
|
+
def action(__unit: None = None) -> tuple[_T, int] | None:
|
|
1243
|
+
nonlocal enumerator_r
|
|
1244
|
+
if i_1 < len(prefix):
|
|
1245
|
+
return (prefix[i_1], i_1 + 1)
|
|
1246
|
+
|
|
1247
|
+
else:
|
|
1248
|
+
if i_1 >= len(prefix):
|
|
1249
|
+
opt_enumerator_2: IEnumerator[_T] | None
|
|
1250
|
+
if enumerator_r is not None:
|
|
1251
|
+
opt_enumerator_2 = value_1(enumerator_r)
|
|
1252
|
+
|
|
1253
|
+
else:
|
|
1254
|
+
opt_enumerator: IEnumerator[_T] | None = get_enumerator(source)
|
|
1255
|
+
enumerator_r = some(opt_enumerator)
|
|
1256
|
+
opt_enumerator_2 = opt_enumerator
|
|
1257
|
+
|
|
1258
|
+
if opt_enumerator_2 is None:
|
|
1259
|
+
pass
|
|
1260
|
+
|
|
1261
|
+
else:
|
|
1262
|
+
enumerator: IEnumerator[_T] = opt_enumerator_2
|
|
1263
|
+
if enumerator.System_Collections_IEnumerator_MoveNext():
|
|
1264
|
+
(prefix.append(enumerator.System_Collections_Generic_IEnumerator_1_get_Current()))
|
|
1265
|
+
|
|
1266
|
+
else:
|
|
1267
|
+
dispose_2(enumerator)
|
|
1268
|
+
enumerator_r = some(None)
|
|
1269
|
+
|
|
1270
|
+
if i_1 < len(prefix):
|
|
1271
|
+
return (prefix[i_1], i_1 + 1)
|
|
1272
|
+
|
|
1273
|
+
else:
|
|
1274
|
+
return None
|
|
1275
|
+
|
|
1276
|
+
return lock(prefix, action)
|
|
1277
|
+
|
|
1278
|
+
return CachedSeq_1__ctor_Z7A8347D4(cleanup, unfold(_arrow178, 0))
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
def all_pairs(xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> IEnumerable_1[tuple[_T1, _T2]]:
|
|
1282
|
+
ys_cache: IEnumerable_1[_T2] = cache(ys)
|
|
1283
|
+
|
|
1284
|
+
def _arrow179(__unit: None = None, xs: Any = xs, ys: Any = ys) -> IEnumerable_1[tuple[_T1, _T2]]:
|
|
1285
|
+
def mapping_1(x: _T1 | None = None) -> IEnumerable_1[tuple[_T1, _T2]]:
|
|
1286
|
+
def mapping(y: _T2 | None = None, x: Any = x) -> tuple[_T1, _T2]:
|
|
1287
|
+
return (x, y)
|
|
1288
|
+
|
|
1289
|
+
return map(mapping, ys_cache)
|
|
1290
|
+
|
|
1291
|
+
return concat(map(mapping_1, xs))
|
|
1292
|
+
|
|
1293
|
+
return delay(_arrow179)
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
def map_fold(
|
|
1297
|
+
mapping: Callable[[_STATE, _T], tuple[_RESULT, _STATE]], state: Any, xs: IEnumerable_1[Any]
|
|
1298
|
+
) -> tuple[IEnumerable_1[_RESULT], _STATE]:
|
|
1299
|
+
pattern_input: tuple[Array[_RESULT], _STATE] = map_fold_1(mapping, state, to_array(xs), None)
|
|
1300
|
+
return (read_only(pattern_input[0]), pattern_input[1])
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
def map_fold_back(
|
|
1304
|
+
mapping: Callable[[_T, _STATE], tuple[_RESULT, _STATE]], xs: IEnumerable_1[Any], state: Any
|
|
1305
|
+
) -> tuple[IEnumerable_1[_RESULT], _STATE]:
|
|
1306
|
+
pattern_input: tuple[Array[_RESULT], _STATE] = map_fold_back_1(mapping, to_array(xs), state, None)
|
|
1307
|
+
return (read_only(pattern_input[0]), pattern_input[1])
|
|
1308
|
+
|
|
1309
|
+
|
|
1310
|
+
def try_pick(chooser: Callable[[_T], __A | None], xs: IEnumerable_1[Any]) -> Any | None:
|
|
1311
|
+
with of_seq(xs) as e:
|
|
1312
|
+
res: __A | None = None
|
|
1313
|
+
while e.System_Collections_IEnumerator_MoveNext() if (res is None) else False:
|
|
1314
|
+
res = chooser(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1315
|
+
return res
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
def pick(chooser: Callable[[_T], __A | None], xs: IEnumerable_1[Any]) -> Any:
|
|
1319
|
+
match_value: __A | None = try_pick(chooser, xs)
|
|
1320
|
+
if match_value is None:
|
|
1321
|
+
return index_not_found()
|
|
1322
|
+
|
|
1323
|
+
else:
|
|
1324
|
+
return value_1(match_value)
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
def reduce(folder: Callable[[_T, _T], _T], xs: IEnumerable_1[Any]) -> Any:
|
|
1328
|
+
with of_seq(xs) as e:
|
|
1329
|
+
|
|
1330
|
+
def loop(acc_mut: _T | None = None, folder: Any = folder, xs: Any = xs) -> _T | None:
|
|
1331
|
+
while True:
|
|
1332
|
+
(acc,) = (acc_mut,)
|
|
1333
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
1334
|
+
acc_mut = folder(acc, e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1335
|
+
continue
|
|
1336
|
+
|
|
1337
|
+
else:
|
|
1338
|
+
return acc
|
|
1339
|
+
|
|
1340
|
+
break
|
|
1341
|
+
|
|
1342
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
1343
|
+
return loop(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1344
|
+
|
|
1345
|
+
else:
|
|
1346
|
+
raise Exception(SR_inputSequenceEmpty)
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
def reduce_back(folder: Callable[[_T, _T], _T], xs: IEnumerable_1[Any]) -> Any:
|
|
1350
|
+
arr: Array[_T] = to_array(xs)
|
|
1351
|
+
if len(arr) > 0:
|
|
1352
|
+
return reduce_back_1(folder, arr)
|
|
1353
|
+
|
|
1354
|
+
else:
|
|
1355
|
+
raise Exception(SR_inputSequenceEmpty)
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
def replicate(n: int, x: Any) -> IEnumerable_1[Any]:
|
|
1359
|
+
def _arrow180(_arg: int, n: Any = n, x: Any = x) -> __A:
|
|
1360
|
+
return x
|
|
1361
|
+
|
|
1362
|
+
return initialize(n, _arrow180)
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
def reverse(xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1366
|
+
def _arrow181(__unit: None = None, xs: Any = xs) -> IEnumerable_1[_T]:
|
|
1367
|
+
return of_array(reverse_1(to_array(xs)))
|
|
1368
|
+
|
|
1369
|
+
return delay(_arrow181)
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
def scan(folder: Callable[[_STATE, _T], _STATE], state: Any, xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1373
|
+
def _arrow182(__unit: None = None, folder: Any = folder, state: Any = state, xs: Any = xs) -> IEnumerable_1[_STATE]:
|
|
1374
|
+
acc: _STATE = state
|
|
1375
|
+
|
|
1376
|
+
def mapping(x: _T | None = None) -> _STATE:
|
|
1377
|
+
nonlocal acc
|
|
1378
|
+
acc = folder(acc, x)
|
|
1379
|
+
return acc
|
|
1380
|
+
|
|
1381
|
+
return concat(to_enumerable([singleton(state), map(mapping, xs)]))
|
|
1382
|
+
|
|
1383
|
+
return delay(_arrow182)
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
def scan_back(folder: Callable[[_T, _STATE], _STATE], xs: IEnumerable_1[Any], state: Any) -> IEnumerable_1[Any]:
|
|
1387
|
+
def _arrow183(__unit: None = None, folder: Any = folder, xs: Any = xs, state: Any = state) -> IEnumerable_1[_STATE]:
|
|
1388
|
+
return of_array(scan_back_1(folder, to_array(xs), state, None))
|
|
1389
|
+
|
|
1390
|
+
return delay(_arrow183)
|
|
1391
|
+
|
|
1392
|
+
|
|
1393
|
+
def skip(count: int, source: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1394
|
+
def _arrow184(__unit: None = None, count: Any = count, source: Any = source) -> IEnumerator[_T]:
|
|
1395
|
+
e: IEnumerator[_T] = of_seq(source)
|
|
1396
|
+
try:
|
|
1397
|
+
for _ in range(1, count + 1, 1):
|
|
1398
|
+
if not e.System_Collections_IEnumerator_MoveNext():
|
|
1399
|
+
raise Exception((SR_notEnoughElements + "\\nParameter name: ") + "source")
|
|
1400
|
+
|
|
1401
|
+
def compensation(__unit: None = None) -> None:
|
|
1402
|
+
pass
|
|
1403
|
+
|
|
1404
|
+
return Enumerator_enumerateThenFinally(compensation, e)
|
|
1405
|
+
|
|
1406
|
+
except Exception as match_value:
|
|
1407
|
+
dispose_2(e)
|
|
1408
|
+
raise match_value
|
|
1409
|
+
|
|
1410
|
+
return mk_seq(_arrow184)
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
def skip_while(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1414
|
+
def _arrow185(__unit: None = None, predicate: Any = predicate, xs: Any = xs) -> IEnumerable_1[_T]:
|
|
1415
|
+
skipped: bool = True
|
|
1416
|
+
|
|
1417
|
+
def f(x: _T | None = None) -> bool:
|
|
1418
|
+
nonlocal skipped
|
|
1419
|
+
if skipped:
|
|
1420
|
+
skipped = predicate(x)
|
|
1421
|
+
|
|
1422
|
+
return not skipped
|
|
1423
|
+
|
|
1424
|
+
return filter(f, xs)
|
|
1425
|
+
|
|
1426
|
+
return delay(_arrow185)
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
def tail(xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1430
|
+
return skip(1, xs)
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
def take(count: int, xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1434
|
+
def _arrow186(__unit: None = None, count: Any = count, xs: Any = xs) -> IEnumerator[_T]:
|
|
1435
|
+
return of_seq(xs)
|
|
1436
|
+
|
|
1437
|
+
def _arrow187(i: int, e: IEnumerator[_T], count: Any = count, xs: Any = xs) -> _T | None:
|
|
1438
|
+
if i < count:
|
|
1439
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
1440
|
+
return some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1441
|
+
|
|
1442
|
+
else:
|
|
1443
|
+
raise Exception((SR_notEnoughElements + "\\nParameter name: ") + "source")
|
|
1444
|
+
|
|
1445
|
+
else:
|
|
1446
|
+
return None
|
|
1447
|
+
|
|
1448
|
+
def _arrow188(e_1: IEnumerator[_T], count: Any = count, xs: Any = xs) -> None:
|
|
1449
|
+
dispose_2(e_1)
|
|
1450
|
+
|
|
1451
|
+
return generate_indexed(_arrow186, _arrow187, _arrow188)
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
def take_while(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1455
|
+
def _arrow189(__unit: None = None, predicate: Any = predicate, xs: Any = xs) -> IEnumerator[_T]:
|
|
1456
|
+
return of_seq(xs)
|
|
1457
|
+
|
|
1458
|
+
def _arrow190(e: IEnumerator[_T], predicate: Any = predicate, xs: Any = xs) -> _T | None:
|
|
1459
|
+
return (
|
|
1460
|
+
some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1461
|
+
if (
|
|
1462
|
+
predicate(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1463
|
+
if e.System_Collections_IEnumerator_MoveNext()
|
|
1464
|
+
else False
|
|
1465
|
+
)
|
|
1466
|
+
else None
|
|
1467
|
+
)
|
|
1468
|
+
|
|
1469
|
+
def _arrow191(e_1: IEnumerator[_T], predicate: Any = predicate, xs: Any = xs) -> None:
|
|
1470
|
+
dispose_2(e_1)
|
|
1471
|
+
|
|
1472
|
+
return generate(_arrow189, _arrow190, _arrow191)
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
def truncate(count: int, xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1476
|
+
def _arrow192(__unit: None = None, count: Any = count, xs: Any = xs) -> IEnumerator[_T]:
|
|
1477
|
+
return of_seq(xs)
|
|
1478
|
+
|
|
1479
|
+
def _arrow193(i: int, e: IEnumerator[_T], count: Any = count, xs: Any = xs) -> _T | None:
|
|
1480
|
+
return (
|
|
1481
|
+
some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1482
|
+
if (e.System_Collections_IEnumerator_MoveNext() if (i < count) else False)
|
|
1483
|
+
else None
|
|
1484
|
+
)
|
|
1485
|
+
|
|
1486
|
+
def _arrow194(e_1: IEnumerator[_T], count: Any = count, xs: Any = xs) -> None:
|
|
1487
|
+
dispose_2(e_1)
|
|
1488
|
+
|
|
1489
|
+
return generate_indexed(_arrow192, _arrow193, _arrow194)
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
def zip(xs: IEnumerable_1[Any], ys: IEnumerable_1[Any]) -> IEnumerable_1[tuple[_T1, _T2]]:
|
|
1493
|
+
def _arrow195(x: _T1, y: _T2, xs: Any = xs, ys: Any = ys) -> tuple[_T1, _T2]:
|
|
1494
|
+
return (x, y)
|
|
1495
|
+
|
|
1496
|
+
return map2(_arrow195, xs, ys)
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
def zip3(xs: IEnumerable_1[Any], ys: IEnumerable_1[Any], zs: IEnumerable_1[Any]) -> IEnumerable_1[tuple[_T1, _T2, _T3]]:
|
|
1500
|
+
def _arrow196(x: _T1, y: _T2, z: _T3, xs: Any = xs, ys: Any = ys, zs: Any = zs) -> tuple[_T1, _T2, _T3]:
|
|
1501
|
+
return (x, y, z)
|
|
1502
|
+
|
|
1503
|
+
return map3(_arrow196, xs, ys, zs)
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
def collect(mapping: Callable[[_T], _COLLECTION], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1507
|
+
def _arrow197(__unit: None = None, mapping: Any = mapping, xs: Any = xs) -> IEnumerable_1[_U]:
|
|
1508
|
+
return concat(map(mapping, xs))
|
|
1509
|
+
|
|
1510
|
+
return delay(_arrow197)
|
|
1511
|
+
|
|
1512
|
+
|
|
1513
|
+
def where(predicate: Callable[[_T], bool], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1514
|
+
return filter(predicate, xs)
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
def pairwise(xs: IEnumerable_1[Any]) -> IEnumerable_1[tuple[_T, _T]]:
|
|
1518
|
+
def _arrow198(__unit: None = None, xs: Any = xs) -> IEnumerable_1[tuple[_T, _T]]:
|
|
1519
|
+
return of_array(pairwise_1(to_array(xs)))
|
|
1520
|
+
|
|
1521
|
+
return delay(_arrow198)
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
def split_into(chunks: int, xs: IEnumerable_1[Any]) -> IEnumerable_1[Array[Any]]:
|
|
1525
|
+
def _arrow199(__unit: None = None, chunks: Any = chunks, xs: Any = xs) -> IEnumerable_1[Array[_T]]:
|
|
1526
|
+
return of_array(split_into_1(chunks, to_array(xs)))
|
|
1527
|
+
|
|
1528
|
+
return delay(_arrow199)
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
def windowed(window_size: int, xs: IEnumerable_1[Any]) -> IEnumerable_1[Array[Any]]:
|
|
1532
|
+
def _arrow200(__unit: None = None, window_size: Any = window_size, xs: Any = xs) -> IEnumerable_1[Array[_T]]:
|
|
1533
|
+
return of_array(windowed_1(window_size, to_array(xs)))
|
|
1534
|
+
|
|
1535
|
+
return delay(_arrow200)
|
|
1536
|
+
|
|
1537
|
+
|
|
1538
|
+
def transpose(xss: IEnumerable_1[Any]) -> IEnumerable_1[IEnumerable_1[Any]]:
|
|
1539
|
+
def _arrow201(__unit: None = None, xss: Any = xss) -> IEnumerable_1[IEnumerable_1[_T]]:
|
|
1540
|
+
return of_array(map_1(of_array, transpose_1(map_1(to_array, to_array(xss), None), None), None))
|
|
1541
|
+
|
|
1542
|
+
return delay(_arrow201)
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
def sort_with(comparer: Callable[[_T, _T], int], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1546
|
+
def _arrow202(__unit: None = None, comparer: Any = comparer, xs: Any = xs) -> IEnumerable_1[_T]:
|
|
1547
|
+
arr: Array[_T] = to_array(xs)
|
|
1548
|
+
sort_in_place_with(comparer, arr)
|
|
1549
|
+
return of_array(arr)
|
|
1550
|
+
|
|
1551
|
+
return delay(_arrow202)
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
def sort(xs: IEnumerable_1[Any], comparer: IComparer_1[Any]) -> IEnumerable_1[Any]:
|
|
1555
|
+
def _arrow203(x: _T, y: _T, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
1556
|
+
return comparer.Compare(x, y)
|
|
1557
|
+
|
|
1558
|
+
return sort_with(_arrow203, xs)
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
def sort_by(projection: Callable[[_T], _U], xs: IEnumerable_1[Any], comparer: IComparer_1[Any]) -> IEnumerable_1[Any]:
|
|
1562
|
+
def _arrow204(x: _T, y: _T, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
1563
|
+
return comparer.Compare(projection(x), projection(y))
|
|
1564
|
+
|
|
1565
|
+
return sort_with(_arrow204, xs)
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
def sort_descending(xs: IEnumerable_1[Any], comparer: IComparer_1[Any]) -> IEnumerable_1[Any]:
|
|
1569
|
+
def _arrow205(x: _T, y: _T, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
1570
|
+
return comparer.Compare(x, y) * -1
|
|
1571
|
+
|
|
1572
|
+
return sort_with(_arrow205, xs)
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
def sort_by_descending(
|
|
1576
|
+
projection: Callable[[_T], _U], xs: IEnumerable_1[Any], comparer: IComparer_1[Any]
|
|
1577
|
+
) -> IEnumerable_1[Any]:
|
|
1578
|
+
def _arrow206(x: _T, y: _T, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> int:
|
|
1579
|
+
return comparer.Compare(projection(x), projection(y)) * -1
|
|
1580
|
+
|
|
1581
|
+
return sort_with(_arrow206, xs)
|
|
1582
|
+
|
|
1583
|
+
|
|
1584
|
+
def sum(xs: IEnumerable_1[Any], adder: IGenericAdder_1[Any]) -> Any:
|
|
1585
|
+
def _arrow207(acc: _T, x: _T, xs: Any = xs, adder: Any = adder) -> _T:
|
|
1586
|
+
return adder.Add(acc, x)
|
|
1587
|
+
|
|
1588
|
+
return fold(_arrow207, adder.GetZero(), xs)
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
def sum_by(f: Callable[[_T], _U], xs: IEnumerable_1[Any], adder: IGenericAdder_1[Any]) -> Any:
|
|
1592
|
+
def _arrow208(acc: _U, x: _T, f: Any = f, xs: Any = xs, adder: Any = adder) -> _U:
|
|
1593
|
+
return adder.Add(acc, f(x))
|
|
1594
|
+
|
|
1595
|
+
return fold(_arrow208, adder.GetZero(), xs)
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
def max_by(projection: Callable[[_T], _U], xs: IEnumerable_1[Any], comparer: IComparer_1[Any]) -> Any:
|
|
1599
|
+
def _arrow209(x: _T, y: _T, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> _T:
|
|
1600
|
+
return y if (comparer.Compare(projection(y), projection(x)) > 0) else x
|
|
1601
|
+
|
|
1602
|
+
return reduce(_arrow209, xs)
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
def max(xs: IEnumerable_1[Any], comparer: IComparer_1[Any]) -> Any:
|
|
1606
|
+
def _arrow210(x: _T, y: _T, xs: Any = xs, comparer: Any = comparer) -> _T:
|
|
1607
|
+
return y if (comparer.Compare(y, x) > 0) else x
|
|
1608
|
+
|
|
1609
|
+
return reduce(_arrow210, xs)
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
def min_by(projection: Callable[[_T], _U], xs: IEnumerable_1[Any], comparer: IComparer_1[Any]) -> Any:
|
|
1613
|
+
def _arrow211(x: _T, y: _T, projection: Any = projection, xs: Any = xs, comparer: Any = comparer) -> _T:
|
|
1614
|
+
return x if (comparer.Compare(projection(y), projection(x)) > 0) else y
|
|
1615
|
+
|
|
1616
|
+
return reduce(_arrow211, xs)
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
def min(xs: IEnumerable_1[Any], comparer: IComparer_1[Any]) -> Any:
|
|
1620
|
+
def _arrow212(x: _T, y: _T, xs: Any = xs, comparer: Any = comparer) -> _T:
|
|
1621
|
+
return x if (comparer.Compare(y, x) > 0) else y
|
|
1622
|
+
|
|
1623
|
+
return reduce(_arrow212, xs)
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
def average(xs: IEnumerable_1[Any], averager: IGenericAverager_1[Any]) -> Any:
|
|
1627
|
+
count: int = 0
|
|
1628
|
+
|
|
1629
|
+
def folder(acc: _T, x: _T, xs: Any = xs, averager: Any = averager) -> _T:
|
|
1630
|
+
nonlocal count
|
|
1631
|
+
count = (count + 1) or 0
|
|
1632
|
+
return averager.Add(acc, x)
|
|
1633
|
+
|
|
1634
|
+
total: _T = fold(folder, averager.GetZero(), xs)
|
|
1635
|
+
if count == 0:
|
|
1636
|
+
raise Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "source")
|
|
1637
|
+
|
|
1638
|
+
else:
|
|
1639
|
+
return averager.DivideByInt(total, count)
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
def average_by(f: Callable[[_T], _U], xs: IEnumerable_1[Any], averager: IGenericAverager_1[Any]) -> Any:
|
|
1643
|
+
count: int = 0
|
|
1644
|
+
|
|
1645
|
+
def _arrow213(acc: _U, x: _T, f: Any = f, xs: Any = xs, averager: Any = averager) -> _U:
|
|
1646
|
+
nonlocal count
|
|
1647
|
+
count = (count + 1) or 0
|
|
1648
|
+
return averager.Add(acc, f(x))
|
|
1649
|
+
|
|
1650
|
+
total: _U = fold(_arrow213, averager.GetZero(), xs)
|
|
1651
|
+
if count == 0:
|
|
1652
|
+
raise Exception((SR_inputSequenceEmpty + "\\nParameter name: ") + "source")
|
|
1653
|
+
|
|
1654
|
+
else:
|
|
1655
|
+
return averager.DivideByInt(total, count)
|
|
1656
|
+
|
|
1657
|
+
|
|
1658
|
+
def permute(f: Callable[[int], int], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1659
|
+
def _arrow214(__unit: None = None, f: Any = f, xs: Any = xs) -> IEnumerable_1[_T]:
|
|
1660
|
+
return of_array(permute_1(f, to_array(xs)))
|
|
1661
|
+
|
|
1662
|
+
return delay(_arrow214)
|
|
1663
|
+
|
|
1664
|
+
|
|
1665
|
+
def chunk_by_size(chunk_size: int, xs: IEnumerable_1[Any]) -> IEnumerable_1[Array[Any]]:
|
|
1666
|
+
def _arrow215(__unit: None = None, chunk_size: Any = chunk_size, xs: Any = xs) -> IEnumerable_1[Array[_T]]:
|
|
1667
|
+
return of_array(chunk_by_size_1(chunk_size, to_array(xs)))
|
|
1668
|
+
|
|
1669
|
+
return delay(_arrow215)
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
def insert_at(index: int, y: Any, xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1673
|
+
is_done: bool = False
|
|
1674
|
+
if index < 0:
|
|
1675
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1676
|
+
|
|
1677
|
+
def _arrow216(__unit: None = None, index: Any = index, y: Any = y, xs: Any = xs) -> IEnumerator[_T]:
|
|
1678
|
+
return of_seq(xs)
|
|
1679
|
+
|
|
1680
|
+
def _arrow217(i: int, e: IEnumerator[_T], index: Any = index, y: Any = y, xs: Any = xs) -> _T | None:
|
|
1681
|
+
nonlocal is_done
|
|
1682
|
+
if e.System_Collections_IEnumerator_MoveNext() if (True if is_done else (i < index)) else False:
|
|
1683
|
+
return some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1684
|
+
|
|
1685
|
+
elif i == index:
|
|
1686
|
+
is_done = True
|
|
1687
|
+
return some(y)
|
|
1688
|
+
|
|
1689
|
+
else:
|
|
1690
|
+
if not is_done:
|
|
1691
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1692
|
+
|
|
1693
|
+
return None
|
|
1694
|
+
|
|
1695
|
+
def _arrow218(e_1: IEnumerator[_T], index: Any = index, y: Any = y, xs: Any = xs) -> None:
|
|
1696
|
+
dispose_2(e_1)
|
|
1697
|
+
|
|
1698
|
+
return generate_indexed(_arrow216, _arrow217, _arrow218)
|
|
1699
|
+
|
|
1700
|
+
|
|
1701
|
+
def insert_many_at(index: int, ys: IEnumerable_1[Any], xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1702
|
+
status: int = -1
|
|
1703
|
+
if index < 0:
|
|
1704
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1705
|
+
|
|
1706
|
+
def _arrow219(
|
|
1707
|
+
__unit: None = None, index: Any = index, ys: Any = ys, xs: Any = xs
|
|
1708
|
+
) -> tuple[IEnumerator[_T], IEnumerator[_T]]:
|
|
1709
|
+
return (of_seq(xs), of_seq(ys))
|
|
1710
|
+
|
|
1711
|
+
def _arrow220(
|
|
1712
|
+
i: int, tupled_arg: tuple[IEnumerator[_T], IEnumerator[_T]], index: Any = index, ys: Any = ys, xs: Any = xs
|
|
1713
|
+
) -> _T | None:
|
|
1714
|
+
nonlocal status
|
|
1715
|
+
e1: IEnumerator[_T] = tupled_arg[0]
|
|
1716
|
+
e2: IEnumerator[_T] = tupled_arg[1]
|
|
1717
|
+
if i == index:
|
|
1718
|
+
status = 0
|
|
1719
|
+
|
|
1720
|
+
inserted: _T | None
|
|
1721
|
+
if status == 0:
|
|
1722
|
+
if e2.System_Collections_IEnumerator_MoveNext():
|
|
1723
|
+
inserted = some(e2.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1724
|
+
|
|
1725
|
+
else:
|
|
1726
|
+
status = 1
|
|
1727
|
+
inserted = None
|
|
1728
|
+
|
|
1729
|
+
else:
|
|
1730
|
+
inserted = None
|
|
1731
|
+
|
|
1732
|
+
if inserted is None:
|
|
1733
|
+
if e1.System_Collections_IEnumerator_MoveNext():
|
|
1734
|
+
return some(e1.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1735
|
+
|
|
1736
|
+
else:
|
|
1737
|
+
if status < 1:
|
|
1738
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1739
|
+
|
|
1740
|
+
return None
|
|
1741
|
+
|
|
1742
|
+
else:
|
|
1743
|
+
return some(value_1(inserted))
|
|
1744
|
+
|
|
1745
|
+
def _arrow221(
|
|
1746
|
+
tupled_arg_1: tuple[IEnumerator[_T], IEnumerator[_T]], index: Any = index, ys: Any = ys, xs: Any = xs
|
|
1747
|
+
) -> None:
|
|
1748
|
+
dispose_2(tupled_arg_1[0])
|
|
1749
|
+
dispose_2(tupled_arg_1[1])
|
|
1750
|
+
|
|
1751
|
+
return generate_indexed(_arrow219, _arrow220, _arrow221)
|
|
1752
|
+
|
|
1753
|
+
|
|
1754
|
+
def remove_at(index: int, xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1755
|
+
is_done: bool = False
|
|
1756
|
+
if index < 0:
|
|
1757
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1758
|
+
|
|
1759
|
+
def _arrow222(__unit: None = None, index: Any = index, xs: Any = xs) -> IEnumerator[_T]:
|
|
1760
|
+
return of_seq(xs)
|
|
1761
|
+
|
|
1762
|
+
def _arrow223(i: int, e: IEnumerator[_T], index: Any = index, xs: Any = xs) -> _T | None:
|
|
1763
|
+
nonlocal is_done
|
|
1764
|
+
if e.System_Collections_IEnumerator_MoveNext() if (True if is_done else (i < index)) else False:
|
|
1765
|
+
return some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1766
|
+
|
|
1767
|
+
elif e.System_Collections_IEnumerator_MoveNext() if (i == index) else False:
|
|
1768
|
+
is_done = True
|
|
1769
|
+
return (
|
|
1770
|
+
some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1771
|
+
if e.System_Collections_IEnumerator_MoveNext()
|
|
1772
|
+
else None
|
|
1773
|
+
)
|
|
1774
|
+
|
|
1775
|
+
else:
|
|
1776
|
+
if not is_done:
|
|
1777
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1778
|
+
|
|
1779
|
+
return None
|
|
1780
|
+
|
|
1781
|
+
def _arrow224(e_1: IEnumerator[_T], index: Any = index, xs: Any = xs) -> None:
|
|
1782
|
+
dispose_2(e_1)
|
|
1783
|
+
|
|
1784
|
+
return generate_indexed(_arrow222, _arrow223, _arrow224)
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
def remove_many_at(index: int, count: int, xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1788
|
+
if index < 0:
|
|
1789
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1790
|
+
|
|
1791
|
+
def _arrow225(__unit: None = None, index: Any = index, count: Any = count, xs: Any = xs) -> IEnumerator[_T]:
|
|
1792
|
+
return of_seq(xs)
|
|
1793
|
+
|
|
1794
|
+
def _arrow226(i: int, e: IEnumerator[_T], index: Any = index, count: Any = count, xs: Any = xs) -> _T | None:
|
|
1795
|
+
if i < index:
|
|
1796
|
+
if e.System_Collections_IEnumerator_MoveNext():
|
|
1797
|
+
return some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1798
|
+
|
|
1799
|
+
else:
|
|
1800
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1801
|
+
|
|
1802
|
+
else:
|
|
1803
|
+
if i == index:
|
|
1804
|
+
for _ in range(1, count + 1, 1):
|
|
1805
|
+
if not e.System_Collections_IEnumerator_MoveNext():
|
|
1806
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "count")
|
|
1807
|
+
|
|
1808
|
+
return (
|
|
1809
|
+
some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1810
|
+
if e.System_Collections_IEnumerator_MoveNext()
|
|
1811
|
+
else None
|
|
1812
|
+
)
|
|
1813
|
+
|
|
1814
|
+
def _arrow227(e_1: IEnumerator[_T], index: Any = index, count: Any = count, xs: Any = xs) -> None:
|
|
1815
|
+
dispose_2(e_1)
|
|
1816
|
+
|
|
1817
|
+
return generate_indexed(_arrow225, _arrow226, _arrow227)
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
def update_at(index: int, y: Any, xs: IEnumerable_1[Any]) -> IEnumerable_1[Any]:
|
|
1821
|
+
is_done: bool = False
|
|
1822
|
+
if index < 0:
|
|
1823
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1824
|
+
|
|
1825
|
+
def _arrow228(__unit: None = None, index: Any = index, y: Any = y, xs: Any = xs) -> IEnumerator[_T]:
|
|
1826
|
+
return of_seq(xs)
|
|
1827
|
+
|
|
1828
|
+
def _arrow229(i: int, e: IEnumerator[_T], index: Any = index, y: Any = y, xs: Any = xs) -> _T | None:
|
|
1829
|
+
nonlocal is_done
|
|
1830
|
+
if e.System_Collections_IEnumerator_MoveNext() if (True if is_done else (i < index)) else False:
|
|
1831
|
+
return some(e.System_Collections_Generic_IEnumerator_1_get_Current())
|
|
1832
|
+
|
|
1833
|
+
elif e.System_Collections_IEnumerator_MoveNext() if (i == index) else False:
|
|
1834
|
+
is_done = True
|
|
1835
|
+
return some(y)
|
|
1836
|
+
|
|
1837
|
+
else:
|
|
1838
|
+
if not is_done:
|
|
1839
|
+
raise Exception((SR_indexOutOfBounds + "\\nParameter name: ") + "index")
|
|
1840
|
+
|
|
1841
|
+
return None
|
|
1842
|
+
|
|
1843
|
+
def _arrow230(e_1: IEnumerator[_T], index: Any = index, y: Any = y, xs: Any = xs) -> None:
|
|
1844
|
+
dispose_2(e_1)
|
|
1845
|
+
|
|
1846
|
+
return generate_indexed(_arrow228, _arrow229, _arrow230)
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
__all__ = [
|
|
1850
|
+
"SR_enumerationAlreadyFinished",
|
|
1851
|
+
"SR_enumerationNotStarted",
|
|
1852
|
+
"SR_inputSequenceEmpty",
|
|
1853
|
+
"SR_inputSequenceTooLong",
|
|
1854
|
+
"SR_keyNotFoundAlt",
|
|
1855
|
+
"SR_notEnoughElements",
|
|
1856
|
+
"SR_resetNotSupported",
|
|
1857
|
+
"Enumerator_noReset",
|
|
1858
|
+
"Enumerator_notStarted",
|
|
1859
|
+
"Enumerator_alreadyFinished",
|
|
1860
|
+
"Enumerator_Seq_reflection",
|
|
1861
|
+
"Enumerator_FromFunctions_1_reflection",
|
|
1862
|
+
"Enumerator_cast",
|
|
1863
|
+
"Enumerator_concat",
|
|
1864
|
+
"Enumerator_enumerateThenFinally",
|
|
1865
|
+
"Enumerator_generateWhileSome",
|
|
1866
|
+
"Enumerator_unfold",
|
|
1867
|
+
"index_not_found",
|
|
1868
|
+
"check_non_null",
|
|
1869
|
+
"mk_seq",
|
|
1870
|
+
"of_seq",
|
|
1871
|
+
"delay",
|
|
1872
|
+
"concat",
|
|
1873
|
+
"unfold",
|
|
1874
|
+
"empty",
|
|
1875
|
+
"singleton",
|
|
1876
|
+
"of_array",
|
|
1877
|
+
"to_array",
|
|
1878
|
+
"of_list",
|
|
1879
|
+
"to_list",
|
|
1880
|
+
"generate",
|
|
1881
|
+
"generate_indexed",
|
|
1882
|
+
"append",
|
|
1883
|
+
"cast",
|
|
1884
|
+
"choose",
|
|
1885
|
+
"compare_with",
|
|
1886
|
+
"contains",
|
|
1887
|
+
"enumerate_from_functions",
|
|
1888
|
+
"enumerate_then_finally",
|
|
1889
|
+
"enumerate_using",
|
|
1890
|
+
"enumerate_while",
|
|
1891
|
+
"filter",
|
|
1892
|
+
"exists",
|
|
1893
|
+
"exists2",
|
|
1894
|
+
"exactly_one",
|
|
1895
|
+
"try_exactly_one",
|
|
1896
|
+
"try_find",
|
|
1897
|
+
"find",
|
|
1898
|
+
"try_find_back",
|
|
1899
|
+
"find_back",
|
|
1900
|
+
"try_find_index",
|
|
1901
|
+
"find_index",
|
|
1902
|
+
"try_find_index_back",
|
|
1903
|
+
"find_index_back",
|
|
1904
|
+
"fold",
|
|
1905
|
+
"fold_back",
|
|
1906
|
+
"fold2",
|
|
1907
|
+
"fold_back2",
|
|
1908
|
+
"for_all",
|
|
1909
|
+
"for_all2",
|
|
1910
|
+
"try_head",
|
|
1911
|
+
"head",
|
|
1912
|
+
"initialize",
|
|
1913
|
+
"initialize_infinite",
|
|
1914
|
+
"is_empty",
|
|
1915
|
+
"try_item",
|
|
1916
|
+
"item",
|
|
1917
|
+
"iterate",
|
|
1918
|
+
"iterate2",
|
|
1919
|
+
"iterate_indexed",
|
|
1920
|
+
"iterate_indexed2",
|
|
1921
|
+
"try_last",
|
|
1922
|
+
"last",
|
|
1923
|
+
"length",
|
|
1924
|
+
"map",
|
|
1925
|
+
"map_indexed",
|
|
1926
|
+
"indexed",
|
|
1927
|
+
"map2",
|
|
1928
|
+
"map_indexed2",
|
|
1929
|
+
"map3",
|
|
1930
|
+
"read_only",
|
|
1931
|
+
"CachedSeq_1_reflection",
|
|
1932
|
+
"CachedSeq_1__Clear",
|
|
1933
|
+
"cache",
|
|
1934
|
+
"all_pairs",
|
|
1935
|
+
"map_fold",
|
|
1936
|
+
"map_fold_back",
|
|
1937
|
+
"try_pick",
|
|
1938
|
+
"pick",
|
|
1939
|
+
"reduce",
|
|
1940
|
+
"reduce_back",
|
|
1941
|
+
"replicate",
|
|
1942
|
+
"reverse",
|
|
1943
|
+
"scan",
|
|
1944
|
+
"scan_back",
|
|
1945
|
+
"skip",
|
|
1946
|
+
"skip_while",
|
|
1947
|
+
"tail",
|
|
1948
|
+
"take",
|
|
1949
|
+
"take_while",
|
|
1950
|
+
"truncate",
|
|
1951
|
+
"zip",
|
|
1952
|
+
"zip3",
|
|
1953
|
+
"collect",
|
|
1954
|
+
"where",
|
|
1955
|
+
"pairwise",
|
|
1956
|
+
"split_into",
|
|
1957
|
+
"windowed",
|
|
1958
|
+
"transpose",
|
|
1959
|
+
"sort_with",
|
|
1960
|
+
"sort",
|
|
1961
|
+
"sort_by",
|
|
1962
|
+
"sort_descending",
|
|
1963
|
+
"sort_by_descending",
|
|
1964
|
+
"sum",
|
|
1965
|
+
"sum_by",
|
|
1966
|
+
"max_by",
|
|
1967
|
+
"max",
|
|
1968
|
+
"min_by",
|
|
1969
|
+
"min",
|
|
1970
|
+
"average",
|
|
1971
|
+
"average_by",
|
|
1972
|
+
"permute",
|
|
1973
|
+
"chunk_by_size",
|
|
1974
|
+
"insert_at",
|
|
1975
|
+
"insert_many_at",
|
|
1976
|
+
"remove_at",
|
|
1977
|
+
"remove_many_at",
|
|
1978
|
+
"update_at",
|
|
1979
|
+
]
|