node-expression-eval

0.1.0 • Public • Published

��J�a�v�a�S�c�r�i�p�t� �E�x�p�r�e�s�s�i�o�n� �E�v�a�l�u�a�t�o�r� �D�e�s�c�r�i�p�t�i�o�n� � �T�h�i�s� �l�i�b�r�a�r�y� �i�s� �a� �m�o�d�i�f�i�e�d� �v�e�r�s�i�o�n� �o�f� �R�a�p�h�a�e�l� �G�r�a�f� s� �A�c�t�i�o�n�S�c�r�i�p�t� �E�x�p�r�e�s�s�i�o�n� �P�a�r�s�e�r�.� �W�h�e�n� �I� �w�r�o�t�e� �t�h�e� �J�a�v�a�S�c�r�i�p�t� �F�u�n�c�t�i�o�n� �P�l�o�t�t�e�r�,� �I� �w�a�n�t�e�d� �a� �b�e�t�t�e�r� �a�l�t�e�r�n�a�t�i�v�e� �t�o� �u�s�i�n�g� �J�a�v�a�S�c�r�i�p�t� s� �e�v�a�l� �f�u�n�c�t�i�o�n�.� �T�h�e�r�e� s� �n�o� �s�e�c�u�r�i�t�y� �r�i�s�k� �c�u�r�r�e�n�t�l�y�,� �b�e�c�a�u�s�e� �y�o�u� �c�a�n� �o�n�l�y� �r�u�n� �c�o�d�e� �i�n� �y�o�u�r� �o�w�n� �b�r�o�w�s�e�r�,� �b�u�t� �i�t� s� �n�o�t� �a�s� �c�o�n�v�e�n�i�e�n�t� �f�o�r� �m�a�t�h� �(�M�a�t�h�.�p�o�w�(�2�^�x�)� �i�n�s�t�e�a�d� �o�f� �2�^�x�,� �e�t�c�.�)�.� � �D�o�w�n�l�o�a�d� � �G�e�t� �t�h�e� �c�o�d�e� �f�r�o�m� �g�i�t�h�u�b�.� � �D�o�c�u�m�e�n�t�a�t�i�o�n� �(�i�n�c�o�m�p�l�e�t�e�,� �o�f� �c�o�u�r�s�e�)� � �P�a�r�s�e�r� � �P�a�r�s�e�r� �i�s� �t�h�e� �m�a�i�n� �c�l�a�s�s� �i�n� �t�h�e� �l�i�b�r�a�r�y�.� �I�t� �h�a�s� � s�t�a�t�i�c� �m�e�t�h�o�d�s� �f�o�r� �p�a�r�s�i�n�g� �a�n�d� �e�v�a�l�u�a�t�i�n�g� �e�x�p�r�e�s�s�i�o�n�s�.� � �P�a�r�s�e�r�(�)� �C�o�n�s�t�r�u�c�t�o�r�.� �I�n� �m�o�s�t� �c�a�s�e�s�,� �y�o�u� �d�o�n� t� �n�e�e�d� �t�h�i�s�.� �E�v�e�n�t�u�a�l�l�y�,� �I� l�l� �g�e�t� �a�r�o�u�n�d� �t�o� �d�o�c�u�m�e�n�t�i�n�g� �w�h�y� �y�o�u� �w�o�u�l�d� �w�a�n�t� �t�o�,� �b�u�t� �f�o�r� �n�o�w�,� �y�o�u� �c�a�n� �f�i�g�u�r�e� �i�t� �o�u�t� �b�y� �r�e�a�d�i�n�g� �t�h�e� �s�o�u�r�c�e� �;�-�)�.� �p�a�r�s�e�(�{�e�x�p�r�e�s�s�i�o�n�:� �s�t�r�i�n�g�}�)� �C�o�n�v�e�r�t� �a� �m�a�t�h�e�m�a�t�i�c�a�l� �e�x�p�r�e�s�s�i�o�n� �i�n�t�o� �a�n� �E�x�p�r�e�s�s�i�o�n� �o�b�j�e�c�t�.� �e�v�a�l�u�a�t�e�(�{�e�x�p�r�e�s�s�i�o�n�:� �s�t�r�i�n�g�}� �[�,� �{�v�a�r�i�a�b�l�e�s�:� �o�b�j�e�c�t�}�]�)� �P�a�r�s�e� �a�n�d� �i�m�m�e�d�i�a�t�e�l�y� �e�v�a�l�u�a�t�e� �a�n� �e�x�p�r�e�s�s�i�o�n� �u�s�i�n�g� �t�h�e� �v�a�l�u�e�s�/�f�u�n�c�t�i�o�n�s� �f�r�o�m� �t�h�e� �{�v�a�r�i�a�b�l�e�s�}� �o�b�j�e�c�t�.� �P�a�r�s�e�r�.�e�v�a�l�u�a�t�e�(�e�x�p�r�,� �v�a�r�s�)� �i�s� �e�q�u�i�v�a�l�e�n�t� �t�o� �c�a�l�l�i�n�g� �P�a�r�s�e�r�.�p�a�r�s�e�(�e�x�p�r�)�.�e�v�a�l�u�a�t�e�(�v�a�r�s�)�.� �I�n� �f�a�c�t�,� �t�h�a�t� s� �e�x�a�c�t�l�y� �w�h�a�t� �i�t� �d�o�e�s�.� � �P�a�r�s�e�r�.�E�x�p�r�e�s�s�i�o�n� � �P�a�r�s�e�r�.�p�a�r�s�e� �r�e�t�u�r�n�s� �a�n� �E�x�p�r�e�s�s�i�o�n� �o�b�j�e�c�t�.� �E�x�p�r�e�s�s�i�o�n� �o�b�j�e�c�t�s� �a�r�e� �s�i�m�i�l�a�r� �t�o� �J�a�v�a�S�c�r�i�p�t� �f�u�n�c�t�i�o�n�s�,� �i�.�e�.� �t�h�e�y� �c�a�n� �b�e� � c�a�l�l�e�d� �w�i�t�h� �v�a�r�i�a�b�l�e�s� �b�o�u�n�d� �t�o� �p�a�s�s�e�d�-�i�n� �v�a�l�u�e�s�.� �I�n� �f�a�c�t�,� �t�h�e�y� �c�a�n� �e�v�e�n� �b�e� �c�o�n�v�e�r�t�e�d� �i�n�t�o� �J�a�v�a�S�c�r�i�p�t� �f�u�n�c�t�i�o�n�s�.� � �e�v�a�l�u�a�t�e�(�[�{�v�a�r�i�a�b�l�e�s�:� �o�b�j�e�c�t�}�]�)� �E�v�a�l�u�a�t�e� �a�n� �e�x�p�r�e�s�s�i�o�n�,� �w�i�t�h� �v�a�r�i�a�b�l�e�s� �b�o�u�n�d� �t�o� �t�h�e� �v�a�l�u�e�s� �i�n� �{�v�a�r�i�a�b�l�e�s�}�.� �E�a�c�h� �u�n�b�o�u�n�d� �v�a�r�i�a�b�l�e� �i�n� �t�h�e� �e�x�p�r�e�s�s�i�o�n� �i�s� �b�o�u�n�d� �t�o� �t�h�e� �c�o�r�r�e�s�p�o�n�d�i�n�g� �m�e�m�b�e�r� �o�f� �t�h�e� �{�v�a�r�i�a�b�l�e�s�}� �o�b�j�e�c�t�.� �I�f� �t�h�e�r�e� �a�r�e� �u�n�b�o�u�n�d� �v�a�r�i�a�b�l�e�s�,� �e�v�a�l�u�a�t�e� �w�i�l�l� �t�h�r�o�w� �a�n� �e�x�c�e�p�t�i�o�n�.� �j�s�>� �e�x�p�r� �=� �P�a�r�s�e�r�.�p�a�r�s�e�(�"�2� �^� �x�"�)�;� �(�2�^�x�)� �j�s�>� �e�x�p�r�.�e�v�a�l�u�a�t�e�(�{� �x�:� �3� �}�)�;� �8� �s�u�b�s�t�i�t�u�t�e�(�{�v�a�r�i�a�b�l�e�:� �s�t�r�i�n�g�}�,� �{�e�x�p�r�:� �E�x�p�r�e�s�s�i�o�n�,� �s�t�r�i�n�g�,� �o�r� �n�u�m�b�e�r�}�)� �C�r�e�a�t�e� �a� �n�e�w� �e�x�p�r�e�s�s�i�o�n� �w�i�t�h� �t�h�e� �s�p�e�c�i�f�i�e�d� �v�a�r�i�a�b�l�e� �r�e�p�l�a�c�e�d� �w�i�t�h� �a�n�o�t�h�e�r� �e�x�p�r�e�s�s�i�o�n� �(�e�s�s�e�n�t�i�a�l�l�y�,� �f�u�n�c�t�i�o�n� �c�o�m�p�o�s�i�t�i�o�n�)�.� �j�s�>� �e�x�p�r� �=� �P�a�r�s�e�r�.�p�a�r�s�e�(�"�2� �� �x� �+� �1�"�)�;� �(�(�2��x�)�+�1�)� �j�s�>� �e�x�p�r�.�s�u�b�s�t�i�t�u�t�e�(�"�x�"�,� �"�4� �� �x�"�)�;� �(�(�2��(�4��x�)�)�+�1�)� �j�s�>� �e�x�p�r�2�.�e�v�a�l�u�a�t�e�(�{� �x�:� �3�}�)�;� �2�5� �s�i�m�p�l�i�f�y�(�{�v�a�r�i�a�b�l�e�s�:� �o�b�j�e�c�t�>�)� �S�i�m�p�l�i�f�y� �c�o�n�s�t�a�n�t� �s�u�b�-�e�x�p�r�e�s�s�i�o�n�s� �a�n�d� �r�e�p�l�a�c�e� �v�a�r�i�a�b�l�e� �r�e�f�e�r�e�n�c�e�s� �w�i�t�h� �l�i�t�e�r�a�l� �v�a�l�u�e�s�.� �T�h�i�s� �i�s� �b�a�s�i�c�a�l�l�y� �a� �p�a�r�t�i�a�l� �e�v�a�l�u�a�t�i�o�n�,� �t�h�a�t� �d�o�e�s� �a�s� �m�u�c�h� �o�f� �t�h�e� �c�a�l�c�u�a�t�i�o�n� �a�s� �i�t� �c�a�n� �w�i�t�h� �t�h�e� �p�r�o�v�i�d�e�d� �v�a�r�i�a�b�l�e�s�.� �F�u�n�c�t�i�o�n� �c�a�l�l�s� �a�r�e� �n�o�t� �e�v�a�l�u�a�t�e�d� �(�e�x�c�e�p�t� �t�h�e� �b�u�i�l�t�-�i�n� �o�p�e�r�a�t�o�r� �f�u�n�c�t�i�o�n�s�)�,� �s�i�n�c�e� �t�h�e�y� �m�a�y� �n�o�t� �b�e� �d�e�t�e�r�m�i�n�i�s�t�i�c�.� �S�i�m�p�l�i�f�y� �i�s� �p�r�e�t�t�y� �s�i�m�p�l�e� �(�s�e�e� �w�h�a�t� �I� �d�i�d� �t�h�e�r�e�?�)�.� �I�t� �d�o�e�s�n� t� �k�n�o�w� �t�h�a�t� �a�d�d�i�t�i�o�n� �a�n�d� �m�u�l�t�i�p�l�i�c�a�t�i�o�n� �a�r�e� �a�s�s�o�c�i�a�t�i�v�e�,� �s�o� � (�(�2��(�4��x�)�)�+�1�)� �f�r�o�m� �t�h�e� �p�r�e�v�i�o�u�s� �e�x�a�m�p�l�e� �c�a�n�n�o�t� �b�e� �s�i�m�p�l�i�f�i�e�d� �u�n�l�e�s�s� �y�o�u� �p�r�o�v�i�d�e� �a� �v�a�l�u�e� �f�o�r� �x�.� � 2��4��x� �+� �1�3 �c�a�n� �h�o�w�e�v�e�r�,� �b�e�c�a�u�s�e� �i�t� s� �p�a�r�s�e�d� �a�s� � (�(�(�2��4�)��x�)�+�1�)� ,� �s�o� �t�h�e� � (�2��4�)� �s�u�b�-�e�x�p�r�e�s�s�i�o�n� �w�i�l�l� �b�e� �r�e�p�l�a�c�e�d� �w�i�t�h� � 8�3 ,� �r�e�s�u�l�t�i�n�g� �i�n� � (�(�8��x�)�+�1�)� .� � �j�s�>� �e�x�p�r� �=� �P�a�r�s�e�r�.�p�a�r�s�e�(�"�x� �� �(�y� �� �a�t�a�n�(�1�)�)�"�)�.�s�i�m�p�l�i�f�y�(�{� �y�:� �4� �}�)�;� �(�x��3�.�1�4�1�5�9�2�6�5�3�5�8�9�7�9�3�)� �j�s�>� �e�x�p�r�.�e�v�a�l�u�a�t�e�(�{� �x�:� �2� �}�)�;� �6�.�2�8�3�1�8�5�3�0�7�1�7�9�5�8�6� �v�a�r�i�a�b�l�e�s�(�)� �G�e�t� �a�n� �a�r�r�a�y� �o�f� �t�h�e� �u�n�b�o�u�n�d� �v�a�r�i�a�b�l�e�s� �i�n� �t�h�e� �e�x�p�r�e�s�s�i�o�n�.� �j�s�>� �e�x�p�r� �=� �P�a�r�s�e�r�.�p�a�r�s�e�(�"�x� �� �(�y� �� �a�t�a�n�(�1�)�)�"�)�;� �(�x��(�y��a�t�a�n�(�1�)�)�)� �j�s�>� �e�x�p�r�.�v�a�r�i�a�b�l�e�s�(�)�;� �x�,�y� �j�s�>� �e�x�p�r�.�s�i�m�p�l�i�f�y�(�{� �y�:� �4� �}�)�.�v�a�r�i�a�b�l�e�s�(�)�;� �x� �t�o�S�t�r�i�n�g�(�)� �C�o�n�v�e�r�t� �t�h�e� �e�x�p�r�e�s�s�i�o�n� �t�o� �a� �s�t�r�i�n�g�.� �t�o�S�t�r�i�n�g�(�)� �s�u�r�r�o�u�n�d�s� �e�v�e�r�y� �s�u�b�-�e�x�p�r�e�s�s�i�o�n� �w�i�t�h� �p�a�r�e�n�t�h�e�s�e�s� �(�e�x�c�e�p�t� �l�i�t�e�r�a�l� �v�a�l�u�e�s�,� �v�a�r�i�a�b�l�e�s�,� �a�n�d� �f�u�n�c�t�i�o�n� �c�a�l�l�s�)�,� �s�o� �i�t� s� �u�s�e�f�u�l� �f�o�r� �d�e�b�u�g�g�i�n�g� �p�r�e�c�i�d�e�n�c�e� �e�r�r�o�r�s�.� �t�o�J�S�F�u�n�c�t�i�o�n�(�{�p�a�r�a�m�e�t�e�r�s�:� �A�r�r�a�y�}� �[�,� �{�v�a�r�i�a�b�l�e�s�:� �o�b�j�e�c�t�}�]�)� �C�o�n�v�e�r�t� �a�n� �E�x�p�r�e�s�s�i�o�n� �o�b�j�e�c�t� �i�n�t�o� �a� �c�a�l�l�a�b�l�e� �J�a�v�a�S�c�r�i�p�t� �f�u�n�c�t�i�o�n�.� �Y�o�u� �n�e�e�d� �t�o� �p�r�o�v�i�d�e� �a�n� �a�r�r�a�y� �o�f� �p�a�r�a�m�e�t�e�r� �n�a�m�e�s� �t�h�a�t� �s�h�o�u�l�d� �n�o�r�m�a�l�l�y� �b�e� �e�x�p�r�.�v�a�r�i�a�b�l�e�s�(�)�.� �A�n�y� �u�n�b�o�u�n�d�-�v�a�r�i�a�b�l�e�s� �w�i�l�l� �g�e�t� �t�h�e�i�r� �v�a�l�u�e�s� �f�r�o�m� �t�h�e� �g�l�o�b�a�l� �s�c�o�p�e�.� �t�o�J�S�F�u�n�c�t�i�o�n� �w�o�r�k�s� �b�y� �s�i�m�p�l�i�f�y�i�n�g� �t�h�e� �E�x�p�r�e�s�s�i�o�n� �(�w�i�t�h� �{�v�a�r�i�a�b�l�e�s�}�,� �i�f� �p�r�o�v�i�d�e�d�)�,� �c�o�n�v�e�r�t�i�n�g� �i�t� �t�o� �a� �s�t�r�i�n�g�,� �a�n�d� �p�a�s�s�i�n�g� �t�h�e� �s�t�r�i�n�g� �t�o� �t�h�e� �F�u�n�c�t�i�o�n� �c�o�n�s�t�r�u�c�t�o�r� �(�w�i�t�h� �s�o�m�e� �o�f� �i�t�s� �o�w�n� �c�o�d�e� �t�o� �b�r�i�n�g� �b�u�i�l�t�-�i�n� �f�u�n�c�t�i�o�n�s� �a�n�d� �c�o�n�s�t�a�n�t�s� �i�n�t�o� �s�c�o�p�e� �a�n�d� �r�e�t�u�r�n� �t�h�e� �r�e�s�u�l�t� �o�f� �t�h�e� �e�x�p�r�e�s�s�i�o�n�)�.� � �E�x�p�r�e�s�s�i�o�n� �S�y�n�t�a�x� � �T�h�e� �p�a�r�s�e�r� �a�c�c�e�p�t�s� �a� �p�r�e�t�t�y� �b�a�s�i�c� �g�r�a�m�m�a�r�.� �O�p�e�r�a�t�o�r�s� �h�a�v�e� �t�h�e� �n�o�r�m�a�l� �p�r�e�c�i�d�e�n�c�e� � �f�(�x�,�y�,�z�)� �(�f�u�n�c�t�i�o�n� �c�a�l�l�s�)�,� �^� �(�e�x�p�o�n�e�n�t�i�a�t�i�o�n�)�,� ��,� �/�,� �a�n�d� �%� �(�m�u�l�t�i�p�l�i�c�a�t�i�o�n�,� �d�i�v�i�s�i�o�n�,� �a�n�d� �r�e�m�a�i�n�d�e�r�)�,� �a�n�d� �f�i�n�a�l�l�y� �+�,� �-�,� �a�n�d� �|�|� �(�a�d�d�i�t�i�o�n�,� �s�u�b�t�r�a�c�t�i�o�n�,� �a�n�d� �s�t�r�i�n�g� �c�o�n�c�a�t�e�n�a�t�i�o�n�)� � �a�n�d� �b�i�n�d� �f�r�o�m� �l�e�f�t� �t�o� �r�i�g�h�t� �(�y�e�s�,� �e�v�e�n� �e�x�p�o�n�e�n�t�i�a�t�i�o�n�& �i�t� s� �s�i�m�p�l�e�r� �t�h�a�t� �w�a�y�)�.� � �T�h�e�r�e� s� �a�l�s�o� �a� � ,� �(�c�o�m�m�a�)� �o�p�e�r�a�t�o�r� �t�h�a�t� �c�o�n�c�a�t�e�n�a�t�e�s� �v�a�l�u�e�s� �i�n�t�o� �a�n� �a�r�r�a�y�.� �I�t� s� �m�o�s�t�l�y� �u�s�e�f�u�l� �f�o�r� �p�a�s�s�i�n�g� �a�r�g�u�m�e�n�t�s� �t�o� �f�u�n�c�t�i�o�n�s�,� �s�i�n�c�e� �i�t� �d�o�e�s�n� t� �a�l�w�a�y�s� �b�e�h�a�v�e� �l�i�k�e� �y�o�u� �w�o�u�l�d� �t�h�i�n�k� �w�i�t�h� �r�e�g�a�r�d�s� �t�o� �m�u�l�t�i�-�d�i�m�e�n�s�i�o�n�a�l� �a�r�r�a�y�s�.� �I�f� �t�h�e� �l�e�f�t� �v�a�l�u�e� �i�s� �a�n� �a�r�r�a�y�,� �i�t� �p�u�s�h�e�s� �t�h�e� �r�i�g�h�t� �v�a�l�u�e� �o�n�t�o� �t�h�e� �e�n�d� �o�f� �t�h�e� �a�r�r�a�y�,� �o�t�h�e�r�w�i�s�e�,� �i�t� �c�r�e�a�t�e�s� �a� �n�e�w� �a�r�r�a�y� � [�l�e�f�t�,� �r�i�g�h�t�]� .� �T�h�i�s� �m�a�k�e�s� �i�t� �i�m�p�o�s�s�i�b�l�e� �t�o� �c�r�e�a�t�e� �a�n� �a�r�r�a�y� �w�i�t�h� �a�n�o�t�h�e�r� �a�r�r�a�y� �a�s� �i�t� s� �f�i�r�s�t� �e�l�e�m�e�n�t�.� � �F�u�n�c�t�i�o�n� �o�p�e�r�a�t�o�r�s� � �T�h�e� �p�a�r�s�e�r� �h�a�s� �s�e�v�e�r�a�l� �b�u�i�l�t�-�i�n� � f�u�n�c�t�i�o�n�s� �t�h�a�t� �a�r�e� �a�c�t�u�a�l�l�y� �o�p�e�r�a�t�o�r�s�.� �T�h�e� �o�n�l�y� �d�i�f�f�e�r�e�n�c�e� �f�r�o�m� �a�n� �o�u�t�s�i�d�e� �p�o�i�n�t� �o�f� �v�i�e�w�,� �i�s� �t�h�a�t� �t�h�e�y� �c�a�n�n�o�t� �b�e� �c�a�l�l�e�d� �w�i�t�h� �m�u�l�t�i�p�l�e� �a�r�g�u�m�e�n�t�s� �a�n�d� �t�h�e�y� �a�r�e� �e�v�a�l�u�a�t�e�d� �b�y� �t�h�e� �s�i�m�p�l�i�f�y� �m�e�t�h�o�d� �i�f� �t�h�e�i�r� �a�r�g�u�m�e�n�t�s� �a�r�e� �c�o�n�s�t�a�n�t�.� � �F�u�n�c�t�i�o�n� �D�e�s�c�r�i�p�t�i�o�n� �s�i�n�(�x�)� �S�i�n�e� �o�f� �x� �(�x� �i�s� �i�n� �r�a�d�i�a�n�s�)� �c�o�s�(�x�)� �C�o�s�i�n�e� �o�f� �x� �(�x� �i�s� �i�n� �r�a�d�i�a�n�s�)� �t�a�n�(�x�)� �T�a�n�g�e�n�t� �o�f� �x� �(�x� �i�s�& �w�e�l�l�,� �y�o�u� �k�n�o�w�)� �a�s�i�n�(�x�)� �A�r�c� �s�i�n�e� �o�f� �x� �(�i�n� �r�a�d�i�a�n�s�)� �a�c�o�s�(�x�)� �A�r�c� �c�o�s�i�n�e� �o�f� �x� �(�i�n� �r�a�d�i�a�n�s�)� �a�t�a�n�(�x�)� �A�r�c� �t�a�n�g�e�n�t� �o�f� �x� �(�i�n� �r�a�d�i�a�n�s�)� �s�q�r�t�(�x�)� �S�q�u�a�r�e� �r�o�o�t� �o�f� �x�.� �R�e�s�u�l�t� �i�s� �N�a�N� �(�N�o�t� �a� �N�u�m�b�e�r�)� �i�f� �x� �i�s� �n�e�g�a�t�i�v�e�.� �l�o�g�(�x�)� �N�a�t�u�r�a�l� �l�o�g�a�r�i�t�h�m� �o�f� �x� �(�n�o�t� �b�a�s�e�-�1�0�)�.� �I�t� s� �l�o�g� �i�n�s�t�e�a�d� �o�f� �l�n� �b�e�c�a�u�s�e� �t�h�a�t� s� �w�h�a�t� �J�a�v�a�S�c�r�i�p�t� �c�a�l�l�s� �i�t�.� �a�b�s�(�x�)� �A�b�s�o�l�u�t�e� �v�a�l�u�e� �(�m�a�g�n�a�t�u�d�e�)� �o�f� �x� �c�e�i�l�(�x�)� �C�e�i�l�i�n�g� �o�f� �x� � �t�h�e� �s�m�a�l�l�e�s�t� �i�n�t�e�g�e�r� �t�h�a�t� s� �>�=� �x�.� �f�l�o�o�r�(�x�)� �F�l�o�o�r� �o�f� �x� � �t�h�e� �l�a�r�g�e�s�t� �i�n�t�e�g�e�r� �t�h�a�t� s� �<�=� �x� �r�o�u�n�d�(�x�)� �X�,� �r�o�u�n�d�e�d� �t�o� �t�h�e� �n�e�a�r�e�s�t� �i�n�t�e�g�e�r�,� �u�s�i�n�g� � g�r�a�d�e�s�c�h�o�o�l� �r�o�u�n�d�i�n�g� .� �e�x�p�(�x�)� �e�x� �(�e�x�p�o�n�e�n�t�i�a�l�/�a�n�t�i�l�o�g�a�r�i�t�h�m� �f�u�n�c�t�i�o�n� �w�i�t�h� �b�a�s�e� �e�)� �P�r�e�-�d�e�f�i�n�e�d� �f�u�n�c�t�i�o�n�s� � �B�e�s�i�d�e�s� �t�h�e� � o�p�e�r�a�t�o�r� �f�u�n�c�t�i�o�n�s�,� �t�h�e�r�e� �a�r�e� �s�e�v�e�r�a�l� �p�r�e�-�d�e�f�i�n�e�d� �f�u�n�c�t�i�o�n�s�.� �Y�o�u� �c�a�n� �p�r�o�v�i�d�e� �y�o�u�r� �o�w�n�,� �b�y� �b�i�n�d�i�n�g� �v�a�r�i�a�b�l�e�s� �t�o� �n�o�r�m�a�l� �J�a�v�a�S�c�r�i�p�t� �f�u�n�c�t�i�o�n�s�.� �T�h�e�s�e� �a�r�e� �n�o�t� �e�v�a�l�u�a�t�e�d� �b�y� �s�i�m�p�l�i�f�y�.� � �F�u�n�c�t�i�o�n� �D�e�s�c�r�i�p�t�i�o�n� �r�a�n�d�o�m�(�n�)� �G�e�t� �a� �r�a�n�d�o�m� �n�u�m�b�e�r� �i�n� �t�h�e� �r�a�n�g�e� �[�0�,� �n�)�.� �I�f� �n� �i�s� �z�e�r�o�,� �o�r� �n�o�t� �p�r�o�v�i�d�e�d�,� �i�t� �d�e�f�a�u�l�t�s� �t�o� �1�.� �f�a�c�(�n�)� �n�!� �(�f�a�c�t�o�r�i�a�l� �o�f� �n�:� � n� �� �(�n�-�1�)� �� �(�n�-�2�)� �� �& �� �2� �� �1�3 )� �m�i�n�(�a�,�b�,�& )� �G�e�t� �t�h�e� �s�m�a�l�l�e�s�t� �(� m�i�n�i�m�u�m� )� �n�u�m�b�e�r� �i�n� �t�h�e� �l�i�s�t� �m�a�x�(�a�,�b�,�& )� �G�e�t� �t�h�e� �l�a�r�g�e�s�t� �(� m�a�x�i�m�u�m� )� �n�u�m�b�e�r� �i�n� �t�h�e� �l�i�s�t� �p�y�t�(�a�,� �b�)� �P�y�t�h�a�g�o�r�e�a�n� �f�u�n�c�t�i�o�n�,� �i�.�e�.� �t�h�e� �c� �i�n� � c�2� �=� �a�2� �+� �b�2� �p�o�w�(�x�,� �y�)� �x�y�.� �T�h�i�s� �i�s� �e�x�a�c�t�l�y� �t�h�e� �s�a�m�e� �a�s� � x�^�y� .� �I�t� s� �j�u�s�t� �p�r�o�v�i�d�e�d� �s�i�n�c�e� �i�t� s� �i�n� �t�h�e� �M�a�t�h� �o�b�j�e�c�t� �f�r�o�m� �J�a�v�a�S�c�r�i�p�t� �a�t�a�n�2�(�y�,� �x�)� �a�r�c� �t�a�n�g�e�n�t� �o�f� �x�/�y�.� �i�.�e�.� �t�h�e� �a�n�g�l�e� �b�e�t�w�e�e�n� �(�0�,� �0�)� �a�n�d� �(�x�,� �y�)� �i�n� �r�a�d�i�a�n�s�.�

Dependents (0)

Package Sidebar

Install

npm i node-expression-eval

Weekly Downloads

0

Version

0.1.0

License

none

Last publish

Collaborators

  • wookets