![]() |
N.S.B. Cosmic Center |
![]() |
JavaScript & MathScript Interactive Document Generator-Demo-09This document is generated by N.S.B. JavaScript & MathScript Interactive Document Generator version 001. Introduction to N.S.B. JavaScript & MathScript Interactive Document Generator MathScript Functions (cont.) The functions holdCases[] and delCases[] are useful for keeping or deleting, respectively, the elements of a MathScript function that satisfy a certain property. In the following code sequence, we begin with a MathScript array containing several elements of various types, then proceed to illustrate the use of input(1)=> ff={a,f[i,j], 2.3, x, g[r,s,t], pi, 11711}output(1)=> {a, f[i, j], 2.300, x, g[r, s, t], 3.142, 11711}input(2)=> holdCases[ff, isNum]output(2)=> {2.300, 3.142, 11711}input(3)=> delCases[ff, isNum]output(3)=> {a, f[i, j], x, g[r, s, t]}input(4)=> %// delCases[#, isStr]output(4)=> {f[i, j], g[r, s, t]}Many more types of conditions that can be applied to the identification of members will be discussed further in more advanced demodocs. We have already introduced the function input(5)=> F[a,b,c,d,e]output(5)=> F[a, b, c, d, e]input(6)=> insert[%, x, 3]output(6)=> F[a, b, x, c, d, e]input(7)=> %// insert[#, y, 6]output(7)=> F[a, b, x, c, d, y, e]input(8)=> delAt[%, 1]output(8)=> F[b, x, c, d, y, e]input(9)=> %// delAt[#, 6]output(9)=> F[b, x, c, d, y]The function input(10)=> ffoutput(10)=> {a, f[i, j], 2.300, x, g[r, s, t], 3.142, 11711}input(11)=> isMemberOf[f[i,j], ff]output(11)=> trueinput(12)=> countMemberOf[f[i,j], ff]output(12)=> 1input(13)=> indexMemberOf[f[i,j], ff]output(13)=> 2input(14)=> ff// isMemberOf[isNum, #]output(14)=> trueinput(15)=> ff// countMemberOf[isNum, #]output(15)=> 3input(16)=> ff// indexMemberOf[isNum, #]output(16)=> 3input(17)=> ff//reverseoutput(17)=> {11711, 3.142, g[r, s, t], x, 2.300, f[i, j], a}input(18)=> %// indexMemberOf[isNum, #]output(18)=> 1Before proceeding to the next demodoc, where we shall continue to introduce more functions and features of MathScript, why don't you practice using MathScript live by clicking the program page below, and apply what you learned on this page. Program PageNext |
||
![]() |
Home |
![]() |