@designliquido/delegua 0.14.6 → 0.15.0
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.
- package/README.md +85 -85
- package/bin/delegua +2 -2
- package/bin/package.json +88 -88
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.d.ts +67 -67
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js +215 -215
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -1
- package/fontes/avaliador-sintatico/avaliador-sintatico.d.ts +92 -92
- package/fontes/avaliador-sintatico/avaliador-sintatico.js +857 -727
- package/fontes/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-birl.d.ts +22 -22
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-birl.js +145 -145
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts +69 -69
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +640 -640
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.d.ts +84 -84
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js +714 -714
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.d.ts +20 -20
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js +149 -149
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-studio.d.ts +49 -32
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-studio.js +419 -192
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-studio.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.d.ts +73 -73
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.js +534 -534
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/index.d.ts +5 -5
- package/fontes/avaliador-sintatico/dialetos/index.js +21 -21
- package/fontes/avaliador-sintatico/erro-avaliador-sintatico.d.ts +5 -5
- package/fontes/avaliador-sintatico/erro-avaliador-sintatico.js +11 -11
- package/fontes/avaliador-sintatico/index.d.ts +2 -2
- package/fontes/avaliador-sintatico/index.js +18 -18
- package/fontes/avaliador-sintatico/retornos/index.d.ts +3 -3
- package/fontes/avaliador-sintatico/retornos/index.js +19 -19
- package/fontes/avaliador-sintatico/retornos/retorno-declaracao.d.ts +3 -3
- package/fontes/avaliador-sintatico/retornos/retorno-declaracao.js +2 -2
- package/fontes/avaliador-sintatico/retornos/retorno-primario.d.ts +3 -3
- package/fontes/avaliador-sintatico/retornos/retorno-primario.js +2 -2
- package/fontes/avaliador-sintatico/retornos/retorno-resolver-declaracao.d.ts +2 -2
- package/fontes/avaliador-sintatico/retornos/retorno-resolver-declaracao.js +2 -2
- package/fontes/bibliotecas/biblioteca-global.d.ts +3 -3
- package/fontes/bibliotecas/biblioteca-global.js +315 -315
- package/fontes/bibliotecas/dialetos/egua-classico/biblioteca-global.d.ts +1 -1
- package/fontes/bibliotecas/dialetos/egua-classico/biblioteca-global.js +230 -230
- package/fontes/bibliotecas/dialetos/egua-classico/index.d.ts +2 -2
- package/fontes/bibliotecas/dialetos/egua-classico/index.js +32 -32
- package/fontes/bibliotecas/dialetos/egua-classico/matematica.d.ts +1 -1
- package/fontes/bibliotecas/dialetos/egua-classico/matematica.js +478 -478
- package/fontes/bibliotecas/dialetos/egua-classico/tempo.d.ts +1 -1
- package/fontes/bibliotecas/dialetos/egua-classico/tempo.js +39 -39
- package/fontes/bibliotecas/dialetos/egua-classico/textos.d.ts +8 -8
- package/fontes/bibliotecas/dialetos/egua-classico/textos.js +201 -201
- package/fontes/bibliotecas/primitivas-texto.d.ts +11 -11
- package/fontes/bibliotecas/primitivas-texto.js +12 -12
- package/fontes/bibliotecas/primitivas-vetor.d.ts +15 -15
- package/fontes/bibliotecas/primitivas-vetor.js +33 -33
- package/fontes/construtos/acesso-indice-variavel.d.ts +15 -15
- package/fontes/construtos/acesso-indice-variavel.js +20 -20
- package/fontes/construtos/acesso-metodo.d.ts +14 -14
- package/fontes/construtos/acesso-metodo.js +19 -19
- package/fontes/construtos/agrupamento.d.ts +14 -14
- package/fontes/construtos/agrupamento.js +19 -19
- package/fontes/construtos/atribuicao-sobrescrita.d.ts +11 -11
- package/fontes/construtos/atribuicao-sobrescrita.js +16 -16
- package/fontes/construtos/atribuir.d.ts +10 -10
- package/fontes/construtos/atribuir.js +15 -15
- package/fontes/construtos/binario.d.ts +22 -22
- package/fontes/construtos/binario.js +27 -27
- package/fontes/construtos/chamada.d.ts +13 -13
- package/fontes/construtos/chamada.js +36 -36
- package/fontes/construtos/construto.d.ts +7 -7
- package/fontes/construtos/construto.js +2 -2
- package/fontes/construtos/definir-valor.d.ts +11 -11
- package/fontes/construtos/definir-valor.js +16 -16
- package/fontes/construtos/dicionario.d.ts +10 -10
- package/fontes/construtos/dicionario.js +15 -15
- package/fontes/construtos/formatacao-escrita.d.ts +16 -16
- package/fontes/construtos/formatacao-escrita.js +21 -21
- package/fontes/construtos/funcao.d.ts +10 -10
- package/fontes/construtos/funcao.js +15 -15
- package/fontes/construtos/index.d.ts +19 -19
- package/fontes/construtos/index.js +35 -35
- package/fontes/construtos/isto.d.ts +9 -9
- package/fontes/construtos/isto.js +14 -14
- package/fontes/construtos/literal.d.ts +10 -10
- package/fontes/construtos/literal.js +14 -14
- package/fontes/construtos/logico.d.ts +11 -11
- package/fontes/construtos/logico.js +16 -16
- package/fontes/construtos/super.d.ts +10 -10
- package/fontes/construtos/super.js +15 -15
- package/fontes/construtos/unario.d.ts +11 -10
- package/fontes/construtos/unario.js +16 -15
- package/fontes/construtos/unario.js.map +1 -1
- package/fontes/construtos/variavel.d.ts +9 -9
- package/fontes/construtos/variavel.js +14 -14
- package/fontes/construtos/vetor.d.ts +9 -9
- package/fontes/construtos/vetor.js +14 -14
- package/fontes/declaracoes/bloco.d.ts +7 -7
- package/fontes/declaracoes/bloco.js +14 -14
- package/fontes/declaracoes/classe.d.ts +9 -9
- package/fontes/declaracoes/classe.js +16 -16
- package/fontes/declaracoes/continua.d.ts +6 -6
- package/fontes/declaracoes/continua.js +13 -13
- package/fontes/declaracoes/declaracao.d.ts +8 -8
- package/fontes/declaracoes/declaracao.js +17 -17
- package/fontes/declaracoes/enquanto.d.ts +9 -9
- package/fontes/declaracoes/enquanto.js +15 -15
- package/fontes/declaracoes/escolha.d.ts +14 -14
- package/fontes/declaracoes/escolha.js +19 -19
- package/fontes/declaracoes/escreva-mesma-linha.d.ts +8 -8
- package/fontes/declaracoes/escreva-mesma-linha.js +14 -14
- package/fontes/declaracoes/escreva.d.ts +8 -8
- package/fontes/declaracoes/escreva.js +14 -14
- package/fontes/declaracoes/expressao.d.ts +8 -8
- package/fontes/declaracoes/expressao.js +14 -14
- package/fontes/declaracoes/fazer.d.ts +8 -8
- package/fontes/declaracoes/fazer.js +15 -15
- package/fontes/declaracoes/funcao.d.ts +9 -9
- package/fontes/declaracoes/funcao.js +15 -15
- package/fontes/declaracoes/importar.d.ts +9 -9
- package/fontes/declaracoes/importar.js +15 -15
- package/fontes/declaracoes/index.d.ts +19 -19
- package/fontes/declaracoes/index.js +35 -35
- package/fontes/declaracoes/leia.d.ts +12 -12
- package/fontes/declaracoes/leia.js +18 -18
- package/fontes/declaracoes/para.d.ts +10 -10
- package/fontes/declaracoes/para.js +17 -17
- package/fontes/declaracoes/retorna.d.ts +8 -8
- package/fontes/declaracoes/retorna.js +15 -15
- package/fontes/declaracoes/se.d.ts +11 -11
- package/fontes/declaracoes/se.js +17 -17
- package/fontes/declaracoes/sustar.d.ts +6 -6
- package/fontes/declaracoes/sustar.js +13 -13
- package/fontes/declaracoes/tente.d.ts +14 -14
- package/fontes/declaracoes/tente.js +20 -20
- package/fontes/declaracoes/var.d.ts +9 -9
- package/fontes/declaracoes/var.js +15 -15
- package/fontes/depuracao/cyrb53.d.ts +9 -9
- package/fontes/depuracao/cyrb53.js +22 -22
- package/fontes/depuracao/index.d.ts +2 -2
- package/fontes/depuracao/index.js +23 -23
- package/fontes/depuracao/ponto-parada.d.ts +4 -4
- package/fontes/depuracao/ponto-parada.js +2 -2
- package/fontes/espaco-variaveis.d.ts +19 -19
- package/fontes/espaco-variaveis.js +19 -19
- package/fontes/estruturas/chamavel.d.ts +5 -5
- package/fontes/estruturas/chamavel.js +12 -12
- package/fontes/estruturas/classe-padrao.d.ts +17 -17
- package/fontes/estruturas/classe-padrao.js +28 -28
- package/fontes/estruturas/delegua-classe.d.ts +16 -16
- package/fontes/estruturas/delegua-classe.js +38 -38
- package/fontes/estruturas/delegua-funcao.d.ts +18 -18
- package/fontes/estruturas/delegua-funcao.js +60 -60
- package/fontes/estruturas/funcao-padrao.d.ts +12 -12
- package/fontes/estruturas/funcao-padrao.js +22 -22
- package/fontes/estruturas/index.d.ts +9 -9
- package/fontes/estruturas/index.js +25 -25
- package/fontes/estruturas/metodo-primitiva.d.ts +17 -17
- package/fontes/estruturas/metodo-primitiva.js +26 -26
- package/fontes/estruturas/modulo.d.ts +9 -9
- package/fontes/estruturas/modulo.js +13 -13
- package/fontes/estruturas/objeto-delegua-classe.d.ts +10 -10
- package/fontes/estruturas/objeto-delegua-classe.js +26 -26
- package/fontes/estruturas/objeto-padrao.d.ts +9 -9
- package/fontes/estruturas/objeto-padrao.js +21 -21
- package/fontes/excecoes/erro-em-tempo-de-execucao.d.ts +7 -7
- package/fontes/excecoes/erro-em-tempo-de-execucao.js +13 -13
- package/fontes/excecoes/index.d.ts +1 -1
- package/fontes/excecoes/index.js +17 -17
- package/fontes/formatadores/delegua.d.ts +18 -11
- package/fontes/formatadores/delegua.js +82 -99
- package/fontes/formatadores/delegua.js.map +1 -1
- package/fontes/formatadores/index.d.ts +1 -1
- package/fontes/formatadores/index.js +17 -17
- package/fontes/interfaces/avaliador-sintatico-interface.d.ts +57 -57
- package/fontes/interfaces/avaliador-sintatico-interface.js +2 -2
- package/fontes/interfaces/construtos/index.d.ts +4 -4
- package/fontes/interfaces/construtos/index.js +2 -2
- package/fontes/interfaces/escopo-execucao.d.ts +11 -11
- package/fontes/interfaces/escopo-execucao.js +2 -2
- package/fontes/interfaces/index.d.ts +11 -11
- package/fontes/interfaces/index.js +27 -27
- package/fontes/interfaces/interpretador-com-depuracao-interface.d.ts +17 -17
- package/fontes/interfaces/interpretador-com-depuracao-interface.js +2 -2
- package/fontes/interfaces/interpretador-interface.d.ts +55 -55
- package/fontes/interfaces/interpretador-interface.js +2 -2
- package/fontes/interfaces/lexador-interface.d.ts +23 -23
- package/fontes/interfaces/lexador-interface.js +2 -2
- package/fontes/interfaces/parametro-interface.d.ts +6 -6
- package/fontes/interfaces/parametro-interface.js +2 -2
- package/fontes/interfaces/pilha-escopos-execucao-interface.d.ts +25 -25
- package/fontes/interfaces/pilha-escopos-execucao-interface.js +2 -2
- package/fontes/interfaces/pilha-interface.d.ts +7 -7
- package/fontes/interfaces/pilha-interface.js +2 -2
- package/fontes/interfaces/resolvedor-interface.d.ts +41 -41
- package/fontes/interfaces/resolvedor-interface.js +2 -2
- package/fontes/interfaces/retornos/index.d.ts +4 -4
- package/fontes/interfaces/retornos/index.js +20 -20
- package/fontes/interfaces/retornos/retorno-avaliador-sintatico.d.ts +6 -6
- package/fontes/interfaces/retornos/retorno-avaliador-sintatico.js +2 -2
- package/fontes/interfaces/retornos/retorno-execucao-interface.d.ts +5 -5
- package/fontes/interfaces/retornos/retorno-execucao-interface.js +2 -2
- package/fontes/interfaces/retornos/retorno-interpretador.d.ts +5 -5
- package/fontes/interfaces/retornos/retorno-interpretador.js +2 -2
- package/fontes/interfaces/retornos/retorno-lexador.d.ts +10 -10
- package/fontes/interfaces/retornos/retorno-lexador.js +2 -2
- package/fontes/interfaces/simbolo-interface.d.ts +7 -7
- package/fontes/interfaces/simbolo-interface.js +2 -2
- package/fontes/interfaces/tradutor-interface.d.ts +4 -4
- package/fontes/interfaces/tradutor-interface.js +2 -2
- package/fontes/interfaces/variavel-interface.d.ts +4 -4
- package/fontes/interfaces/variavel-interface.js +2 -2
- package/fontes/interpretador/dialetos/egua-classico/index.d.ts +1 -1
- package/fontes/interpretador/dialetos/egua-classico/index.js +17 -17
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.d.ts +99 -99
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.js +743 -743
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.js.map +1 -1
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/erro-resolvedor.d.ts +5 -5
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/erro-resolvedor.js +11 -11
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/index.d.ts +3 -3
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/index.js +19 -19
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/pilha-escopos.d.ts +9 -9
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/pilha-escopos.js +25 -25
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/resolvedor.d.ts +87 -87
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/resolvedor.js +387 -387
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/retorno-resolvedor.d.ts +6 -6
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/retorno-resolvedor.js +2 -2
- package/fontes/interpretador/dialetos/index.d.ts +4 -4
- package/fontes/interpretador/dialetos/index.js +20 -20
- package/fontes/interpretador/dialetos/portugol-studio/interpretador-portugol-studio.d.ts +12 -12
- package/fontes/interpretador/dialetos/portugol-studio/interpretador-portugol-studio.js +26 -26
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg-com-depuracao.d.ts +40 -40
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg-com-depuracao.js +96 -96
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg.d.ts +46 -46
- package/fontes/interpretador/dialetos/visualg/interpretador-visualg.js +102 -102
- package/fontes/interpretador/erro-interpretador.d.ts +8 -8
- package/fontes/interpretador/erro-interpretador.js +2 -2
- package/fontes/interpretador/index.d.ts +4 -4
- package/fontes/interpretador/index.js +20 -20
- package/fontes/interpretador/inferenciador.d.ts +1 -1
- package/fontes/interpretador/inferenciador.js +31 -31
- package/fontes/interpretador/interpretador-base.d.ts +187 -187
- package/fontes/interpretador/interpretador-base.js +998 -972
- package/fontes/interpretador/interpretador-base.js.map +1 -1
- package/fontes/interpretador/interpretador-com-depuracao.d.ts +199 -199
- package/fontes/interpretador/interpretador-com-depuracao.js +516 -516
- package/fontes/interpretador/pilha-escopos-execucao.d.ts +38 -38
- package/fontes/interpretador/pilha-escopos-execucao.js +158 -158
- package/fontes/lexador/dialetos/index.d.ts +6 -6
- package/fontes/lexador/dialetos/index.js +22 -22
- package/fontes/lexador/dialetos/lexador-birl.d.ts +12 -12
- package/fontes/lexador/dialetos/lexador-birl.js +165 -165
- package/fontes/lexador/dialetos/lexador-egua-classico.d.ts +36 -36
- package/fontes/lexador/dialetos/lexador-egua-classico.js +286 -286
- package/fontes/lexador/dialetos/lexador-eguap.d.ts +51 -51
- package/fontes/lexador/dialetos/lexador-eguap.js +398 -398
- package/fontes/lexador/dialetos/lexador-guarani.d.ts +9 -9
- package/fontes/lexador/dialetos/lexador-guarani.js +113 -113
- package/fontes/lexador/dialetos/lexador-portugol-ipt.d.ts +33 -33
- package/fontes/lexador/dialetos/lexador-portugol-ipt.js +195 -195
- package/fontes/lexador/dialetos/lexador-portugol-studio.d.ts +21 -15
- package/fontes/lexador/dialetos/lexador-portugol-studio.js +280 -242
- package/fontes/lexador/dialetos/lexador-portugol-studio.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-visualg.d.ts +18 -18
- package/fontes/lexador/dialetos/lexador-visualg.js +218 -218
- package/fontes/lexador/dialetos/palavras-reservadas/birl.d.ts +41 -41
- package/fontes/lexador/dialetos/palavras-reservadas/birl.js +58 -58
- package/fontes/lexador/dialetos/palavras-reservadas/egua-classico.d.ts +36 -36
- package/fontes/lexador/dialetos/palavras-reservadas/egua-classico.js +41 -41
- package/fontes/lexador/dialetos/palavras-reservadas/guarani.d.ts +4 -4
- package/fontes/lexador/dialetos/palavras-reservadas/guarani.js +9 -9
- package/fontes/lexador/dialetos/palavras-reservadas/index.d.ts +3 -3
- package/fontes/lexador/dialetos/palavras-reservadas/index.js +19 -19
- package/fontes/lexador/dialetos/palavras-reservadas/portugol-ipt.d.ts +6 -6
- package/fontes/lexador/dialetos/palavras-reservadas/portugol-ipt.js +11 -11
- package/fontes/lexador/dialetos/palavras-reservadas/portugol-studio.d.ts +23 -8
- package/fontes/lexador/dialetos/palavras-reservadas/portugol-studio.js +28 -13
- package/fontes/lexador/dialetos/palavras-reservadas/portugol-studio.js.map +1 -1
- package/fontes/lexador/dialetos/palavras-reservadas/rantiaquin.d.ts +2 -2
- package/fontes/lexador/dialetos/palavras-reservadas/rantiaquin.js +3 -3
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.d.ts +60 -60
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.js +65 -65
- package/fontes/lexador/dialetos/pragma.d.ts +8 -8
- package/fontes/lexador/dialetos/pragma.js +2 -2
- package/fontes/lexador/erro-lexador.d.ts +5 -5
- package/fontes/lexador/erro-lexador.js +2 -2
- package/fontes/lexador/index.d.ts +2 -2
- package/fontes/lexador/index.js +18 -18
- package/fontes/lexador/lexador-base-linha-unica.d.ts +28 -28
- package/fontes/lexador/lexador-base-linha-unica.js +82 -82
- package/fontes/lexador/lexador-base.d.ts +41 -41
- package/fontes/lexador/lexador-base.js +112 -112
- package/fontes/lexador/lexador-base.js.map +1 -1
- package/fontes/lexador/lexador.d.ts +43 -43
- package/fontes/lexador/lexador.js +412 -408
- package/fontes/lexador/lexador.js.map +1 -1
- package/fontes/lexador/palavras-reservadas.d.ts +36 -36
- package/fontes/lexador/palavras-reservadas.js +41 -41
- package/fontes/lexador/simbolo.d.ts +10 -10
- package/fontes/lexador/simbolo.js +16 -16
- package/fontes/quebras/index.d.ts +10 -10
- package/fontes/quebras/index.js +19 -19
- package/fontes/tipos-de-simbolos/birl.d.ts +57 -57
- package/fontes/tipos-de-simbolos/birl.js +61 -61
- package/fontes/tipos-de-simbolos/comum.d.ts +22 -22
- package/fontes/tipos-de-simbolos/comum.js +23 -23
- package/fontes/tipos-de-simbolos/delegua.d.ts +80 -80
- package/fontes/tipos-de-simbolos/delegua.js +81 -81
- package/fontes/tipos-de-simbolos/egua-classico.d.ts +77 -77
- package/fontes/tipos-de-simbolos/egua-classico.js +78 -78
- package/fontes/tipos-de-simbolos/eguap.d.ts +73 -73
- package/fontes/tipos-de-simbolos/eguap.js +74 -74
- package/fontes/tipos-de-simbolos/guarani.d.ts +14 -14
- package/fontes/tipos-de-simbolos/guarani.js +15 -15
- package/fontes/tipos-de-simbolos/portugol-ipt.d.ts +28 -28
- package/fontes/tipos-de-simbolos/portugol-ipt.js +29 -29
- package/fontes/tipos-de-simbolos/portugol-studio.d.ts +53 -35
- package/fontes/tipos-de-simbolos/portugol-studio.js +54 -36
- package/fontes/tipos-de-simbolos/portugol-studio.js.map +1 -1
- package/fontes/tipos-de-simbolos/rantiaquin.d.ts +2 -2
- package/fontes/tipos-de-simbolos/rantiaquin.js +3 -3
- package/fontes/tipos-de-simbolos/visualg.d.ts +68 -68
- package/fontes/tipos-de-simbolos/visualg.js +69 -69
- package/fontes/tradutores/dicionarios/dicionario-delegua-javascript.d.ts +2 -2
- package/fontes/tradutores/dicionarios/dicionario-delegua-javascript.js +10 -10
- package/fontes/tradutores/dicionarios/index.d.ts +1 -1
- package/fontes/tradutores/dicionarios/index.js +17 -17
- package/fontes/tradutores/index.d.ts +2 -2
- package/fontes/tradutores/index.js +18 -18
- package/fontes/tradutores/python/python3-lexer.d.ts +152 -152
- package/fontes/tradutores/python/python3-lexer.js +1226 -1226
- package/fontes/tradutores/python/python3-listener.d.ts +953 -953
- package/fontes/tradutores/python/python3-listener.js +2 -2
- package/fontes/tradutores/python/python3-parser.d.ts +1330 -1330
- package/fontes/tradutores/python/python3-parser.js +11156 -11156
- package/fontes/tradutores/python/python3-visitor.d.ts +612 -612
- package/fontes/tradutores/python/python3-visitor.js +2 -2
- package/fontes/tradutores/tradutor-javascript.d.ts +83 -83
- package/fontes/tradutores/tradutor-javascript.js +470 -470
- package/fontes/tradutores/tradutor-javascript.js.map +1 -1
- package/fontes/tradutores/tradutor-python.d.ts +1 -1
- package/fontes/tradutores/tradutor-python.js +34 -34
- package/fontes/tradutores/tradutor-reverso-javascript.d.ts +47 -47
- package/fontes/tradutores/tradutor-reverso-javascript.js +342 -342
- package/index.d.ts +5 -5
- package/index.js +23 -23
- package/package.json +88 -88
|
@@ -1,479 +1,479 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable prefer-rest-params */
|
|
4
|
-
const excecoes_1 = require("../../../excecoes");
|
|
5
|
-
module.exports.graus = function (angle) {
|
|
6
|
-
if (isNaN(angle) || angle === null)
|
|
7
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover um número para mat.graus(ângulo).');
|
|
8
|
-
return angle * (180 / Math.PI);
|
|
9
|
-
};
|
|
10
|
-
module.exports.mediana = function (a) {
|
|
11
|
-
if (isNaN(a) || a === null)
|
|
12
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para mediana(a).');
|
|
13
|
-
a.sort(function (a, b) {
|
|
14
|
-
return a - b;
|
|
15
|
-
});
|
|
16
|
-
const mid = a.length / 2;
|
|
17
|
-
return mid % 1 ? a[mid - 0.5] : (a[mid - 1] + a[mid]) / 2;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Calcula a moda de um vetor.
|
|
21
|
-
* @param {inteiro[]} vetor Vetor de inteiros.
|
|
22
|
-
* @returns Valor inteiro da moda.
|
|
23
|
-
*/
|
|
24
|
-
module.exports.moda = function (numbers) {
|
|
25
|
-
if (!Array.isArray(numbers))
|
|
26
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Parâmetro `vetor` deve ser um vetor na função moda(vetor).');
|
|
27
|
-
if (numbers.some(isNaN))
|
|
28
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Todos os elementos de `vetor` deve ser numéricos na função moda(vetor).');
|
|
29
|
-
let modes = [], count = [], i, number, maxIndex = 0;
|
|
30
|
-
for (i = 0; i < numbers.length; i += 1) {
|
|
31
|
-
number = numbers[i];
|
|
32
|
-
count[number] = (count[number] || 0) + 1;
|
|
33
|
-
if (count[number] > maxIndex) {
|
|
34
|
-
maxIndex = count[number];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
for (i in count)
|
|
38
|
-
if (count.hasOwnProperty(i)) {
|
|
39
|
-
if (count[i] === maxIndex) {
|
|
40
|
-
modes.push(Number(i));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return modes;
|
|
44
|
-
};
|
|
45
|
-
module.exports.pi = Math.PI;
|
|
46
|
-
module.exports.radiano = function (angulo) {
|
|
47
|
-
if (!Number.isInteger(angulo))
|
|
48
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover um número inteiro para o parâmetro `angulo`, em radiano(angulo).');
|
|
49
|
-
return angulo * (Math.PI / 180);
|
|
50
|
-
};
|
|
51
|
-
//FUNÇÃO AFIM E QUADRÁTICA
|
|
52
|
-
/**
|
|
53
|
-
* Gera valores para abscissa.
|
|
54
|
-
* @param {inteiro} distancia A distância entra dois pontos.
|
|
55
|
-
* @param {inteiro} valorPontoCentral O ponto central na abscissa.
|
|
56
|
-
* @param {inteiro} numeroPontos Número de pontos a serem gerados (padrão: 7).
|
|
57
|
-
* @returns Um vetor, contendo o número de pontos informado ou definido por padrão em uma abscissa.
|
|
58
|
-
* Se o número informado é par, um ponto negativo a mais é gerado.
|
|
59
|
-
*/
|
|
60
|
-
module.exports.gerarPontosAbscissa = function (distancia, valorPontoCentral, numeroPontos) {
|
|
61
|
-
if (!Number.isInteger(distancia))
|
|
62
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover um valor inteiro para o parâmetro `distancia`, em gerarPontosAbscissa(distancia, valorInicial).');
|
|
63
|
-
if (!Number.isInteger(valorPontoCentral))
|
|
64
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover um valor inteiro para o parâmetro `valorInicial`, em gerarPontosAbscissa(distancia, valorInicial).');
|
|
65
|
-
if (!numeroPontos) {
|
|
66
|
-
numeroPontos = 7;
|
|
67
|
-
}
|
|
68
|
-
const elementoInicial = valorPontoCentral - ((numeroPontos / 2) >> 0) * distancia;
|
|
69
|
-
const x = [];
|
|
70
|
-
for (let i = 0; i < numeroPontos; i++) {
|
|
71
|
-
x.push(elementoInicial + i * distancia);
|
|
72
|
-
}
|
|
73
|
-
return x;
|
|
74
|
-
};
|
|
75
|
-
//Raíz da Função Afim
|
|
76
|
-
module.exports.fun1R = function (a, b) {
|
|
77
|
-
if (isNaN(a) || a === null || isNaN(b) || b === null)
|
|
78
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para fun1R(valor1,valor2).');
|
|
79
|
-
return (-1 * b) / a;
|
|
80
|
-
};
|
|
81
|
-
//Intervalo Preenchido
|
|
82
|
-
module.exports.linspace = function (startValue, stopValue, cardinality) {
|
|
83
|
-
if (isNaN(startValue) ||
|
|
84
|
-
startValue === null ||
|
|
85
|
-
isNaN(stopValue) ||
|
|
86
|
-
stopValue === null ||
|
|
87
|
-
isNaN(cardinality) ||
|
|
88
|
-
cardinality === null)
|
|
89
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para linspace(valor1,valor2,valor3).');
|
|
90
|
-
const lista = [];
|
|
91
|
-
const step = (stopValue - startValue) / (cardinality - 1);
|
|
92
|
-
for (let i = 0; i < cardinality; i++) {
|
|
93
|
-
lista.push(startValue + step * i);
|
|
94
|
-
}
|
|
95
|
-
return lista;
|
|
96
|
-
};
|
|
97
|
-
//Raízes da Função Quadrática
|
|
98
|
-
module.exports.fun2R = function (a, b, c) {
|
|
99
|
-
if (isNaN(a) || a === null)
|
|
100
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para fun2R(a,b,c).');
|
|
101
|
-
const r1 = (-1 * b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
|
|
102
|
-
const r2 = (-1 * b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
|
|
103
|
-
const xv = (-1 * b) / (2 * a);
|
|
104
|
-
const yv = ((-1 * (Math.pow(b, 2) - 4 * a * c)) / 4) * a;
|
|
105
|
-
return [xv, yv];
|
|
106
|
-
};
|
|
107
|
-
//Aproximação de valores
|
|
108
|
-
const aprox = function (x, z) {
|
|
109
|
-
if (isNaN(x) || x === null || isNaN(z) || z === null)
|
|
110
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para aprox(x,z).');
|
|
111
|
-
if (z == undefined) {
|
|
112
|
-
z = 2;
|
|
113
|
-
}
|
|
114
|
-
if (typeof x == 'number') {
|
|
115
|
-
x = x.toFixed(z);
|
|
116
|
-
}
|
|
117
|
-
else if (x[0].length == undefined) {
|
|
118
|
-
// 1D array
|
|
119
|
-
for (let i = 0; i < x.length; i++) {
|
|
120
|
-
x[i] = parseFloat(x[i].toFixed(z));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else
|
|
124
|
-
for (let i = 0; i < x.length; i++) {
|
|
125
|
-
// 2D array
|
|
126
|
-
for (let j = 0; j < x[0].length; j++) {
|
|
127
|
-
x[i][j] = parseFloat(x[i][j].toFixed(z));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return x;
|
|
131
|
-
};
|
|
132
|
-
module.exports.aprox = aprox;
|
|
133
|
-
//Parâmetros da Função
|
|
134
|
-
const matrizn = function (z) {
|
|
135
|
-
if (isNaN(z) || z === null)
|
|
136
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para matrizn(z).');
|
|
137
|
-
const n = arguments.length;
|
|
138
|
-
const data = Array.from(Array(1), () => new Array(n));
|
|
139
|
-
for (let i = 0; i < n; i++) {
|
|
140
|
-
data[0][i] = arguments[i];
|
|
141
|
-
}
|
|
142
|
-
return data;
|
|
143
|
-
};
|
|
144
|
-
module.exports.matrizn = matrizn;
|
|
145
|
-
//Vetor de pontos aleatórios
|
|
146
|
-
module.exports.pontosAleatorios = function (n) {
|
|
147
|
-
if (isNaN(n) || n === null)
|
|
148
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para pale(n).');
|
|
149
|
-
let ex;
|
|
150
|
-
if (ex == undefined) {
|
|
151
|
-
ex = 0;
|
|
152
|
-
}
|
|
153
|
-
const x = [];
|
|
154
|
-
x[0] = 100;
|
|
155
|
-
for (let i = 1; i < n; i++) {
|
|
156
|
-
x[i] = ex + x[i - 1] + Math.random() * 2 - 1;
|
|
157
|
-
}
|
|
158
|
-
const xx = aprox(x, 2);
|
|
159
|
-
return xx;
|
|
160
|
-
};
|
|
161
|
-
//Intervalo A-B
|
|
162
|
-
module.exports.vet = function (a, b) {
|
|
163
|
-
if (isNaN(a) || a === null || isNaN(b) || b === null)
|
|
164
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para vet(a,b).');
|
|
165
|
-
const data = Array.from(Array(1), () => new Array(b - a + 1));
|
|
166
|
-
for (let i = 0; i < data[0].length; i++) {
|
|
167
|
-
data[0][i] = a + i;
|
|
168
|
-
}
|
|
169
|
-
return matrizn(data);
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Conta quantas vezes um determinado valor aparece em um vetor.
|
|
173
|
-
* @param {qualquer[]} vetor Vetor de elementos
|
|
174
|
-
* @param {qualquer} valor Valor a ser encontrado no vetor
|
|
175
|
-
* @returns Valor inteiro, com o número de vezes que `valor` foi encontrado em `vetor`.
|
|
176
|
-
*/
|
|
177
|
-
module.exports.numeroOcorrencias = function (vetor, valor) {
|
|
178
|
-
if (!Array.isArray(vetor))
|
|
179
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Parâmetro `vetor` deve ser um vetor, em numeroOcorrencias(vetor, valor).');
|
|
180
|
-
return vetor.filter((v) => v === valor).length;
|
|
181
|
-
};
|
|
182
|
-
/* ESTATÍSTICA */
|
|
183
|
-
/**
|
|
184
|
-
* Encontra o elemento máximo em um vetor.
|
|
185
|
-
* @param {inteiro[]} vetor Um vetor de números inteiros.
|
|
186
|
-
* @returns O maior número encontrado em um vetor.
|
|
187
|
-
*/
|
|
188
|
-
module.exports.max = function (vetor) {
|
|
189
|
-
if (!Array.isArray(vetor))
|
|
190
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Parâmetro `vetor` deve ser um vetor, em max(vetor).');
|
|
191
|
-
if (vetor.some(isNaN))
|
|
192
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Todos os elementos de `vetor` deve ser numéricos, em max(vetor).');
|
|
193
|
-
return Math.max.apply(null, vetor);
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* Encontra o elemento mínimo em um vetor.
|
|
197
|
-
* @param {inteiro[]} vetor Um vetor de números inteiros.
|
|
198
|
-
* @returns O menor número encontrado em um vetor.
|
|
199
|
-
*/
|
|
200
|
-
module.exports.min = function (vetor) {
|
|
201
|
-
if (!Array.isArray(vetor))
|
|
202
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Parâmetro `vetor` deve ser um vetor, em min(vetor).');
|
|
203
|
-
if (vetor.some(isNaN))
|
|
204
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Todos os elementos de `vetor` deve ser numéricos, em min(vetor).');
|
|
205
|
-
return Math.min.apply(null, vetor);
|
|
206
|
-
};
|
|
207
|
-
//Soma de determinada matriz
|
|
208
|
-
const smtr = function (a) {
|
|
209
|
-
if (isNaN(a) || a === null)
|
|
210
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para smtr(a).');
|
|
211
|
-
let z = 0;
|
|
212
|
-
if (a.length == 1) {
|
|
213
|
-
// a is a 1D row array
|
|
214
|
-
for (let j = 0; j < a[0].length; j++) {
|
|
215
|
-
z = z + a[0][j];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (a[0].length == 1) {
|
|
219
|
-
// a is a 1D column array
|
|
220
|
-
for (let i = 0; i < a.length; i++) {
|
|
221
|
-
z = z + a[i][0];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
for (let j = 0; j < a.length; j++) {
|
|
226
|
-
z = z + a[j];
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return aprox(z, 2);
|
|
230
|
-
};
|
|
231
|
-
module.exports.smtr = smtr;
|
|
232
|
-
// Retorna a média de um vetor de números
|
|
233
|
-
module.exports.media = function () {
|
|
234
|
-
const argumentsLength = Object.keys(arguments).length;
|
|
235
|
-
if (argumentsLength <= 0) {
|
|
236
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve fornecer um parâmetro para a função.');
|
|
237
|
-
}
|
|
238
|
-
if (argumentsLength > 1) {
|
|
239
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'A função recebe apenas um parâmetro.');
|
|
240
|
-
}
|
|
241
|
-
// Pega o primeiro argumento do objeto de argumentos
|
|
242
|
-
const args = arguments['0'];
|
|
243
|
-
if (!Array.isArray(args)) {
|
|
244
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve fornecer um parâmetro do tipo vetor.');
|
|
245
|
-
}
|
|
246
|
-
// Valida se o array está vazio.
|
|
247
|
-
if (!args.length) {
|
|
248
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Vetor vazio. Você deve fornecer ao menos um valor ao vetor.');
|
|
249
|
-
}
|
|
250
|
-
// Valida se o array contém apenas valores do tipo número.
|
|
251
|
-
args.forEach((item) => {
|
|
252
|
-
if (typeof item !== 'number') {
|
|
253
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve fornecer um vetor contendo apenas valores do tipo número.');
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
// Soma todos os itens.
|
|
257
|
-
const valoresSomados = args.reduce((acumulador, itemAtual) => acumulador + itemAtual, 0);
|
|
258
|
-
// Faz o cáculo da média em si e retorna.
|
|
259
|
-
return valoresSomados / args.length;
|
|
260
|
-
};
|
|
261
|
-
//Média aritmética de uma matriz
|
|
262
|
-
const ve = function (a) {
|
|
263
|
-
if (isNaN(a) || a === null)
|
|
264
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para ve(a).');
|
|
265
|
-
if (a.length == 1) {
|
|
266
|
-
return aprox(smtr(a) / a[0].length, 4);
|
|
267
|
-
} // a is a row array
|
|
268
|
-
if (a[0].length == 1) {
|
|
269
|
-
return aprox(smtr(a) / a.length, 4);
|
|
270
|
-
} // a is a column array
|
|
271
|
-
if (a[0].length == undefined) {
|
|
272
|
-
return aprox(smtr(a) / a.length, 4);
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
module.exports.ve = ve;
|
|
276
|
-
//Soma dos quadrados dos resíduos (sqr) de uma matriz
|
|
277
|
-
const sqr = function (a) {
|
|
278
|
-
if (isNaN(a) || a === null)
|
|
279
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para sqr(a).');
|
|
280
|
-
const mean = ve(a);
|
|
281
|
-
let sum = 0;
|
|
282
|
-
let i = a.length;
|
|
283
|
-
let tmp;
|
|
284
|
-
while (--i >= 0) {
|
|
285
|
-
tmp = a[i] - mean;
|
|
286
|
-
sum += tmp * tmp;
|
|
287
|
-
}
|
|
288
|
-
return sum;
|
|
289
|
-
};
|
|
290
|
-
module.exports.sqr = sqr;
|
|
291
|
-
//Variação de uma matriz
|
|
292
|
-
module.exports.variancia = function (array, flag) {
|
|
293
|
-
if (isNaN(array) || array === null || isNaN(flag) || flag === null)
|
|
294
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para variancia(matriz, flag).');
|
|
295
|
-
if (flag == undefined) {
|
|
296
|
-
flag = 1;
|
|
297
|
-
}
|
|
298
|
-
return sqr(array) / (array.length - (flag ? 1 : 0));
|
|
299
|
-
};
|
|
300
|
-
//Covariância de duas matrizes
|
|
301
|
-
module.exports.colet = function (array1, array2) {
|
|
302
|
-
if (isNaN(array1) || array1 === null || isNaN(array1) || array2 === null)
|
|
303
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para covar(matriz1, matriz2).');
|
|
304
|
-
let u = ve(array1);
|
|
305
|
-
let v = ve(array2);
|
|
306
|
-
let arr1Len = array1.length;
|
|
307
|
-
let sq_dev = new Array(arr1Len);
|
|
308
|
-
for (let i = 0; i < arr1Len; i++)
|
|
309
|
-
sq_dev[i] = (array1[i] - u) * (array2[i] - v);
|
|
310
|
-
return smtr(sq_dev) / (arr1Len - 1);
|
|
311
|
-
};
|
|
312
|
-
/*TRIGONOMETRIA*/
|
|
313
|
-
//Seno de um número
|
|
314
|
-
module.exports.sen = function (x) {
|
|
315
|
-
if (isNaN(x) || x === null)
|
|
316
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para sen(x).');
|
|
317
|
-
return Math.sin(x);
|
|
318
|
-
};
|
|
319
|
-
//Cosseno de um número
|
|
320
|
-
module.exports.cos = function (x) {
|
|
321
|
-
if (isNaN(x) || x === null)
|
|
322
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para cos(x).');
|
|
323
|
-
return Math.cos(x);
|
|
324
|
-
};
|
|
325
|
-
//Tangente de um número
|
|
326
|
-
module.exports.tan = function (x) {
|
|
327
|
-
if (isNaN(x) || x === null)
|
|
328
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para tan(x).');
|
|
329
|
-
return Math.tan(x);
|
|
330
|
-
};
|
|
331
|
-
//Arco cosseno de um número
|
|
332
|
-
module.exports.arcos = function (x) {
|
|
333
|
-
if (isNaN(x) || x === null)
|
|
334
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para arcos(x).');
|
|
335
|
-
return Math.acos(x);
|
|
336
|
-
};
|
|
337
|
-
//Arco seno de um número
|
|
338
|
-
module.exports.arsen = function (x) {
|
|
339
|
-
if (isNaN(x) || x === null)
|
|
340
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para arsen(x).');
|
|
341
|
-
return Math.asin(x);
|
|
342
|
-
};
|
|
343
|
-
//Arco tangente de um número
|
|
344
|
-
module.exports.artan = function (x) {
|
|
345
|
-
if (isNaN(x) || x === null)
|
|
346
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para artan(x).');
|
|
347
|
-
return Math.atan(x);
|
|
348
|
-
};
|
|
349
|
-
//Exponencial
|
|
350
|
-
module.exports.exp = function (x) {
|
|
351
|
-
if (isNaN(x) || x === null)
|
|
352
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para exp(x).');
|
|
353
|
-
return Math.exp(x);
|
|
354
|
-
};
|
|
355
|
-
//Logaritmo natural
|
|
356
|
-
module.exports.log = function (x) {
|
|
357
|
-
if (isNaN(x) || x === null)
|
|
358
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para log(x).');
|
|
359
|
-
return Math.log(x);
|
|
360
|
-
};
|
|
361
|
-
// Retorna a base elevada ao expoente
|
|
362
|
-
const pot = function (base, expoente) {
|
|
363
|
-
if (typeof base !== 'number' || typeof expoente !== 'number') {
|
|
364
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Os parâmetros devem ser do tipo número.');
|
|
365
|
-
}
|
|
366
|
-
return Math.pow(base, expoente);
|
|
367
|
-
};
|
|
368
|
-
module.exports.potencia = pot;
|
|
369
|
-
//Raíz quadrada
|
|
370
|
-
module.exports.raizq = function (x) {
|
|
371
|
-
if (isNaN(x) || x === null)
|
|
372
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para raizq(x).');
|
|
373
|
-
return Math.sqrt(x);
|
|
374
|
-
};
|
|
375
|
-
/*CINEMÁTICA*/
|
|
376
|
-
//Velocidade média
|
|
377
|
-
module.exports.velocidadeMedia = function (s, t) {
|
|
378
|
-
if (isNaN(s) || s === null || isNaN(t) || t === null)
|
|
379
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para velocidadeMedia(d,t).');
|
|
380
|
-
return s / t;
|
|
381
|
-
};
|
|
382
|
-
//Espaço percorrido
|
|
383
|
-
module.exports.deltaS = function (s0, s) {
|
|
384
|
-
if (isNaN(s0) || s0 === null || isNaN(s) || s === null)
|
|
385
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para deltas(e0,e1).');
|
|
386
|
-
let ds = s - s0;
|
|
387
|
-
return ds;
|
|
388
|
-
};
|
|
389
|
-
//Tempo Percorrido
|
|
390
|
-
module.exports.deltaT = function (t0, t) {
|
|
391
|
-
if (isNaN(t0) || t0 === null || isNaN(t) || t === null)
|
|
392
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para deltat(t0,t1).');
|
|
393
|
-
let dt = t - t0;
|
|
394
|
-
return dt;
|
|
395
|
-
};
|
|
396
|
-
// Cálculo de aceleração
|
|
397
|
-
module.exports.aceleracao = function (velocidadeFinal, velocidadeInicial, tempoFinal, tempoInicial) {
|
|
398
|
-
if (velocidadeFinal === null || velocidadeInicial === null || tempoFinal === null || tempoInicial === null) {
|
|
399
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Devem ser fornecidos quatro parâmetros obrigatórios.');
|
|
400
|
-
}
|
|
401
|
-
if (typeof velocidadeFinal !== 'number' ||
|
|
402
|
-
typeof velocidadeInicial !== 'number' ||
|
|
403
|
-
typeof tempoFinal !== 'number' ||
|
|
404
|
-
typeof tempoInicial !== 'number') {
|
|
405
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Todos os parâmetros devem ser do tipo número.');
|
|
406
|
-
}
|
|
407
|
-
return (velocidadeFinal - velocidadeInicial) / (tempoFinal - tempoInicial);
|
|
408
|
-
};
|
|
409
|
-
//Função Horária da Posição (M.R.U)
|
|
410
|
-
module.exports.mrufh = function (s0, v, t) {
|
|
411
|
-
if (isNaN(s0) || s0 === null)
|
|
412
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para mrufh(s0,v,t).');
|
|
413
|
-
t = t + 1;
|
|
414
|
-
const s = [];
|
|
415
|
-
let index = 0;
|
|
416
|
-
for (let i = 0; i < t; i++) {
|
|
417
|
-
s[index] = s0 + v * i;
|
|
418
|
-
index++;
|
|
419
|
-
}
|
|
420
|
-
return ['Função: ' + s0 + '+(' + v + ')*t' + '<br>' + 'Posições: ' + s];
|
|
421
|
-
};
|
|
422
|
-
//Gráfico da velocidade (M.R.U.V)
|
|
423
|
-
module.exports.mruv = function (s0, s, a) {
|
|
424
|
-
if (isNaN(s0) || s0 === null || isNaN(s) || s === null || isNaN(a) || a === null)
|
|
425
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para mruv(Pi, Vf, A).');
|
|
426
|
-
const vf = [];
|
|
427
|
-
const x = [];
|
|
428
|
-
let v = [];
|
|
429
|
-
let index = 0;
|
|
430
|
-
for (let i = 0; i < s; i++) {
|
|
431
|
-
v = index;
|
|
432
|
-
vf[index] = Math.sqrt(2 * a * (index - s0));
|
|
433
|
-
x[index] = i;
|
|
434
|
-
index++;
|
|
435
|
-
}
|
|
436
|
-
return vf;
|
|
437
|
-
};
|
|
438
|
-
/*Controle e Servomecanismos*/
|
|
439
|
-
module.exports.pid = function (Mo, t, K, T1, T2) {
|
|
440
|
-
if (isNaN(Mo) ||
|
|
441
|
-
Mo === null ||
|
|
442
|
-
isNaN(t) ||
|
|
443
|
-
t === null ||
|
|
444
|
-
isNaN(K) ||
|
|
445
|
-
K === null ||
|
|
446
|
-
isNaN(T1) ||
|
|
447
|
-
T1 === null ||
|
|
448
|
-
isNaN(T2) ||
|
|
449
|
-
T2 === null) {
|
|
450
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para pid(Ov, Ts, K, T1, T2).');
|
|
451
|
-
}
|
|
452
|
-
let pi = Math.PI; //Pi da bilbioteca Math.js
|
|
453
|
-
//Amortecimento Relativo
|
|
454
|
-
let csi = (-1 * Math.log(Mo / 100)) / Math.sqrt(Math.pow(pi, 2) + pot(Math.log(Mo / 100), 2));
|
|
455
|
-
//Frequência Natural
|
|
456
|
-
let Wn = 4 / (t * csi);
|
|
457
|
-
//Controlador Proporcional (P)
|
|
458
|
-
let Kp = 20 * (Math.pow(csi, 2) * Math.pow(Wn, 2) * T1 * T2) + (Math.pow(Wn, 2) * T1 * T2 - 1) / K;
|
|
459
|
-
//Controlador Integral (I)
|
|
460
|
-
let Ki = (10 * csi * Math.pow(Wn, 3) * T1 * T2) / K;
|
|
461
|
-
//Controlador Derivativo (D)
|
|
462
|
-
let Kd = (12 * csi * Wn * T1 * T2 - T1 - T2) / K;
|
|
463
|
-
return [csi, Wn, Kp, Ki, Kd];
|
|
464
|
-
};
|
|
465
|
-
// Retorna o comprimento de um vetor
|
|
466
|
-
module.exports.comp = function (array) {
|
|
467
|
-
if (!Array.isArray(array)) {
|
|
468
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'O valor passado pra função deve ser um vetor.');
|
|
469
|
-
}
|
|
470
|
-
return array.length;
|
|
471
|
-
};
|
|
472
|
-
// Retorna o menor número inteiro dentre o valor de "value"
|
|
473
|
-
module.exports.minaprox = function (value) {
|
|
474
|
-
if (typeof value !== 'number') {
|
|
475
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'O valor passado pra função deve ser um número.');
|
|
476
|
-
}
|
|
477
|
-
return Math.floor(value);
|
|
478
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable prefer-rest-params */
|
|
4
|
+
const excecoes_1 = require("../../../excecoes");
|
|
5
|
+
module.exports.graus = function (angle) {
|
|
6
|
+
if (isNaN(angle) || angle === null)
|
|
7
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover um número para mat.graus(ângulo).');
|
|
8
|
+
return angle * (180 / Math.PI);
|
|
9
|
+
};
|
|
10
|
+
module.exports.mediana = function (a) {
|
|
11
|
+
if (isNaN(a) || a === null)
|
|
12
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para mediana(a).');
|
|
13
|
+
a.sort(function (a, b) {
|
|
14
|
+
return a - b;
|
|
15
|
+
});
|
|
16
|
+
const mid = a.length / 2;
|
|
17
|
+
return mid % 1 ? a[mid - 0.5] : (a[mid - 1] + a[mid]) / 2;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Calcula a moda de um vetor.
|
|
21
|
+
* @param {inteiro[]} vetor Vetor de inteiros.
|
|
22
|
+
* @returns Valor inteiro da moda.
|
|
23
|
+
*/
|
|
24
|
+
module.exports.moda = function (numbers) {
|
|
25
|
+
if (!Array.isArray(numbers))
|
|
26
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Parâmetro `vetor` deve ser um vetor na função moda(vetor).');
|
|
27
|
+
if (numbers.some(isNaN))
|
|
28
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Todos os elementos de `vetor` deve ser numéricos na função moda(vetor).');
|
|
29
|
+
let modes = [], count = [], i, number, maxIndex = 0;
|
|
30
|
+
for (i = 0; i < numbers.length; i += 1) {
|
|
31
|
+
number = numbers[i];
|
|
32
|
+
count[number] = (count[number] || 0) + 1;
|
|
33
|
+
if (count[number] > maxIndex) {
|
|
34
|
+
maxIndex = count[number];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (i in count)
|
|
38
|
+
if (count.hasOwnProperty(i)) {
|
|
39
|
+
if (count[i] === maxIndex) {
|
|
40
|
+
modes.push(Number(i));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return modes;
|
|
44
|
+
};
|
|
45
|
+
module.exports.pi = Math.PI;
|
|
46
|
+
module.exports.radiano = function (angulo) {
|
|
47
|
+
if (!Number.isInteger(angulo))
|
|
48
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover um número inteiro para o parâmetro `angulo`, em radiano(angulo).');
|
|
49
|
+
return angulo * (Math.PI / 180);
|
|
50
|
+
};
|
|
51
|
+
//FUNÇÃO AFIM E QUADRÁTICA
|
|
52
|
+
/**
|
|
53
|
+
* Gera valores para abscissa.
|
|
54
|
+
* @param {inteiro} distancia A distância entra dois pontos.
|
|
55
|
+
* @param {inteiro} valorPontoCentral O ponto central na abscissa.
|
|
56
|
+
* @param {inteiro} numeroPontos Número de pontos a serem gerados (padrão: 7).
|
|
57
|
+
* @returns Um vetor, contendo o número de pontos informado ou definido por padrão em uma abscissa.
|
|
58
|
+
* Se o número informado é par, um ponto negativo a mais é gerado.
|
|
59
|
+
*/
|
|
60
|
+
module.exports.gerarPontosAbscissa = function (distancia, valorPontoCentral, numeroPontos) {
|
|
61
|
+
if (!Number.isInteger(distancia))
|
|
62
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover um valor inteiro para o parâmetro `distancia`, em gerarPontosAbscissa(distancia, valorInicial).');
|
|
63
|
+
if (!Number.isInteger(valorPontoCentral))
|
|
64
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover um valor inteiro para o parâmetro `valorInicial`, em gerarPontosAbscissa(distancia, valorInicial).');
|
|
65
|
+
if (!numeroPontos) {
|
|
66
|
+
numeroPontos = 7;
|
|
67
|
+
}
|
|
68
|
+
const elementoInicial = valorPontoCentral - ((numeroPontos / 2) >> 0) * distancia;
|
|
69
|
+
const x = [];
|
|
70
|
+
for (let i = 0; i < numeroPontos; i++) {
|
|
71
|
+
x.push(elementoInicial + i * distancia);
|
|
72
|
+
}
|
|
73
|
+
return x;
|
|
74
|
+
};
|
|
75
|
+
//Raíz da Função Afim
|
|
76
|
+
module.exports.fun1R = function (a, b) {
|
|
77
|
+
if (isNaN(a) || a === null || isNaN(b) || b === null)
|
|
78
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para fun1R(valor1,valor2).');
|
|
79
|
+
return (-1 * b) / a;
|
|
80
|
+
};
|
|
81
|
+
//Intervalo Preenchido
|
|
82
|
+
module.exports.linspace = function (startValue, stopValue, cardinality) {
|
|
83
|
+
if (isNaN(startValue) ||
|
|
84
|
+
startValue === null ||
|
|
85
|
+
isNaN(stopValue) ||
|
|
86
|
+
stopValue === null ||
|
|
87
|
+
isNaN(cardinality) ||
|
|
88
|
+
cardinality === null)
|
|
89
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para linspace(valor1,valor2,valor3).');
|
|
90
|
+
const lista = [];
|
|
91
|
+
const step = (stopValue - startValue) / (cardinality - 1);
|
|
92
|
+
for (let i = 0; i < cardinality; i++) {
|
|
93
|
+
lista.push(startValue + step * i);
|
|
94
|
+
}
|
|
95
|
+
return lista;
|
|
96
|
+
};
|
|
97
|
+
//Raízes da Função Quadrática
|
|
98
|
+
module.exports.fun2R = function (a, b, c) {
|
|
99
|
+
if (isNaN(a) || a === null)
|
|
100
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para fun2R(a,b,c).');
|
|
101
|
+
const r1 = (-1 * b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
|
|
102
|
+
const r2 = (-1 * b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
|
|
103
|
+
const xv = (-1 * b) / (2 * a);
|
|
104
|
+
const yv = ((-1 * (Math.pow(b, 2) - 4 * a * c)) / 4) * a;
|
|
105
|
+
return [xv, yv];
|
|
106
|
+
};
|
|
107
|
+
//Aproximação de valores
|
|
108
|
+
const aprox = function (x, z) {
|
|
109
|
+
if (isNaN(x) || x === null || isNaN(z) || z === null)
|
|
110
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para aprox(x,z).');
|
|
111
|
+
if (z == undefined) {
|
|
112
|
+
z = 2;
|
|
113
|
+
}
|
|
114
|
+
if (typeof x == 'number') {
|
|
115
|
+
x = x.toFixed(z);
|
|
116
|
+
}
|
|
117
|
+
else if (x[0].length == undefined) {
|
|
118
|
+
// 1D array
|
|
119
|
+
for (let i = 0; i < x.length; i++) {
|
|
120
|
+
x[i] = parseFloat(x[i].toFixed(z));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else
|
|
124
|
+
for (let i = 0; i < x.length; i++) {
|
|
125
|
+
// 2D array
|
|
126
|
+
for (let j = 0; j < x[0].length; j++) {
|
|
127
|
+
x[i][j] = parseFloat(x[i][j].toFixed(z));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return x;
|
|
131
|
+
};
|
|
132
|
+
module.exports.aprox = aprox;
|
|
133
|
+
//Parâmetros da Função
|
|
134
|
+
const matrizn = function (z) {
|
|
135
|
+
if (isNaN(z) || z === null)
|
|
136
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para matrizn(z).');
|
|
137
|
+
const n = arguments.length;
|
|
138
|
+
const data = Array.from(Array(1), () => new Array(n));
|
|
139
|
+
for (let i = 0; i < n; i++) {
|
|
140
|
+
data[0][i] = arguments[i];
|
|
141
|
+
}
|
|
142
|
+
return data;
|
|
143
|
+
};
|
|
144
|
+
module.exports.matrizn = matrizn;
|
|
145
|
+
//Vetor de pontos aleatórios
|
|
146
|
+
module.exports.pontosAleatorios = function (n) {
|
|
147
|
+
if (isNaN(n) || n === null)
|
|
148
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para pale(n).');
|
|
149
|
+
let ex;
|
|
150
|
+
if (ex == undefined) {
|
|
151
|
+
ex = 0;
|
|
152
|
+
}
|
|
153
|
+
const x = [];
|
|
154
|
+
x[0] = 100;
|
|
155
|
+
for (let i = 1; i < n; i++) {
|
|
156
|
+
x[i] = ex + x[i - 1] + Math.random() * 2 - 1;
|
|
157
|
+
}
|
|
158
|
+
const xx = aprox(x, 2);
|
|
159
|
+
return xx;
|
|
160
|
+
};
|
|
161
|
+
//Intervalo A-B
|
|
162
|
+
module.exports.vet = function (a, b) {
|
|
163
|
+
if (isNaN(a) || a === null || isNaN(b) || b === null)
|
|
164
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para vet(a,b).');
|
|
165
|
+
const data = Array.from(Array(1), () => new Array(b - a + 1));
|
|
166
|
+
for (let i = 0; i < data[0].length; i++) {
|
|
167
|
+
data[0][i] = a + i;
|
|
168
|
+
}
|
|
169
|
+
return matrizn(data);
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Conta quantas vezes um determinado valor aparece em um vetor.
|
|
173
|
+
* @param {qualquer[]} vetor Vetor de elementos
|
|
174
|
+
* @param {qualquer} valor Valor a ser encontrado no vetor
|
|
175
|
+
* @returns Valor inteiro, com o número de vezes que `valor` foi encontrado em `vetor`.
|
|
176
|
+
*/
|
|
177
|
+
module.exports.numeroOcorrencias = function (vetor, valor) {
|
|
178
|
+
if (!Array.isArray(vetor))
|
|
179
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Parâmetro `vetor` deve ser um vetor, em numeroOcorrencias(vetor, valor).');
|
|
180
|
+
return vetor.filter((v) => v === valor).length;
|
|
181
|
+
};
|
|
182
|
+
/* ESTATÍSTICA */
|
|
183
|
+
/**
|
|
184
|
+
* Encontra o elemento máximo em um vetor.
|
|
185
|
+
* @param {inteiro[]} vetor Um vetor de números inteiros.
|
|
186
|
+
* @returns O maior número encontrado em um vetor.
|
|
187
|
+
*/
|
|
188
|
+
module.exports.max = function (vetor) {
|
|
189
|
+
if (!Array.isArray(vetor))
|
|
190
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Parâmetro `vetor` deve ser um vetor, em max(vetor).');
|
|
191
|
+
if (vetor.some(isNaN))
|
|
192
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Todos os elementos de `vetor` deve ser numéricos, em max(vetor).');
|
|
193
|
+
return Math.max.apply(null, vetor);
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Encontra o elemento mínimo em um vetor.
|
|
197
|
+
* @param {inteiro[]} vetor Um vetor de números inteiros.
|
|
198
|
+
* @returns O menor número encontrado em um vetor.
|
|
199
|
+
*/
|
|
200
|
+
module.exports.min = function (vetor) {
|
|
201
|
+
if (!Array.isArray(vetor))
|
|
202
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Parâmetro `vetor` deve ser um vetor, em min(vetor).');
|
|
203
|
+
if (vetor.some(isNaN))
|
|
204
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Todos os elementos de `vetor` deve ser numéricos, em min(vetor).');
|
|
205
|
+
return Math.min.apply(null, vetor);
|
|
206
|
+
};
|
|
207
|
+
//Soma de determinada matriz
|
|
208
|
+
const smtr = function (a) {
|
|
209
|
+
if (isNaN(a) || a === null)
|
|
210
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para smtr(a).');
|
|
211
|
+
let z = 0;
|
|
212
|
+
if (a.length == 1) {
|
|
213
|
+
// a is a 1D row array
|
|
214
|
+
for (let j = 0; j < a[0].length; j++) {
|
|
215
|
+
z = z + a[0][j];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else if (a[0].length == 1) {
|
|
219
|
+
// a is a 1D column array
|
|
220
|
+
for (let i = 0; i < a.length; i++) {
|
|
221
|
+
z = z + a[i][0];
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
for (let j = 0; j < a.length; j++) {
|
|
226
|
+
z = z + a[j];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return aprox(z, 2);
|
|
230
|
+
};
|
|
231
|
+
module.exports.smtr = smtr;
|
|
232
|
+
// Retorna a média de um vetor de números
|
|
233
|
+
module.exports.media = function () {
|
|
234
|
+
const argumentsLength = Object.keys(arguments).length;
|
|
235
|
+
if (argumentsLength <= 0) {
|
|
236
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve fornecer um parâmetro para a função.');
|
|
237
|
+
}
|
|
238
|
+
if (argumentsLength > 1) {
|
|
239
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'A função recebe apenas um parâmetro.');
|
|
240
|
+
}
|
|
241
|
+
// Pega o primeiro argumento do objeto de argumentos
|
|
242
|
+
const args = arguments['0'];
|
|
243
|
+
if (!Array.isArray(args)) {
|
|
244
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve fornecer um parâmetro do tipo vetor.');
|
|
245
|
+
}
|
|
246
|
+
// Valida se o array está vazio.
|
|
247
|
+
if (!args.length) {
|
|
248
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Vetor vazio. Você deve fornecer ao menos um valor ao vetor.');
|
|
249
|
+
}
|
|
250
|
+
// Valida se o array contém apenas valores do tipo número.
|
|
251
|
+
args.forEach((item) => {
|
|
252
|
+
if (typeof item !== 'number') {
|
|
253
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve fornecer um vetor contendo apenas valores do tipo número.');
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
// Soma todos os itens.
|
|
257
|
+
const valoresSomados = args.reduce((acumulador, itemAtual) => acumulador + itemAtual, 0);
|
|
258
|
+
// Faz o cáculo da média em si e retorna.
|
|
259
|
+
return valoresSomados / args.length;
|
|
260
|
+
};
|
|
261
|
+
//Média aritmética de uma matriz
|
|
262
|
+
const ve = function (a) {
|
|
263
|
+
if (isNaN(a) || a === null)
|
|
264
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para ve(a).');
|
|
265
|
+
if (a.length == 1) {
|
|
266
|
+
return aprox(smtr(a) / a[0].length, 4);
|
|
267
|
+
} // a is a row array
|
|
268
|
+
if (a[0].length == 1) {
|
|
269
|
+
return aprox(smtr(a) / a.length, 4);
|
|
270
|
+
} // a is a column array
|
|
271
|
+
if (a[0].length == undefined) {
|
|
272
|
+
return aprox(smtr(a) / a.length, 4);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
module.exports.ve = ve;
|
|
276
|
+
//Soma dos quadrados dos resíduos (sqr) de uma matriz
|
|
277
|
+
const sqr = function (a) {
|
|
278
|
+
if (isNaN(a) || a === null)
|
|
279
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para sqr(a).');
|
|
280
|
+
const mean = ve(a);
|
|
281
|
+
let sum = 0;
|
|
282
|
+
let i = a.length;
|
|
283
|
+
let tmp;
|
|
284
|
+
while (--i >= 0) {
|
|
285
|
+
tmp = a[i] - mean;
|
|
286
|
+
sum += tmp * tmp;
|
|
287
|
+
}
|
|
288
|
+
return sum;
|
|
289
|
+
};
|
|
290
|
+
module.exports.sqr = sqr;
|
|
291
|
+
//Variação de uma matriz
|
|
292
|
+
module.exports.variancia = function (array, flag) {
|
|
293
|
+
if (isNaN(array) || array === null || isNaN(flag) || flag === null)
|
|
294
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para variancia(matriz, flag).');
|
|
295
|
+
if (flag == undefined) {
|
|
296
|
+
flag = 1;
|
|
297
|
+
}
|
|
298
|
+
return sqr(array) / (array.length - (flag ? 1 : 0));
|
|
299
|
+
};
|
|
300
|
+
//Covariância de duas matrizes
|
|
301
|
+
module.exports.colet = function (array1, array2) {
|
|
302
|
+
if (isNaN(array1) || array1 === null || isNaN(array1) || array2 === null)
|
|
303
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para covar(matriz1, matriz2).');
|
|
304
|
+
let u = ve(array1);
|
|
305
|
+
let v = ve(array2);
|
|
306
|
+
let arr1Len = array1.length;
|
|
307
|
+
let sq_dev = new Array(arr1Len);
|
|
308
|
+
for (let i = 0; i < arr1Len; i++)
|
|
309
|
+
sq_dev[i] = (array1[i] - u) * (array2[i] - v);
|
|
310
|
+
return smtr(sq_dev) / (arr1Len - 1);
|
|
311
|
+
};
|
|
312
|
+
/*TRIGONOMETRIA*/
|
|
313
|
+
//Seno de um número
|
|
314
|
+
module.exports.sen = function (x) {
|
|
315
|
+
if (isNaN(x) || x === null)
|
|
316
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para sen(x).');
|
|
317
|
+
return Math.sin(x);
|
|
318
|
+
};
|
|
319
|
+
//Cosseno de um número
|
|
320
|
+
module.exports.cos = function (x) {
|
|
321
|
+
if (isNaN(x) || x === null)
|
|
322
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para cos(x).');
|
|
323
|
+
return Math.cos(x);
|
|
324
|
+
};
|
|
325
|
+
//Tangente de um número
|
|
326
|
+
module.exports.tan = function (x) {
|
|
327
|
+
if (isNaN(x) || x === null)
|
|
328
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para tan(x).');
|
|
329
|
+
return Math.tan(x);
|
|
330
|
+
};
|
|
331
|
+
//Arco cosseno de um número
|
|
332
|
+
module.exports.arcos = function (x) {
|
|
333
|
+
if (isNaN(x) || x === null)
|
|
334
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para arcos(x).');
|
|
335
|
+
return Math.acos(x);
|
|
336
|
+
};
|
|
337
|
+
//Arco seno de um número
|
|
338
|
+
module.exports.arsen = function (x) {
|
|
339
|
+
if (isNaN(x) || x === null)
|
|
340
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para arsen(x).');
|
|
341
|
+
return Math.asin(x);
|
|
342
|
+
};
|
|
343
|
+
//Arco tangente de um número
|
|
344
|
+
module.exports.artan = function (x) {
|
|
345
|
+
if (isNaN(x) || x === null)
|
|
346
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para artan(x).');
|
|
347
|
+
return Math.atan(x);
|
|
348
|
+
};
|
|
349
|
+
//Exponencial
|
|
350
|
+
module.exports.exp = function (x) {
|
|
351
|
+
if (isNaN(x) || x === null)
|
|
352
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para exp(x).');
|
|
353
|
+
return Math.exp(x);
|
|
354
|
+
};
|
|
355
|
+
//Logaritmo natural
|
|
356
|
+
module.exports.log = function (x) {
|
|
357
|
+
if (isNaN(x) || x === null)
|
|
358
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para log(x).');
|
|
359
|
+
return Math.log(x);
|
|
360
|
+
};
|
|
361
|
+
// Retorna a base elevada ao expoente
|
|
362
|
+
const pot = function (base, expoente) {
|
|
363
|
+
if (typeof base !== 'number' || typeof expoente !== 'number') {
|
|
364
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Os parâmetros devem ser do tipo número.');
|
|
365
|
+
}
|
|
366
|
+
return Math.pow(base, expoente);
|
|
367
|
+
};
|
|
368
|
+
module.exports.potencia = pot;
|
|
369
|
+
//Raíz quadrada
|
|
370
|
+
module.exports.raizq = function (x) {
|
|
371
|
+
if (isNaN(x) || x === null)
|
|
372
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para raizq(x).');
|
|
373
|
+
return Math.sqrt(x);
|
|
374
|
+
};
|
|
375
|
+
/*CINEMÁTICA*/
|
|
376
|
+
//Velocidade média
|
|
377
|
+
module.exports.velocidadeMedia = function (s, t) {
|
|
378
|
+
if (isNaN(s) || s === null || isNaN(t) || t === null)
|
|
379
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para velocidadeMedia(d,t).');
|
|
380
|
+
return s / t;
|
|
381
|
+
};
|
|
382
|
+
//Espaço percorrido
|
|
383
|
+
module.exports.deltaS = function (s0, s) {
|
|
384
|
+
if (isNaN(s0) || s0 === null || isNaN(s) || s === null)
|
|
385
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para deltas(e0,e1).');
|
|
386
|
+
let ds = s - s0;
|
|
387
|
+
return ds;
|
|
388
|
+
};
|
|
389
|
+
//Tempo Percorrido
|
|
390
|
+
module.exports.deltaT = function (t0, t) {
|
|
391
|
+
if (isNaN(t0) || t0 === null || isNaN(t) || t === null)
|
|
392
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para deltat(t0,t1).');
|
|
393
|
+
let dt = t - t0;
|
|
394
|
+
return dt;
|
|
395
|
+
};
|
|
396
|
+
// Cálculo de aceleração
|
|
397
|
+
module.exports.aceleracao = function (velocidadeFinal, velocidadeInicial, tempoFinal, tempoInicial) {
|
|
398
|
+
if (velocidadeFinal === null || velocidadeInicial === null || tempoFinal === null || tempoInicial === null) {
|
|
399
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Devem ser fornecidos quatro parâmetros obrigatórios.');
|
|
400
|
+
}
|
|
401
|
+
if (typeof velocidadeFinal !== 'number' ||
|
|
402
|
+
typeof velocidadeInicial !== 'number' ||
|
|
403
|
+
typeof tempoFinal !== 'number' ||
|
|
404
|
+
typeof tempoInicial !== 'number') {
|
|
405
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Todos os parâmetros devem ser do tipo número.');
|
|
406
|
+
}
|
|
407
|
+
return (velocidadeFinal - velocidadeInicial) / (tempoFinal - tempoInicial);
|
|
408
|
+
};
|
|
409
|
+
//Função Horária da Posição (M.R.U)
|
|
410
|
+
module.exports.mrufh = function (s0, v, t) {
|
|
411
|
+
if (isNaN(s0) || s0 === null)
|
|
412
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para mrufh(s0,v,t).');
|
|
413
|
+
t = t + 1;
|
|
414
|
+
const s = [];
|
|
415
|
+
let index = 0;
|
|
416
|
+
for (let i = 0; i < t; i++) {
|
|
417
|
+
s[index] = s0 + v * i;
|
|
418
|
+
index++;
|
|
419
|
+
}
|
|
420
|
+
return ['Função: ' + s0 + '+(' + v + ')*t' + '<br>' + 'Posições: ' + s];
|
|
421
|
+
};
|
|
422
|
+
//Gráfico da velocidade (M.R.U.V)
|
|
423
|
+
module.exports.mruv = function (s0, s, a) {
|
|
424
|
+
if (isNaN(s0) || s0 === null || isNaN(s) || s === null || isNaN(a) || a === null)
|
|
425
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para mruv(Pi, Vf, A).');
|
|
426
|
+
const vf = [];
|
|
427
|
+
const x = [];
|
|
428
|
+
let v = [];
|
|
429
|
+
let index = 0;
|
|
430
|
+
for (let i = 0; i < s; i++) {
|
|
431
|
+
v = index;
|
|
432
|
+
vf[index] = Math.sqrt(2 * a * (index - s0));
|
|
433
|
+
x[index] = i;
|
|
434
|
+
index++;
|
|
435
|
+
}
|
|
436
|
+
return vf;
|
|
437
|
+
};
|
|
438
|
+
/*Controle e Servomecanismos*/
|
|
439
|
+
module.exports.pid = function (Mo, t, K, T1, T2) {
|
|
440
|
+
if (isNaN(Mo) ||
|
|
441
|
+
Mo === null ||
|
|
442
|
+
isNaN(t) ||
|
|
443
|
+
t === null ||
|
|
444
|
+
isNaN(K) ||
|
|
445
|
+
K === null ||
|
|
446
|
+
isNaN(T1) ||
|
|
447
|
+
T1 === null ||
|
|
448
|
+
isNaN(T2) ||
|
|
449
|
+
T2 === null) {
|
|
450
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'Você deve prover valores para pid(Ov, Ts, K, T1, T2).');
|
|
451
|
+
}
|
|
452
|
+
let pi = Math.PI; //Pi da bilbioteca Math.js
|
|
453
|
+
//Amortecimento Relativo
|
|
454
|
+
let csi = (-1 * Math.log(Mo / 100)) / Math.sqrt(Math.pow(pi, 2) + pot(Math.log(Mo / 100), 2));
|
|
455
|
+
//Frequência Natural
|
|
456
|
+
let Wn = 4 / (t * csi);
|
|
457
|
+
//Controlador Proporcional (P)
|
|
458
|
+
let Kp = 20 * (Math.pow(csi, 2) * Math.pow(Wn, 2) * T1 * T2) + (Math.pow(Wn, 2) * T1 * T2 - 1) / K;
|
|
459
|
+
//Controlador Integral (I)
|
|
460
|
+
let Ki = (10 * csi * Math.pow(Wn, 3) * T1 * T2) / K;
|
|
461
|
+
//Controlador Derivativo (D)
|
|
462
|
+
let Kd = (12 * csi * Wn * T1 * T2 - T1 - T2) / K;
|
|
463
|
+
return [csi, Wn, Kp, Ki, Kd];
|
|
464
|
+
};
|
|
465
|
+
// Retorna o comprimento de um vetor
|
|
466
|
+
module.exports.comp = function (array) {
|
|
467
|
+
if (!Array.isArray(array)) {
|
|
468
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'O valor passado pra função deve ser um vetor.');
|
|
469
|
+
}
|
|
470
|
+
return array.length;
|
|
471
|
+
};
|
|
472
|
+
// Retorna o menor número inteiro dentre o valor de "value"
|
|
473
|
+
module.exports.minaprox = function (value) {
|
|
474
|
+
if (typeof value !== 'number') {
|
|
475
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(this.token, 'O valor passado pra função deve ser um número.');
|
|
476
|
+
}
|
|
477
|
+
return Math.floor(value);
|
|
478
|
+
};
|
|
479
479
|
//# sourceMappingURL=matematica.js.map
|