URL
stringlengths
15
1.68k
text_list
listlengths
1
199
image_list
listlengths
1
199
metadata
stringlengths
1.19k
3.08k
https://jy.xinghuo100.com/xxzx/1414.html
[ "", null, "# 小学数学常见数量关系和计算公式\n\n2019-11-21 15:51:16 文章来源:江阴小学辅导 作者:江阴星火教育 浏览量:250\n\n1.一般关系式\n\n路程=速度×时间 速度=路程÷时间\n\n时间=路程÷速度\n\n工作总量=工作效率×工作时间\n\n工作效率=工作总量÷工作时间\n\n工作时间=工作总量÷工作效率\n\n总产量=单产量×数量\n\n单产量=总产量÷数量\n\n数量=总产量÷单产量\n\n总价=单价×数量 单价=总价÷数量\n\n数量=总价÷单价\n\n利息=本金×年利率×年数\n\n利息=本金×月利率×月数\n\n税后利息=本金×年利率×年数×(1-税率)税后利息=本金×月利率×月数×(1-税率)\n\n个人所得税=(收入-基数)×税率\n\n2.四则运算中的关系式\n\n加数+加数=和\n\n一个加数=和—另一加数\n\n被减数—减数=差 被减数=差+减数\n\n减数=被减数—差\n\n因数×因数=积\n\n一个因数=积÷另一个因数\n\n被除数÷除数=商 被除数=商×除数\n\n除数=被除数÷商\n\n3.计算公式\n\n(1)周长\n\n长方形周长=(长+宽)×2\n\n正方形周长=边长×4\n\n圆的周长:C=2Лr 或C=Лd\n\n(2)面积\n\n长方形的面积=长×宽\n\n正方形的面积=边长×边长\n\n三角形的面积=底×高÷2\n\n平行四边形的面积=底×高\n\n梯形的面积=(上底+下底)×高÷2\n\n圆面积;S=Лr²\n\n(3)表面积\n\n正方体表面积=棱长×棱长×6\n\n长方体的表面积=(长×宽+长×高+宽×高)×2\n\n圆柱的表面积=侧面积=底面积×2\n\n(4)柱体的侧面积\n\n圆柱的侧面积=底面周长×高\n\n(5)体积\n\n正方体体积=棱长×棱长×棱长或V=a³\n\n长方体的体积=长×宽×高或V=abh\n\n圆柱的体积=底面积×高 或v=sh\n\n圆锥的体积=底面积×高÷3\n\n或v=1/3sh\n\n(6)圆的相关计算公式(直径d,半径r,大圆半径R,圆周率Л,周长C)\n\nr=d÷2 r=c÷Л÷2\n\nd=2r d=c÷Л\n\n环形面积=Л(R²-r²)\n\n(7)比例尺\n\n图上距离:实际距离=比例尺\n\n实际距离=图上距离÷比例尺\n\n图上距离=实际距离×比例尺" ]
[ null, "https://jy.xinghuo100.com/bocweb/web/img/phone.png", null ]
{"ft_lang_label":"__label__zh","ft_lang_prob":0.8820491,"math_prob":0.9993224,"size":1122,"snap":"2020-45-2020-50","text_gpt3_token_len":1232,"char_repetition_ratio":0.08139535,"word_repetition_ratio":0.0,"special_character_ratio":0.29144385,"punctuation_ratio":0.019379845,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99405813,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-28T19:53:05Z\",\"WARC-Record-ID\":\"<urn:uuid:9287ac64-d7ed-45d0-92b6-3878042beca3>\",\"Content-Length\":\"47410\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:18eac2c0-e5ab-4a24-bb1c-05881702240b>\",\"WARC-Concurrent-To\":\"<urn:uuid:ff7988b5-eb38-4f16-865d-e39a8a1a29b5>\",\"WARC-IP-Address\":\"180.163.121.221\",\"WARC-Target-URI\":\"https://jy.xinghuo100.com/xxzx/1414.html\",\"WARC-Payload-Digest\":\"sha1:OHB6ITUNSG3UPWVAYJKOOSZWJN5WR7V4\",\"WARC-Block-Digest\":\"sha1:HQWFYIFSEWILCFETGBMKV3BHSNCMYYFR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107900860.51_warc_CC-MAIN-20201028191655-20201028221655-00246.warc.gz\"}"}
https://www.schoolconnects.in/studymaterials/cbse-ncert-6th-class-science-motion-and-measurements-10-chapter
[ "", null, "# 6th Class Chapter No 10 - Motion And Measurements in Science for CBSE NCERT\n\nMeasurement: Comparing an unknown quantity with some known quantity is called measurement. Result of Measurement: The result of measurement has two parts; one part is the number and another part is the unit. The known quantity which is used in measurement is called a unit. For example; when you say that your height is 150 cm then the measurement of your height is being expressed in a number, i.e. 150 and a unit, i.e. centimeter.\nPosted in 6th on February 13 2019 at 03:29 PM\n\n### CBSE NCERT 6th CLASS Science OTHER CHAPTERS", null, "", null, "" ]
[ null, "https://d2jg2pri5bpndu.cloudfront.net/users/avatar/1/50_square_2318a062ef1776f75edc8557c5c127f3_tmp.jpg", null, "https://d2jg2pri5bpndu.cloudfront.net/webroot/user/img/noimage/Unknown-user.png", null, "https://www.schoolconnects.in/studymaterials/cbse-ncert-6th-class-science-motion-and-measurements-10-chapter", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.90302396,"math_prob":0.8656667,"size":1021,"snap":"2020-45-2020-50","text_gpt3_token_len":275,"char_repetition_ratio":0.32546705,"word_repetition_ratio":0.0,"special_character_ratio":0.24975514,"punctuation_ratio":0.011904762,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.960739,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,null,null,null,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-28T11:15:24Z\",\"WARC-Record-ID\":\"<urn:uuid:76bd6ad1-d9c7-4f4c-9c3c-8b5cd85fc743>\",\"Content-Length\":\"274061\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:51972f84-2bda-49aa-9cde-ffbfe4dfb6b0>\",\"WARC-Concurrent-To\":\"<urn:uuid:68367d7a-a1cc-4d16-93aa-05e045610f4d>\",\"WARC-IP-Address\":\"35.154.185.3\",\"WARC-Target-URI\":\"https://www.schoolconnects.in/studymaterials/cbse-ncert-6th-class-science-motion-and-measurements-10-chapter\",\"WARC-Payload-Digest\":\"sha1:EULLDQTAOYOTMKCQDOTGU5T66HE464X4\",\"WARC-Block-Digest\":\"sha1:GZWB25WTJFRAVISZJ4W2QBRQIVBDYRLO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107898499.49_warc_CC-MAIN-20201028103215-20201028133215-00500.warc.gz\"}"}
https://radiant-rstats.github.io/docs/basics/cross_tabs.html
[ "Cross-tab analysis is used to evaluate if categorical variables are associated. This tool is also known as chi-square or contingency table analysis\n\n### Example\n\nThe data are from a sample of 580 newspaper readers that indicated (1) which newspaper they read most frequently (USA today or Wall Street Journal) and (2) their level of income (Low income vs. High income). The data has three variables: A respondent identifier (id), respondent income (High or Low), and the primary newspaper the respondent reads (USA today or Wall Street Journal).\n\nWe will examine if there is a relationship between income level and choice of newspaper. In particular, we test the following null and alternative hypotheses:\n\n• H0: There is no relationship between income level and newspaper choice\n• Ha: There is a relationship between income level and newspaper choice\n\nIf the null-hypothesis is rejected we can investigate which cell(s) contribute to the hypothesized association. In Radiant (Basics > Cross-tab) choose Income as the first factor and Newspaper as the second factor. First, compare the observed and expected frequencies. The expected frequencies are calculated using H0 (i.e., no association) as (Row total x Column Total) / Overall Total.", null, "The (Pearson) chi-squared test evaluates if we can reject the null-hypothesis that the two variables are independent. It does so by comparing the observed frequencies (i.e., what we actually see in the data) to the expected frequencies (i.e., what we would expect to see if the two variables were independent). If there are big differences between the table of expected and observed frequencies the chi-square value will be large. The chi-square value for each cell is calculated as (o - e)^2 / e, where o is the observed frequency in a cell and e is the expected frequency in that cell if the null hypothesis holds. These values can be shown by clicking the Chi-squared check box. The overall chi-square value is obtained by summing across all cells, i.e., it is the sum of the values shown in the Contribution to chi-square table.\n\nIn order to determine if the chi-square value can be considered large we first determine the degrees of freedom (df). In particular: df = (# rows - 1) x (# columns - 1). In a 2x2 table, we have (2-1) x (2-1) = 1 df. The output in the Summary tab shows the value of the chi-square statistic, the associated df, and the p.value associated with the test. We also see the contribution from each cells to the overall chi-square statistic.\n\nRemember to check the expected values: All expected frequencies are larger than 5 therefore the p.value for the chi-square statistic is unlikely to be biased. As usual we reject the null-hypothesis when the p.value is smaller 0.05. Since our p.value is very small (< .001) we can reject the null-hypothesis (i.e., the data suggest there is an association between newspaper readership and income).\n\nWe can use the provided p.value associated with the Chi-squared value of 187.783 to evaluate the null hypothesis. However, we can also calculate the critical Chi-squared value using the probability calculator. As we can see from the output below that value is 3.841 if we choose a 95% confidence level. Because the calculated Chi-square value is larger than the critical value (187.783 > 3.841) we reject null hypothesis that Income and Newspaper are independent.", null, "We can also use the probability calculator to determine the p.value associated with the calculated Chi-square value. Consistent with the output from the Cross-tabs > Summary tab this p.value is < .001.", null, "In addition to the numerical output provided in the Summary tab we can evaluate the hypothesis visually (see the Plot tab). We choose the same variables as before. However, we will plot the standardized deviations. This measure is calculated as (o-e)/sqrt(e), i.e., a score of how different the observed and expected frequencies in one cell in our table are. When a cell’s standardized deviation is greater than 1.96 (in absolute value) the cell has a significant deviation from the model of independence (or no association).", null, "In the plot we see that all cells contribute to the association between income and readership as all standardized deviations are larger than 1.96 in absolute value (i.e., the bars extend beyond the outer dotted line in the plot).\n\nIn other words, there seem to be fewer low income respondents that read WSJ and more high income respondents that read WSJ than would be expected if the null hypothesis of no-association were true. Furthermore, there are more low income respondents that read USA today and fewer high income respondents that read USA Today than would be expected if the null hypothesis of no-association were true.\n\n### Report > Rmd\n\nAdd code to Report > Rmd to (re)create the analysis by clicking the icon on the bottom left of your screen or by pressing ALT-enter on your keyboard.\n\nIf a plot was created it can be customized using ggplot2 commands (e.g., plot(result, check = \"observed\", custom = TRUE) + labs(y = \"Percentage\")). See Data > Visualize for details.\n\n### Technical note\n\nWhen one or more expected values are small (e.g., 5 or less) the p.value for the Chi-squared test is calculated using simulation methods. If some cells have an expected count below 1 it may be necessary to collapse rows and/or columns.\n\n### R-functions\n\nFor an overview of related R-functions used by Radiant to evaluate associations between categorical variables see Basics > Tables\n\nThe key function from the stats package used in the cross_tabs tool is chisq.test.\n\n### Video Tutorials\n\nCopy-and-paste the full command below into the RStudio console (i.e., the bottom-left window) and press return to gain access to all materials used in the hypothesis testing module of the Radiant Tutorial Series:\n\nusethis::use_course(\"https://www.dropbox.com/sh/0xvhyolgcvox685/AADSppNSIocrJS-BqZXhD1Kna?dl=1\")\n\nCross-tabs Hypothesis Test\n\n• This video demonstrates how to investigate associations between two categorical variables by a cross-tabs hypothesis test\n• Topics List:\n• Setup a hypothesis test for cross-tabs in Radiant\n• Explain how observed, expected and contribution to chi-squared tables are constructed\n• Use the p.value and critical value to evaluate the hypothesis test\n© Vincent Nijs (2019)", null, "" ]
[ null, "https://radiant-rstats.github.io/docs/basics/figures_basics/cross_tabs_summary.png", null, "https://radiant-rstats.github.io/docs/basics/figures_basics/compare_props_prob_calc.png", null, "https://radiant-rstats.github.io/docs/basics/figures_basics/cross_tabs_chi_pvalue.png", null, "https://radiant-rstats.github.io/docs/basics/figures_basics/cross_tabs_plot.png", null, "https://radiant-rstats.github.io/docs/images/by-nc-sa.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9023143,"math_prob":0.95120335,"size":5656,"snap":"2020-34-2020-40","text_gpt3_token_len":1235,"char_repetition_ratio":0.13446568,"word_repetition_ratio":0.032715376,"special_character_ratio":0.22047383,"punctuation_ratio":0.10795975,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9932367,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,4,null,null,null,4,null,4,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-10T18:44:46Z\",\"WARC-Record-ID\":\"<urn:uuid:e48dffbb-175e-4b24-b685-9e127d1838a0>\",\"Content-Length\":\"22808\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ab82c3a3-68a7-47cb-b964-987441283a32>\",\"WARC-Concurrent-To\":\"<urn:uuid:5e6dd0c3-4b46-4b82-a9e2-253cfa5e7796>\",\"WARC-IP-Address\":\"185.199.111.153\",\"WARC-Target-URI\":\"https://radiant-rstats.github.io/docs/basics/cross_tabs.html\",\"WARC-Payload-Digest\":\"sha1:FOEUY7CPMEFGU4ZWIBUBP3E4FKJN4R6Z\",\"WARC-Block-Digest\":\"sha1:XGUI6WA57XOCITELS7G3P3ZUZHSEZJ6M\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439737168.97_warc_CC-MAIN-20200810175614-20200810205614-00545.warc.gz\"}"}
https://discourse.processing.org/t/translating-syntax-shorthand-for-beginners/24995
[ "# Translating Syntax Shorthand for Beginners?\n\nHello Team Forum,\n\nI found this cool sketch but it is reduced to programming shorthand I have no experience with. I keep trying to format in what I am used but keep failing.\n\n``````t=0,draw=_=>{t++||createCanvas(w=720,w)+strokeWeight(5)\nbackground(w,30)\nfor(i=99;i--;){x=(random(40)|0)*18;y=(random(40)|0)*18\nfor(j=40;j--;){d=((noise(x/w,y/w+t/w,dist(x,y,w/2,w/2)/w)*50|0)%4)*TAU/4\npoint(x+=cos(d)*6,y+=sin(d)*6)}}}\n\n/*\nHelp, what is the translation to beginner's syntax?\n\nt=0;\n\nfunction setup(){\n\n}\n\nfunction draw(){\n\n}\n*/\n\n``````\n\nHope this form is the right amount of expansion:\n\n``````let t = 0;\nlet w = 720;\n\nfunction setup() {\ncreateCanvas(w, w);\nstrokeWeight(5);\n}\n\nfunction draw() {\nt++;\nbackground(w, 30);\n\nfor (let i = 99; i > 0; i--) {\n\nlet x = int(random(40)) * 18;\nlet y = int(random(40)) * 18;\n\nfor (let j = 40; j > 0; j--) {\nn = noise(x / w, y / w + t / w, dist(x, y, w / 2, w / 2) / w);\nn *= 50;\nn = int(n);\nd = n % 4 * TAU / 4;\nx += cos(d) * 6;\ny += sin(d) * 6;\npoint(x, y);\n}\n}\n}\n``````\n2 Likes\n3 Likes\n\nThe list is very nice!\n\nBut I have to say, with the initial code example I cringe. I think it’s written to confuse.\n\nI am friend of explicit, longer code. I go for readability, for maintainability.\n\nNot for shortness. If someone (or myself in 6 months) has to maintain my code, it should be readable.\n\nThat’s common knowledge, see https://www.toptal.com/software/six-commandments-of-good-code\n\nChrisir\n\n3 Likes\n\nAbsolutely, I share the same opinion. (gotoloop probably not)\nBut in the case of necessity of translation, it’s handy.\n\n3 Likes\n\nWow @tabreturn I wasn’t even close to deciphering this! Thank you for unpacking this. Much appreciated.\n\n1 Like\n\n@noel\nThis is really helpful too! I didn’t know what I was looking at!\n\n1 Like\n\nDefinitely better for beginners!\n\n2 Likes\n\nBut in some way for us beginners it’s fun.", null, "``````y=0,f=(x,y,c=0)=>x*x+y*y>4?c:f(3/4-sin(x)*sin(y)*3,abs(y*y-x*x),c+4)\ndraw=_=>{y++||noStroke(createCanvas(w=960,h=540,WEBGL))+texture(T=createGraphics(w,h))\nclear(rotate(PI/2)*rotateY(y/120));sphere(430)\nif(y<h)for(x=w;x--;){T.stroke(f(x/w,y/w)).point(x,y)}}\n``````\n2 Likes\n\nThat’s lovely - one day I will get there", null, "1 Like\n\nI have read the list in the post above, but I am not able to translate the last sketch.\n\nIt is written like that intentionally.\n\nThere are others here:\n\n#つぶやきProcessing\n\n`:)`\n\n1 Like\n\nHello,\n\nCheck out this topic:\nWhat does the following syntax do? =_=>\n\nTiny Tips 'n Tricks:\nhttps://www.openprocessing.org/sketch/683375/\n\n`:)`\n\n3 Likes\n\nHere’s an expanded version of the last listing, @J_Silva\n\n``````let y = 0;\nlet c = 0;\nlet w = 960;\nlet h = 540;\nlet T;\n\nfunction f(x, y, c = 0) {\n\nif (x * x + y * y > 4) {\nreturn c;\n}\n\nlet xarg = 3 / 4 - sin(x) * sin(y) * 3;\nlet yarg = abs(y * y - x * x);\nreturn f(xarg, yarg, c + 4);\n}\n\nfunction setup() {\ncreateCanvas(w, h, WEBGL);\nT = createGraphics(w, h);\ntexture(T);\nnoStroke();\n}\n\nfunction draw() {\ny++;\nclear();\nrotate(PI / 2);\nrotateY(y / 120);\nsphere(430);\n\nif (y < h) {\n\nfor (let x = w; x > 0; x--) {\nT.stroke(f(x / w, y / w));\nT.point(x, y);\n}\n}\n}\n``````\n2 Likes\n\nI do not recommend shorthand syntax, but like @glv said, “It seems to be on purpose”. In fact, I believe that people on OpenProcessing use it, to make it more difficult for someone to fork their sketch. I would not use setup() within draw(), because in the first place it does not give less code, and second the sketch can slow down substantially. I have made another sketch which I think is easier to understand and to translate. Note the dots used to write several functions on one line.\nBut that being said, it still can be fun to write a nice sketch with as little code as possible.\n\n``````x=y=z=0;setup=_=>{createCanvas(windowWidth,windowHeight,WEBGL)}\ndraw=_=>{background(0).noFill().stroke(255).rotateX(x).rotateZ(z).sphere(650)\nfor(i=0;i<12;i+=4){fill(0).stroke(255).rotateX(x+=.0003)\nrotateZ(z+=.0007).rotateY(y+=.001).box(1200,200,200)}}\n``````\n4 Likes\n\nI think this shorthand stuff is great for microblogging platforms. It’s a fun challenge trying to cram your program into a single tweet/micropost using code that prioritises economy over ‘best practice’.\n\nFor some more inspiration, you can check out #tweetcart, #tweetjam, and #TweetTweetJam, which are PICO-8 (Lua) games and demos that fit into a tweet or two.\n\n5 Likes\n\n@mnoble Look at what you started! `:)`\n\nThis topic inspired me to make the maze in P5.js.\n\nProcessing version:\n\nAnd P5.js version of this:\n\n``````// https://10print.org/\n// P5.js version of:\n// 10 PRINT CHR\\$(205.5+RND(1)); : GOTO 10\n\nn=25\nsetup=_=>{createCanvas(w=500,w)\nx=y=0\nwhile(y<w){r=int(random(2))*n\nline(x+r,y,x+n-r,y+n)\nx+=n\nif(x>w){y+=n;x=0}}}\n``````\n\nI removed the semicolons and used a line feed instead; each counts as a character.\nThe n=25 did not make it smaller (still the same size) but left it in there for this example.\n\n`:)`\n\n3 Likes\n\nThank you @tabreturn for the translation, and everyone else for the help.\n\nI had not heard of that yet. Fun stuff. Its free competitor TIC-80 allows using JS!\nI thought “That’s odd” because I expected JS much slower in graphs-drawing because it takes all numbers as a 64-bit floating-point format. I suspect that because JS introduced typed arrays with all distinct numeric types; I believe for better raw data performance.\nCurious about that I compared a number-crunching mandelbrot sketch with java, and I must say it’s as fast. (or maybe slow). So P5.js is really a good choice because you can embed it everywhere. Even in Google’s free Blogger. (I just tested that)\n\nClick to zoom, and type Home End to change colors.\n\n2 Likes\n\nThanks for that link. I followed it right away! I was surprised that in the type of syntax compare list P.java is still winning. 45 to 33 I love those small sketches. It also is proof that knowing to code is not enough; you also need imagination. I admit that I often throw some geometric functions into draw(), just to see the outcome. But In the same twitter I found such a nice simple but at the same time elegant sketch from @Hau_kun that clearly shows that he first imagined the sketch, and then coded it. It’s in java and just as shorthand training, I converted it to P5.js. (the dirty way, throwing setup in draw)\n\n``````x=y=t=s=p=0;f=1;draw=_=>{createCanvas(w=400,w).strokeWeight(3)\nt+=0.01;background(0);for(y=0;y<720;y+=90){f=-f;for(x=-9;x<729;x+=9){\nstroke((s=sq(sin((x+y)*.05*noise(y,x*.001+t*.05)*.5+t*f)))*999);\nline(x-9,y+(p=(pow(1-s,8))*90),x+9,y+p+25);}}}\n``````\n3 Likes" ]
[ null, "https://emoji.discourse-cdn.com/google_classic/innocent.png", null, "https://emoji.discourse-cdn.com/google_classic/slight_smile.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.886604,"math_prob":0.9460026,"size":3568,"snap":"2022-27-2022-33","text_gpt3_token_len":1043,"char_repetition_ratio":0.086980924,"word_repetition_ratio":0.0030674846,"special_character_ratio":0.334361,"punctuation_ratio":0.15574783,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9864903,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-01T13:29:34Z\",\"WARC-Record-ID\":\"<urn:uuid:cc96b0c8-d245-4ce1-a2be-e81ded55bd61>\",\"Content-Length\":\"72041\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:998b258a-171a-4337-bab6-8f17f93866ac>\",\"WARC-Concurrent-To\":\"<urn:uuid:36bb81e6-51b2-4140-bc3a-0d28825b0a8b>\",\"WARC-IP-Address\":\"64.62.250.111\",\"WARC-Target-URI\":\"https://discourse.processing.org/t/translating-syntax-shorthand-for-beginners/24995\",\"WARC-Payload-Digest\":\"sha1:SMGNHXV6LQBRIPKEIOT4NJUDOUTVUEHA\",\"WARC-Block-Digest\":\"sha1:673VNULY66ELGWQFL7AI63HKYYP4BMNA\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103941562.52_warc_CC-MAIN-20220701125452-20220701155452-00739.warc.gz\"}"}
http://www.w3processing.com/index.php?subMenuLoad=cpp/function/Overloading.php
[ "• In C++ you can create several functions with the same name. We says that these functions overload each other.\n• C++ require that those functions must differ in their parameter list with a different type of parameter, a different number of parameters or both.\nSource code Result\n``````// Demonstrates function polymorphism\n#include <iostream>\n// two function, getVolume, that overload each other\nint getVolume(int length, int width , int height );\ndouble getVolume(double length, double width );\n\nint main() {\nint length = 100;\nint width = 50;\nint height = 2;\nint volume;\n// The result of this should be 100*50*2=10000\nvolume = getVolume(length, width, height);\nstd::cout << \"1.volume equals:\" << volume << \"\\n\";\ndouble len = 120.2;\ndouble wid = 54.2;\ndouble vol;\n// The result of this should be 120.2*54.2*1= 6514.84\nvol = getVolume(len, wid);\nstd::cout << \"2.volume equals:\" << vol << \"\\n\";\nreturn 0;\n}\n// Implementation of the function\nint getVolume(int length, int width, int height) {\nreturn (length * width * height);\n}\ndouble getVolume(double length, double width) {\nreturn (length * width * 1.0);\n}``````\n``````1.volume equals: 10000\n2.volume equals: 6514.84``````" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.6678716,"math_prob":0.99643064,"size":1786,"snap":"2019-51-2020-05","text_gpt3_token_len":436,"char_repetition_ratio":0.14590348,"word_repetition_ratio":0.034965035,"special_character_ratio":0.2788354,"punctuation_ratio":0.17784257,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9975577,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-18T22:42:57Z\",\"WARC-Record-ID\":\"<urn:uuid:dff1f9ba-6ea7-405b-9a97-8ff5fc135b51>\",\"Content-Length\":\"48085\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ade8bff8-e82a-4f67-887d-6a1c04424f87>\",\"WARC-Concurrent-To\":\"<urn:uuid:e6a4b7bf-7bbe-4f12-913a-4053eaa9dc5d>\",\"WARC-IP-Address\":\"46.30.213.219\",\"WARC-Target-URI\":\"http://www.w3processing.com/index.php?subMenuLoad=cpp/function/Overloading.php\",\"WARC-Payload-Digest\":\"sha1:55KH3QH3LGEZ67RKADTF2T6XD2EZVPYI\",\"WARC-Block-Digest\":\"sha1:TFJOWNUEC2WJCMCHPST7UADDXXRQ6JSJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579250593994.14_warc_CC-MAIN-20200118221909-20200119005909-00359.warc.gz\"}"}
https://cavmaths.wordpress.com/2019/07/08/interesting-angle-puzzle/?shared=email&msg=fail
[ "Home > Maths > Interesting angle puzzle\n\n## Interesting angle puzzle\n\nHere is a nice little puzzle that has appeared from Ed Southall (@solvemymaths) I think it is a good little puzzle to get your brain going and one that should be usable in a secondary classroom as the maths is not particularly advanced. It would probably be a good one to get some students problem solving and I may give it to some students this week.", null, "My approach:\n\nI looked at this and assumed it is all regular. I labelled the three important points ABC and my first instinct was to draw a line from A to C to make a triangle. I decided not to do this, however, when I noticed that If I drew it to the point I have labelled B then I could get a nice isosceles trapezium:", null, "From here it was just a case of using my knowledge of angles in quadrilaterals, other polygons, round a point etc to find the reflex angle required.", null, "First I used knowledge of regular pentagons to see that angle AEF must be 162.", null, "", null, "Then I used my knowledge of isosceles trapeziums and the knowledge that AEFB is an isosceles trapezium to work out that BAE and ABF are both 18.", null, "Then I considered ABCD, again I know its an isosceles trapezium. I also know that ADGE is a square therefore i can work out that DCB and ABC both equal 72.", null, "This means the reflex angle reuired must be 288.", null, "I’ve been looking at it further, and I’m not sure I can see any other ways that would work. But if you spot a different way then I would love to hear it.\n\nCategories: Maths" ]
[ null, "https://cavmaths.files.wordpress.com/2019/07/20190708_1405526348217002597462956.png", null, "https://cavmaths.files.wordpress.com/2019/07/20190708_1408491266217107061618379.jpg", null, "https://cavmaths.files.wordpress.com/2019/07/20190708_1412067997461502541299144.jpg", null, "https://cavmaths.files.wordpress.com/2019/07/20190708_1412233694902285442255479.jpg", null, "https://cavmaths.files.wordpress.com/2019/07/20190708_1412391894137300946138880.jpg", null, "https://cavmaths.files.wordpress.com/2019/07/20190708_1412564441852885476531820.jpg", null, "https://cavmaths.files.wordpress.com/2019/07/20190708_141334621452812734559307.jpg", null, "https://cavmaths.files.wordpress.com/2019/07/20190708_1413501817019837726633696.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9662375,"math_prob":0.5672464,"size":1428,"snap":"2020-24-2020-29","text_gpt3_token_len":350,"char_repetition_ratio":0.11025281,"word_repetition_ratio":0.0,"special_character_ratio":0.21778712,"punctuation_ratio":0.06688963,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96709174,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"im_url_duplicate_count":[null,3,null,3,null,3,null,3,null,3,null,3,null,3,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-05T01:59:24Z\",\"WARC-Record-ID\":\"<urn:uuid:4198266c-cb0b-4e20-84fb-9af8c99c3d59>\",\"Content-Length\":\"93054\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:61092462-5b1d-4e83-b467-b70b582a48d2>\",\"WARC-Concurrent-To\":\"<urn:uuid:a19f92d9-fecb-41e6-b9ba-1ef221ca7396>\",\"WARC-IP-Address\":\"192.0.78.12\",\"WARC-Target-URI\":\"https://cavmaths.wordpress.com/2019/07/08/interesting-angle-puzzle/?shared=email&msg=fail\",\"WARC-Payload-Digest\":\"sha1:32N66J2KGRHAREY4UFTZLF223GYTGQ2U\",\"WARC-Block-Digest\":\"sha1:HPVYFFGGUEIAGB5AQBFVT6EQPEDS6G4Y\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590348492427.71_warc_CC-MAIN-20200605014501-20200605044501-00277.warc.gz\"}"}
https://www.colorhexa.com/3d073d
[ "# #3d073d Color Information\n\nIn a RGB color space, hex #3d073d is composed of 23.9% red, 2.7% green and 23.9% blue. Whereas in a CMYK color space, it is composed of 0% cyan, 88.5% magenta, 0% yellow and 76.1% black. It has a hue angle of 300 degrees, a saturation of 79.4% and a lightness of 13.3%. #3d073d color hex could be obtained by blending #7a0e7a with #000000. Closest websafe color is: #330033.\n\n• R 24\n• G 3\n• B 24\nRGB color chart\n• C 0\n• M 89\n• Y 0\n• K 76\nCMYK color chart\n\n#3d073d color description : Very dark magenta.\n\n# #3d073d Color Conversion\n\nThe hexadecimal color #3d073d has RGB values of R:61, G:7, B:61 and CMYK values of C:0, M:0.89, Y:0, K:0.76. Its decimal value is 3999549.\n\nHex triplet RGB Decimal 3d073d `#3d073d` 61, 7, 61 `rgb(61,7,61)` 23.9, 2.7, 23.9 `rgb(23.9%,2.7%,23.9%)` 0, 89, 0, 76 300°, 79.4, 13.3 `hsl(300,79.4%,13.3%)` 300°, 88.5, 23.9 330033 `#330033`\nCIE-LAB 12.488, 32.411, -20.29 2.843, 1.481, 4.551 0.32, 0.167, 1.481 12.488, 38.238, 327.952 12.488, 15.566, -20.129 12.17, 20.395, -13.651 00111101, 00000111, 00111101\n\n# Color Schemes with #3d073d\n\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #073d07\n``#073d07` `rgb(7,61,7)``\nComplementary Color\n• #22073d\n``#22073d` `rgb(34,7,61)``\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #3d0722\n``#3d0722` `rgb(61,7,34)``\nAnalogous Color\n• #073d22\n``#073d22` `rgb(7,61,34)``\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #223d07\n``#223d07` `rgb(34,61,7)``\nSplit Complementary Color\n• #073d3d\n``#073d3d` `rgb(7,61,61)``\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #3d3d07\n``#3d3d07` `rgb(61,61,7)``\n• #07073d\n``#07073d` `rgb(7,7,61)``\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #3d3d07\n``#3d3d07` `rgb(61,61,7)``\n• #073d07\n``#073d07` `rgb(7,61,7)``\n• #000000\n``#000000` `rgb(0,0,0)``\n• #0f020f\n``#0f020f` `rgb(15,2,15)``\n• #260426\n``#260426` `rgb(38,4,38)``\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #540a54\n``#540a54` `rgb(84,10,84)``\n• #6b0c6b\n``#6b0c6b` `rgb(107,12,107)``\n• #820f82\n``#820f82` `rgb(130,15,130)``\nMonochromatic Color\n\n# Alternatives to #3d073d\n\nBelow, you can see some colors close to #3d073d. Having a set of related colors can be useful if you need an inspirational alternative to your original color choice.\n\n• #30073d\n``#30073d` `rgb(48,7,61)``\n• #34073d\n``#34073d` `rgb(52,7,61)``\n• #39073d\n``#39073d` `rgb(57,7,61)``\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #3d0739\n``#3d0739` `rgb(61,7,57)``\n• #3d0734\n``#3d0734` `rgb(61,7,52)``\n• #3d0730\n``#3d0730` `rgb(61,7,48)``\nSimilar Colors\n\n# #3d073d Preview\n\nThis text has a font color of #3d073d.\n\n``<span style=\"color:#3d073d;\">Text here</span>``\n#3d073d background color\n\nThis paragraph has a background color of #3d073d.\n\n``<p style=\"background-color:#3d073d;\">Content here</p>``\n#3d073d border color\n\nThis element has a border color of #3d073d.\n\n``<div style=\"border:1px solid #3d073d;\">Content here</div>``\nCSS codes\n``.text {color:#3d073d;}``\n``.background {background-color:#3d073d;}``\n``.border {border:1px solid #3d073d;}``\n\n# Shades and Tints of #3d073d\n\nA shade is achieved by adding black to any pure hue, while a tint is created by mixing white to any pure color. In this example, #080108 is the darkest color, while #fef6fe is the lightest one.\n\n• #080108\n``#080108` `rgb(8,1,8)``\n• #1a031a\n``#1a031a` `rgb(26,3,26)``\n• #2b052b\n``#2b052b` `rgb(43,5,43)``\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #4f094f\n``#4f094f` `rgb(79,9,79)``\n• #600b60\n``#600b60` `rgb(96,11,96)``\n• #720d72\n``#720d72` `rgb(114,13,114)``\n• #830f83\n``#830f83` `rgb(131,15,131)``\n• #951195\n``#951195` `rgb(149,17,149)``\n• #a713a7\n``#a713a7` `rgb(167,19,167)``\n• #b815b8\n``#b815b8` `rgb(184,21,184)``\n• #ca17ca\n``#ca17ca` `rgb(202,23,202)``\n• #db19db\n``#db19db` `rgb(219,25,219)``\n• #e622e6\n``#e622e6` `rgb(230,34,230)``\n• #e834e8\n``#e834e8` `rgb(232,52,232)``\n• #ea46ea\n``#ea46ea` `rgb(234,70,234)``\n• #ec57ec\n``#ec57ec` `rgb(236,87,236)``\n• #ee69ee\n``#ee69ee` `rgb(238,105,238)``\n• #f07af0\n``#f07af0` `rgb(240,122,240)``\n• #f28cf2\n``#f28cf2` `rgb(242,140,242)``\n• #f49ef4\n``#f49ef4` `rgb(244,158,244)``\n• #f6aff6\n``#f6aff6` `rgb(246,175,246)``\n• #f8c1f8\n``#f8c1f8` `rgb(248,193,248)``\n``#fad2fa` `rgb(250,210,250)``\n• #fce4fc\n``#fce4fc` `rgb(252,228,252)``\n• #fef6fe\n``#fef6fe` `rgb(254,246,254)``\nTint Color Variation\n\n# Tones of #3d073d\n\nA tone is produced by adding gray to any pure hue. In this case, #232123 is the less saturated color, while #420242 is the most saturated one.\n\n• #232123\n``#232123` `rgb(35,33,35)``\n• #251f25\n``#251f25` `rgb(37,31,37)``\n• #281c28\n``#281c28` `rgb(40,28,40)``\n• #2b192b\n``#2b192b` `rgb(43,25,43)``\n• #2d172d\n``#2d172d` `rgb(45,23,45)``\n• #301430\n``#301430` `rgb(48,20,48)``\n• #331133\n``#331133` `rgb(51,17,51)``\n• #350f35\n``#350f35` `rgb(53,15,53)``\n• #380c38\n``#380c38` `rgb(56,12,56)``\n• #3a0a3a\n``#3a0a3a` `rgb(58,10,58)``\n• #3d073d\n``#3d073d` `rgb(61,7,61)``\n• #400440\n``#400440` `rgb(64,4,64)``\n• #420242\n``#420242` `rgb(66,2,66)``\nTone Color Variation\n\n# Color Blindness Simulator\n\nBelow, you can see how #3d073d is perceived by people affected by a color vision deficiency. This can be useful if you need to ensure your color combinations are accessible to color-blind users.\n\nMonochromacy\n• Achromatopsia 0.005% of the population\n• Atypical Achromatopsia 0.001% of the population\nDichromacy\n• Protanopia 1% of men\n• Deuteranopia 1% of men\n• Tritanopia 0.001% of the population\nTrichromacy\n• Protanomaly 1% of men, 0.01% of women\n• Deuteranomaly 6% of men, 0.4% of women\n• Tritanomaly 0.01% of the population" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5681625,"math_prob":0.7420511,"size":3654,"snap":"2021-04-2021-17","text_gpt3_token_len":1632,"char_repetition_ratio":0.12520547,"word_repetition_ratio":0.011090573,"special_character_ratio":0.5547345,"punctuation_ratio":0.23430493,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9889481,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-16T00:35:35Z\",\"WARC-Record-ID\":\"<urn:uuid:8b13e04a-172b-440f-9717-3a1922394b68>\",\"Content-Length\":\"36173\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9e9c636a-1353-44eb-9a1c-8ebec8f2d580>\",\"WARC-Concurrent-To\":\"<urn:uuid:f4fc7235-597b-41d0-a68f-cab485bf1705>\",\"WARC-IP-Address\":\"178.32.117.56\",\"WARC-Target-URI\":\"https://www.colorhexa.com/3d073d\",\"WARC-Payload-Digest\":\"sha1:QF4RKKZZBK3FNGOLRBZI76RIKVONFUWC\",\"WARC-Block-Digest\":\"sha1:OTWWD276URQK2SL5JDWU5NWXQDZ7XHWI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703497681.4_warc_CC-MAIN-20210115224908-20210116014908-00739.warc.gz\"}"}
https://ask.sagemath.org/answers/60072/revisions/
[ "# Revision history [back]\n\nSagemath formatting routine is somewhat asinine in radical-involving fraction handling. Contemplate :\n\nsage: 1/sqrt(2)\n1/2*sqrt(2)\n\n\nIt turns out that, in this case, Sage denotes a division by a multiplication :\n\nsage: (1/sqrt(2)).operator()\n<function mul_vararg at 0x7fd16a1949d0>\nsage: (1/sqrt(2)).operands()\n[sqrt(2), 1/2]\n\n\nOn the other hand, if :\n\nsage: (sqrt(x+1)/(x+1)).operator()\n<built-in function pow>\nsage: (sqrt(x+1)/(x+1)).operands()\n[x + 1, -1/2]\n\n\nthe internal representation is different in your initial case :\n\nsage: (sqrt(1-x)/(1-x)).operator()\n<function mul_vararg at 0x7fd16a1949d0>\nsage: (sqrt(1-x)/(1-x)).operands()\n[1/(x - 1), sqrt(-x + 1), -1]\n\n\nAnd; BTW, Sympy's internal representation is different :\n\nsage: (sqrt(1-x)/(1-x))._sympy_().simplify()\n1/sqrt(1 - x)\nsage: (sqrt(1-x)/(1-x))._sympy_().simplify().func\n<class 'sympy.core.power.Pow'>\nsage: (sqrt(1-x)/(1-x))._sympy_().simplify().args\n(1 - x, -1/2)\n\n\nbut this internal representation is lost when reverting to Sage :\n\nsage: (sqrt(1-x)/(1-x))._sympy_()._sage_()\n-sqrt(-x + 1)/(x - 1)\nsage: (sqrt(1-x)/(1-x))._sympy_()._sage_().operator()\n<function mul_vararg at 0x7fd16a1949d0>\nsage: (sqrt(1-x)/(1-x))._sympy_()._sage_().operands()\n[1/(x - 1), sqrt(-x + 1), -1]\n\n\nHTH,\n\nSagemath formatting routine is somewhat asinine in radical-involving fraction handling. handling, due to internal representation of expressions. Contemplate :\n\nsage: 1/sqrt(2)\n1/2*sqrt(2)\n\n\nIt turns out that, in this case, Sage denotes a division by a multiplication :\n\nsage: (1/sqrt(2)).operator()\n<function mul_vararg at 0x7fd16a1949d0>\nsage: (1/sqrt(2)).operands()\n[sqrt(2), 1/2]\n\n\nOn the other hand, if :\n\nsage: (sqrt(x+1)/(x+1)).operator()\n<built-in function pow>\nsage: (sqrt(x+1)/(x+1)).operands()\n[x + 1, -1/2]\n\n\nthe internal representation is different in your initial case :\n\nsage: (sqrt(1-x)/(1-x)).operator()\n<function mul_vararg at 0x7fd16a1949d0>\nsage: (sqrt(1-x)/(1-x)).operands()\n[1/(x - 1), sqrt(-x + 1), -1]\n\n\nAnd; BTW, Sympy's internal representation is different :\n\nsage: (sqrt(1-x)/(1-x))._sympy_().simplify()\n1/sqrt(1 - x)\nsage: (sqrt(1-x)/(1-x))._sympy_().simplify().func\n<class 'sympy.core.power.Pow'>\nsage: (sqrt(1-x)/(1-x))._sympy_().simplify().args\n(1 - x, -1/2)\n\n\nbut this internal representation is lost when reverting to Sage :\n\nsage: (sqrt(1-x)/(1-x))._sympy_()._sage_()\n-sqrt(-x + 1)/(x - 1)\nsage: (sqrt(1-x)/(1-x))._sympy_()._sage_().operator()\n<function mul_vararg at 0x7fd16a1949d0>\nsage: (sqrt(1-x)/(1-x))._sympy_()._sage_().operands()\n[1/(x - 1), sqrt(-x + 1), -1]\n\n\nEDIT : FWIW, the internal representation used by Mathematica is yet another :\n\nsage: mathematica(\"M=Sqrt[1-x]/(1-x)\")\n1/Sqrt[1 - x]\nsage: mathematica(\"Table[M[[u]], {u, Range[0,(Length[M])]}]\")\n{Power, 1 - x, -1/2}\n\n\nHTH," ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.60442144,"math_prob":0.99631035,"size":2851,"snap":"2022-05-2022-21","text_gpt3_token_len":1087,"char_repetition_ratio":0.19845451,"word_repetition_ratio":0.795107,"special_character_ratio":0.41038233,"punctuation_ratio":0.21095008,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9997677,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-20T08:39:43Z\",\"WARC-Record-ID\":\"<urn:uuid:239d43bb-e31f-4005-b106-5cc12beff7d2>\",\"Content-Length\":\"18852\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9b43ec0b-6bf5-4e6d-9b61-0e5e2c0ae73a>\",\"WARC-Concurrent-To\":\"<urn:uuid:d3ac09c6-7310-4ea1-927f-1efb7d261bcc>\",\"WARC-IP-Address\":\"194.254.163.53\",\"WARC-Target-URI\":\"https://ask.sagemath.org/answers/60072/revisions/\",\"WARC-Payload-Digest\":\"sha1:LHEIRRUY2FJR2VILIF43WMBQLKRAXGWE\",\"WARC-Block-Digest\":\"sha1:S2PI6W6FY4NW2O2KEDG57FUSRGAOS3OM\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662531762.30_warc_CC-MAIN-20220520061824-20220520091824-00655.warc.gz\"}"}
https://ask.sagemath.org/question/9003/given-a-direction-vector-and-a-point-how-to-draw-a-3d-line/?answer=13617
[ "# Given a direction vector and a point, how to draw a 3d line?", null, "I have a point\n\n(-e^pi, 0, e^pi)\n\n\nand a direction vector\n\ntvec = vector((e^t * cos(t) - e^t * sin(t), e^t * sin(t) + e^t * cos(t), e^t))\n\n\nHow would I draw a 3d line based upon these 2 arguments?\n\nI looked over at the documentation but I couldnt find it.\n\nedit retag close merge delete\n\nSort by » oldest newest most voted\n\nYou can introduce a new parameter s that will parametrize the line. With p=(-e^pi,0,e^pi), the line is then p+s*tvec(t=t0) for some fixed value t0 of the parameter t.\n\nThen, the line can be drawn as follows.\n\nvar('s,t')\np=vector([-exp(pi),0,exp(pi)])\ntvec = vector((e^t * cos(t) - e^t * sin(t), e^t * sin(t) + e^t * cos(t), e^t))\nparametric_plot3d(p+s*tvec(t=pi/2),(s,0,5),thickness=3)\n\nmore" ]
[ null, "https://www.gravatar.com/avatar/3807813ec3a8536fd55a3897e0ab0a21", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.87477833,"math_prob":0.99929696,"size":309,"snap":"2020-10-2020-16","text_gpt3_token_len":107,"char_repetition_ratio":0.12786885,"word_repetition_ratio":0.0,"special_character_ratio":0.33656958,"punctuation_ratio":0.103896104,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999187,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-03-30T17:05:57Z\",\"WARC-Record-ID\":\"<urn:uuid:23ca2399-5eaa-4518-8b0d-4d356fc3f915>\",\"Content-Length\":\"53778\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d7fcedae-f6e2-49c9-962c-06f8d123b74d>\",\"WARC-Concurrent-To\":\"<urn:uuid:14745e30-a0aa-4177-8486-604aaf7784f5>\",\"WARC-IP-Address\":\"140.254.118.68\",\"WARC-Target-URI\":\"https://ask.sagemath.org/question/9003/given-a-direction-vector-and-a-point-how-to-draw-a-3d-line/?answer=13617\",\"WARC-Payload-Digest\":\"sha1:U6BHXMSLAMDQA76X5BSLZ3DAGXEXBIFL\",\"WARC-Block-Digest\":\"sha1:US5LFIV63WWJKCTGPY2NY6MIN4I2EGFT\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585370497171.9_warc_CC-MAIN-20200330150913-20200330180913-00168.warc.gz\"}"}
http://dauns01.math.tulane.edu/~cortez/Prints/diffuse.html
[ "Convergence of High-order Deterministic Particle Methods for the Convection-diffusion Equation\n(R. Cortez)\n\n#### Abstract\n\nA convergence proof of three high-order deterministic particle methods for the convection-diffusion equation is presented. The methods are based on discretizations of an integro-differential equation in which an integral operator approximates the diffusion operator. The methods differ in the discretization of this operator. The conditions for convergence imposed on the kernel that defines the integral operator include moment conditions and a condition on the kernel's Fourier transform. Explicit formulas for kernels which satisfy these conditions to arbitrary order are presented.\n\nComm. Pure Appl. Math., 50 (1997), pp. 1235-1260.\n\nLaTeX Bibliography:\n```@article{Cortez1997,\nauthor = {Ricardo Cortez},\ntitle = {Convergence of high-order deterministic particle\nmethods for the convection-diffusion equation},\njournal = {Comm. Pure Appl. Math.},\nvolume = {50},\nnumber = {L},\nyear = {1997},\npages = {1235--1260}\n}\n```\n\nBack to:     Papers and Preprints   |   R. Cortez CV" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.831472,"math_prob":0.9763208,"size":892,"snap":"2021-04-2021-17","text_gpt3_token_len":194,"char_repetition_ratio":0.11261261,"word_repetition_ratio":0.05,"special_character_ratio":0.23766816,"punctuation_ratio":0.15068494,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9728485,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-17T08:58:11Z\",\"WARC-Record-ID\":\"<urn:uuid:09b97870-00cb-4f0d-81e8-233de49ee15c>\",\"Content-Length\":\"2250\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5e932244-b8bd-4565-aa95-8d21081877d5>\",\"WARC-Concurrent-To\":\"<urn:uuid:3d915dea-f4df-409d-9c07-bb4d5a4aa54a>\",\"WARC-IP-Address\":\"129.81.170.6\",\"WARC-Target-URI\":\"http://dauns01.math.tulane.edu/~cortez/Prints/diffuse.html\",\"WARC-Payload-Digest\":\"sha1:QXYZOXLAEJ445F5GKIUF4SFF7CXTDPRB\",\"WARC-Block-Digest\":\"sha1:SUMQYJTIQ2I2HYJD5RU7B4C7IDFA3GCE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038118762.49_warc_CC-MAIN-20210417071833-20210417101833-00349.warc.gz\"}"}
https://www.jiskha.com/similar?question=Short+answer+find+the+quotient+6x%5E3-x%5E2-7x-9+------------+2x%2B3&page=650
[ "# Short answer find the quotient 6x^3-x^2-7x-9 ------------ 2x+3\n\n143,010 questions, page 650\n1. ## math\n\n346 mi on 22 gal find each unit rate round to the nearest hundred if necessary\n\nasked by Nichole on November 30, 2015\n2. ## CALCULUS\n\nFind the x-coordinate of the absolute minimum of f(x) = x^3 - x^2 - x +1 on the interval [-2, 2] The function f(x) = x^3 - 2x^2 is increasing on which of the following intervals? a)x4/3 only 0\n\nasked by JIM on January 26, 2009\n3. ## math\n\nCan somebody PLEASE help me understand how to find the domain of a function. I have an F in algebra 3 and just got a 50% on my math quiz. I'm desperate!\n\nasked by Jennifer on March 9, 2010\n4. ## calculus\n\nFind the area of the region bounded by the graph of y^3=x^3 and the chord joining the points (-1, 1) and (8,4)\n\nasked by Tiffany on March 11, 2012\n5. ## Physics\n\nFind the velocity of microwaves having wavelength of 0.75m and frequency 2.75X10^10hz\n\nasked by +++++Tasha+++ on March 25, 2012\n6. ## Science\n\nHow can i find the observed volume? lets say I'm using a 50 ml beaker and I fill it up with 35 ml? would it be 35ml or 50ml?\n\nasked by Boboruto on September 18, 2018\n7. ## Calculus\n\nFind the volume of the solid formed by rotating the region enclosed by y=e^(5x)+(3), y=0, x=0, x=0.8 about the x-axis.\n\nasked by Ideedurmahm on May 9, 2010\n8. ## physics\n\nif the resultant of 2 equal force inclint to each other at 60° is 8root3N. Find the component forces?\n\nasked by amal. on September 2, 2014\n9. ## Math\n\nFind the volume of the rectangular prism A) 23in B) 297in C)318in D) 159in\n\nasked by Anon on March 17, 2019\n10. ## Math\n\nGiven a scale factor of 2, find the coordinates for the dilation of the line segment with endpoints (–1, 2) and (3, –3). A. (–2, 4) and (6, 6) B. (2, 4) and (6, 6) C. (–2, 4) and (6, –6) D. (2, –1) and (–3, 3)\n\nasked by Anonymous on October 28, 2018\n11. ## MATHS\n\nThe sum of 18terms of an A.P is 549.given that the common difference is 3. find the 56th term\n\nasked by Anonymous on October 27, 2018\n12. ## Geometry\n\nIn triangle ABC, side a=7, b=6, and c=8. Find the measure of angle B to the nearest degree.\n\nasked by Sue on May 8, 2010\n13. ## maths\n\nfind the sun's altitude when the height of a tower is 3 times of the length of its shadow.\n\nasked by faris on November 29, 2015\n14. ## 9th grade\n\nfind the domain and the range of the relation age of person 65,36,36,29 books to read 42,37,37,17\n\nasked by teri on September 16, 2010\n15. ## math\n\nfind the dimentions of a bose of largest area that can be inscribed in a sphere of radius 1\n\nasked by Asia on March 6, 2016\n16. ## 11th grade math\n\nThe equation Ax^2 + 4y^2 = 16 represents an ellipse. Find all values of A such that its intersection with y = |x| has coordinates (x,y) which are integers.\n\nasked by Andy on December 19, 2010\n17. ## business\n\nim trying to look for do look alike glucose meter affect business. Its obviously yes but its so hard to find on google?\n\nasked by flame on July 3, 2010\n18. ## math\n\nYou mix the letters S, E, M, I, T, R, O, P, I, C, A, and L thoroughly. Without looking, you draw one letter. Find the probability that you select a vowel.\n\nasked by ashleydawolfy on February 8, 2016\n19. ## Probability\n\nA pair of fair dice is tossed once. Find the probability a sum of 5 or 3 appears.\n\nasked by Amanda on May 2, 2012\n20. ## calculus\n\nFind the volume of the solid generated by revolving about line x = -4 the region bounded by x = y - y^2 and x = y^2 - 3\n\nasked by Ryan on November 9, 2011\n21. ## History\n\nHow did the Romanov dynasty increase Russia's power? I have been researching for almost an hour and I can't find anything ! any help?\n\nasked by Conections academy kid on February 27, 2019\n22. ## critical maths problem need help!!!\n\nshow that any fuction y(t)=acosx+bsinx ,satisfied the differential equation y^\"+wy=0 and also find the value of (a) and (b)\n\nasked by edward on August 23, 2015\n23. ## calculus please help!\n\nFind maxima and minima and points of inflection. f(x) = 2x^3 - 3x^2 -36x +100 on the interval [-6,4]\n\nasked by maura on May 13, 2014\n24. ## Maths\n\non a graph of 2x^2 -7+5 use equations to find the vertex point ,roots and asis of symmetry\n\nasked by Anonymous on August 5, 2009\n25. ## Basic Physics\n\nI don't understand how to work this problem out: Find x-component of vector a ⃗ = (7.0m/s 2 , - y-direction) Please help\n\nasked by Katy on July 9, 2014\n26. ## calculus\n\nFind the center of mass of the region bounded by the curve y = x3 - 4x2 +3x ; the x-axis ; x = 0 ; x = 1\n\nasked by Trisha on December 1, 2011\n27. ## Calculus 3\n\nFind an arc length parametrization of the circle in the plane z = 16 with radius 5 and center (5, 5, 16).\n\nasked by EKM on October 2, 2018\n28. ## Math\n\nFind the points at which the relation 3x^2-2xy+y^2=24 has a vertical or horizontal tangent line.\n\nasked by Mary on April 2, 2012\n29. ## com 220\n\nWhere can I find a graph or table that shows when black people was able to vote and the years?\n\nasked by Tracie on March 21, 2010\n30. ## Math\n\nI need some help with my math.. It says is each equation a direct variation? If it is find the constant of variaton. 32. f(x)=-3x 34. y=2x+5 I don't get how to do these.. please help me.\n\nasked by Amy on May 25, 2009\n31. ## factoring polynomials help?\n\n16x^4-1 4x^4+39x^2-10 find the real number solutions of these equations. 3x^4+15x^2-72=0 x^3+2x^2-x=0 Thanks!\n\nasked by Skye on November 6, 2011\n32. ## calculus\n\ni tried to find the derivative of this questions but it was way too hard, and i got it wrong on a test.. i need help y=x4/3 - (sqr.root)5x + 4/x\n\nasked by blue fire on June 16, 2010\n33. ## geometry\n\nin an isosceles triange with base angles at (0,0) and (7,0), how do I find the coordinates of the 3rd angle?\n\nasked by mary on November 27, 2011\n34. ## physics\n\nA force of 2 kg weight acts on a body of mass 4.9 kg .Find the acceleration produced.\n\nasked by anurag on February 23, 2012\n35. ## physics\n\nA force of 2 kg weight acts on a body of mass 4.9 kg .Find the acceleration produced.\n\nasked by anurag on February 23, 2012\n36. ## geometry\n\nPoint E is the centroid of triangle ABC. Find DB. AF = 10x=3 EF = 2x+5 EB = 4x+3 This is for median of triangles.\n\nasked by Anonymous on February 21, 2012\n37. ## Astrology\n\nWhy is it helpful to use the Celestial Sphere to find the position of objects in the night sky. Please help!, Thank you.\n\nasked by Cherie on April 17, 2014\n38. ## social studies\n\nI need help with My Social studies hw!! Im in 6th grade ive read my book and cant find anything!!!!\n\nasked by Brianna on April 7, 2009\n39. ## Math/Business\n\nWhat is the effective interest rate corresponding to 3.75% compounded continuously? How do I find this? I'm thinking about using the formula A = P(1+r/t)^t ??\n\nasked by Alex on November 5, 2018\n40. ## physics\n\nif he travels 7km N 30 degree E and 10km east find the resultant displacement\n\nasked by Julius on August 24, 2018\n41. ## Math\n\nFind the following. Assume the variables can represent any real number. ã((a+7)^2 ) When I tried to do this I got completely lost. ã((a+7)^2 )=„ a+7„  I'm not doing this right am I?\n\nasked by Sabrina on September 24, 2010\n42. ## math\n\nFind the sum of the first 60 terms of the arithmetic sequence whose first term is −15 and whose common difference is 7.\n\nasked by gisela on September 27, 2014\n43. ## Literature\n\nI was here yesterday and I had gotten help but I still need to find similarites between love and infatuation. Thanks for your help. You can use your own thougts or you can give me a link .\n\nasked by Terrie on April 7, 2009\n44. ## math\n\nFind the number to which this geometric series converges: 200-170+144.5...\n\nasked by Nat on May 2, 2012\n45. ## gemetry\n\nIf EF = 9x + 14, FG = 56, and EG = 250, find the value of x. so on a straight line marked E then F in the middle and G on the other end. I am so confused\n\nasked by Ryan on November 28, 2011\n46. ## Inspire international school\n\nSuppose you want to find out about boiling points of different liquids . Describe how you could go about finding the information.\n\nasked by Yazan on October 18, 2015\n47. ## physics\n\nA football is kicked with an initial velocity v=9i+12j. Find the speed in (m/s) of the ball after 2.4s A) 9.2 B) 10.8 C) 12 D) 15\n\nasked by HEMANT on October 18, 2015\n48. ## algebra\n\nFind all real or imaginary solutions to equation. Use the method of your choice. w^2=-225\n\nasked by Jessica on July 20, 2009\n49. ## maths\n\nIf ax²+bx+c=0 and bx²+cx+a=0 have common root a,b,c are non zero real numbers, then find the value of a³+b³+c³/ abc\n\nasked by vaish on July 7, 2014\n50. ## calc\n\n6(4x+3)^5(4)(3x-5)^5+ 5(3x-5)^4(3)(4X+3)^6 common factors: (4x+3)^5 (3x-5)^4 [(4x+3)^5 (3x-5)^4] [24(3x-5) + 15(4x+3)] Take the second term, combine like terms. f(x)=(4x+3)^6(3x-5)^5 Find the derivative. This is what I did so far. =6(4x+3)^5(4)(3x-5)^5+\n\nasked by bobpursley on December 10, 2006\n51. ## math\n\nhow to find two consecutive positive even integers such that the square of first increased by 2 is equal to 3 times the second.\n\nasked by james on March 24, 2019\n52. ## Maths\n\nFind the equation of a line which cuts off intercepts on the axes whose sum and product are 1 and-6, respectively?\n\nasked by Gash on August 27, 2018\n53. ## ---college algebra (average rate of change)---\n\nFind the average rate of change of g(x) = -2x2 + 36x - 142 on the interval from x = -5 to x = 10.\n\nasked by Brianna on November 6, 2011\n54. ## Math\n\n1.) Find the product. Simplify 1/10 × 3/4 A. 15/2 B. 2/15 C.3/40 D. 40/3 2. 4/5 of 40 A. 32 B. 1/32 C. 12 D. 44/5 1/3 of 3 A. 32 B. 1/32 C. 12 D. 44/5 Betty had 1/7 yard of ribbon. She used 1/6 of it. How many yards did she use? A. 42 B. 7/6 C. 1/42 D.\n\nasked by Lilly agel on November 14, 2018\n55. ## Math\n\nOne side of a triangle is 5cm more than the other and 2cm less than the hypotenuse. Find the lengths of the 3 sides?\n\nasked by Jonel on July 12, 2014\n56. ## Math\n\nA ribbon 10 cm 5mm long is to be divided in the ratio 1:4 .Find the length of each part.\n\nasked by Basit on January 11, 2016\n57. ## math\n\nfind the volume of a solid that has 3 by 3 ft 3ft high and 7ft by 5ft long\n\nasked by billy on February 23, 2010\n58. ## MATH\n\nIf the lengths of the sides of a triangle are in the ratio 8:4:5 and its perimeter is 48cm find its area\n\nasked by RIYA on July 18, 2014\n59. ## interest\n\nFind the future value an investment of \\$4720 at 534% simple interest for 9 years.\n\nasked by Anonymous on September 25, 2015\n60. ## Statistics\n\nAt one college, GPA’s are normally distributed with a mean of 2.9 and a standard deviation of 0.6. Find the 70th percentile.\n\nasked by justice on December 2, 2014\n61. ## 8th grade\n\nhow do you solve ths problem?? 78mi on 3gal (find the unit rate)\n\nasked by Mya on April 14, 2010\n62. ## math\n\nWhat is a simple way to find the radical form of a square root? i.e. the number 368\n\nasked by mekka on August 27, 2010\n63. ## Calculus\n\nFind the derivative of the given function at the indicated point. (use f'(a)=lim [f(a+h)-f(a)]/h as h approaches 0) This is what I have so far: [1/(x+h) - 1/2]/h = [2 - (x+h)]/(h(x+h)(2)) = [2-x-h]/(h(x+h)(2)) ...and now I'm stuck. Help? Thx\n\nasked by Momo on February 23, 2010\n64. ## calculus\n\nUse iterated integral to find the area enclosed by r=2sin2(theta). How do i graph this?\n\nasked by Jean on October 15, 2014\n65. ## GEOMETRY\n\nIn a figure ABCDEF is a regular hexagon with DH=1cm and HC=2cm. Find the length of AH\n\nasked by natali on September 23, 2010\n66. ## trig\n\nfind the general solutions to the equations: 1) sec x = -2 2) 2 sin^2 x = 1 3) cos^2 x - 2cos x + 1 = 0\n\nasked by jenny on March 5, 2012\n67. ## Please help me with trig.\n\nOne more problem.. Given sin t= 3/11 and cos t\n\nasked by Jane on January 27, 2016\n68. ## Calculus\n\nFind an equation of the tangent plane (in the variables x, y and z) to the parametric surface r(u,v) =(2u, 3u^2+5v, -4v^2) at the point (0,-10,-16)\n\nasked by Salman on March 4, 2010\n69. ## Calculus\n\nIf f(x)=sin(2x), find f\"(x) A. 2cos(2x) B. -4sin(2x) C. -2sin(2x) D. -4sinx E. None of these Is it B from using chain rules?\n\nasked by Anonymous on November 30, 2014\n70. ## Math\n\nI need some help with solving this problem: Find the solution set for the system of linear inequalities. x – y ≥ 3 x + 2y ≥ 6\n\nasked by TBA on July 20, 2014\n71. ## math\n\nSuppose c and d vary inversely, and d = 2 when c = 17. a. write an equation that models the variation? b. find d when c = 68\n\nasked by johnn on February 21, 2019\n72. ## Implicit Functions\n\nFind the slope of the tangent to the curve at the point specified. x^3+5x^2y+2y^2=4y+11 at (1,2) So far I simplified it to -(3x^2-10y/5x^2+4y-4) which I think then simplifies to -(8/3). What do I do from here....?\n\nasked by George on November 7, 2008\n73. ## science\n\nWhat are the steps to describing a chemical equation? (i couldn't find a way that made sense to me)\n\nasked by emma_natali_ on November 16, 2018\n74. ## Algebra\n\nThe following problem refers to an arithmetic sequence. If a_1=4 and d=1 Find a_n and a_35.\n\nasked by Keonn'a on October 2, 2018\n75. ## Math\n\nFind the length of a side square with an area of 169 in^2 A 338 in B 106 in C 26 in D 13 in\n\nasked by Amélie on February 27, 2019\n76. ## Pre-Cal\n\nIdentify the following features of the graph of g(x) = (3/2)^x+2 A) Asymptotes B) Intercepts C) Increasing or decreasing I really do not know how to find these\n\nasked by Mark on March 21, 2010\n77. ## algebra\n\nTwo negative, even consecutive integers have a product of 224. Find the smaller integer. a) -12 b) -14 c) -16 d) -18\n\nasked by ant on June 3, 2010\n78. ## government\n\nPlease can you help me to find out which courtroom in Wellington has panelling from the Old Bailey. I am thinking the High Court.\n\nasked by Sam on February 23, 2010\n79. ## MATH - Please help!\n\nFind the present value of \\$6000 payable in four years at 16% simple interest Thanks a bunch!\n\nasked by heather on April 1, 2012\n80. ## physics\n\nFind the mass of 0°C ice that 10g of 100 °C steam will completely melt\n\nasked by Kate on February 26, 2014\n81. ## Algebra, can some show me how to set this up\n\nIf f(x) = x − 7, find the following. f(13) f(-6) f(p) Thank you, you guys do not know what it means to me that I have a site that has a wonderful group of people to help us trying to understand.\n\nasked by Mary Ann on June 13, 2014\n82. ## math- plesae help quick\n\nfind the accumulated value of an investment of \\$2000 at 8% compounded semiannually for 9 years. Use formula A=P[1+(r)(n)^nt\n\nasked by tashs on February 18, 2009\n83. ## 7th grade math\n\nFor these two problems, you would need to find the slope and y intercept and then write the equation in equivalent to ax + by + c. y=3x y=0 Please help and explain how to do it. Thank you\n\nasked by saranghae12 on April 1, 2012\n84. ## Algebra Help\n\nDetermine without graphing, whether the given quadratic function has a max value or min value and then find the value. F(x)=2x^2+16x-1\n\nasked by Anonymous on October 15, 2014\n85. ## Math~Geometry\n\nFind the value of X in the figure. A. 40°* B. 50° C. 140° D. 180° This is the link to the Image ibb.co/g7CVz2g\n\nasked by Mr. Skills1014 on January 25, 2019\n86. ## calculus\n\nFind the volume of the solid obtained by rotating the region bounded by y=5x+25, y=0 about the y-axis.\n\nasked by Anonymous on May 2, 2012\n87. ## Stats\n\nSix letters are picked. Find the chance that they can be arranged to form the word RANDOM.\n\nasked by Mario007 on April 15, 2014\n88. ## Calculus\n\nFind all solutions of the equation correct to three decimal places. (ex: 0.617 or -1.764) x^3=3x-3\n\nasked by Alisha on September 24, 2015\n89. ## CHEMISTRY\n\nFind the amount of CuSO4.5H2O needed to prepare 500 mL of 0.25 M solution.\n\nasked by Sarah on February 20, 2012\n90. ## physics\n\non a trip a car covers 42.3 miles in 40.0 minutes. find the average velocity in m/s and km/hr\n\nasked by roger on June 13, 2014\n91. ## linear algebra\n\nFind the steady state for the Markov matrix? A=[ .2 .4 .3 .4 .2 .3 .4 .4 .4] Then calculate the limit of A^n = (0,20,0) as n->infinity\n\nasked by fatih on April 21, 2012\n92. ## Cal 2\n\nThe region bounded by y=3/x, y=0, x=3, and x=5 is rotated about the x-axis. Find the volume of the resulting solid.\n\nasked by Michael on February 10, 2016\n93. ## com 220\n\nI need a link to find charts and graph statistics on racism and prejudices today\n\nasked by Tracie on March 22, 2010\n94. ## Greek Mythology\n\nI can't find any information on Homer, author of the Odyssey. Is there a good website i could use other than Wikipedia?\n\nasked by Austin on February 18, 2010\n95. ## computers\n\nIs there a way to find out some information about an e-mail address without actually sending a message? As in, is it still in active use? Or, who is the person using it?\n\nasked by Dan on September 29, 2014\n96. ## sequence....help!!!!!\n\nfind an expression in terms n of the nth term of the following sequence 5,13,32,69,129,221......help\n\nasked by emmanuel on March 15, 2016\n97. ## maths\n\nA circle passes throughthe origin and the point (5/2,1/2) and has 2y-3x=0 as a diameter. Find its equation.\n\nasked by Sheelander on January 8, 2016\n98. ## 12th grade\n\nhow can i find the initial velocity of a ball being kicked from a rooftop and landing on the ground?\n\nasked by Anonymous on March 22, 2010\n99. ## maths\n\nfind the surface area of abox with open top having dimensions 5,6,7metre\n\nasked by preeti on February 10, 2016\n100. ## Intro to Chemistry\n\n2 Na + 2 H20 --> 2 NaOH + H2 is this the balanced equation? and How do I find calulate the % yield of the products?\n\nasked by Kimmy on January 28, 2016" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.79636925,"math_prob":0.8924,"size":25721,"snap":"2019-35-2019-39","text_gpt3_token_len":10327,"char_repetition_ratio":0.15355602,"word_repetition_ratio":0.020487804,"special_character_ratio":0.5701567,"punctuation_ratio":0.08574652,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99765366,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-25T23:20:55Z\",\"WARC-Record-ID\":\"<urn:uuid:5f1557c3-04e4-469a-a12b-a8d3527a6e3a>\",\"Content-Length\":\"306824\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8dd11dac-a8cd-4d21-9c24-9a7264a61977>\",\"WARC-Concurrent-To\":\"<urn:uuid:dcffbc37-7662-40bf-8640-d87876e2aa22>\",\"WARC-IP-Address\":\"66.228.55.50\",\"WARC-Target-URI\":\"https://www.jiskha.com/similar?question=Short+answer+find+the+quotient+6x%5E3-x%5E2-7x-9+------------+2x%2B3&page=650\",\"WARC-Payload-Digest\":\"sha1:ZCDH7JYMS5LFU2OWPNEWZXUEH7LUMRWL\",\"WARC-Block-Digest\":\"sha1:KWDR6HCT7ARTTY5CFJX7GHOUTYUCA4O3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027330907.46_warc_CC-MAIN-20190825215958-20190826001958-00247.warc.gz\"}"}
https://juanmarqz.wordpress.com/2011/12/27/mobius-doble-cover/
[ "# möbius doble cover\n\nThe set", null, "$E=M\\ddot{o}\\stackrel{\\sim}\\times I$ is an orientable 3-manifold with boundary. In the illustration we see in orange the möbius band at", null, "$\\frac{1}{2}$ and a small regular neigbourhood of her removed without her, i.e., if", null, "$Q={\\cal{N}}(M\\ddot{o}\\times \\frac{1}{2})\\smallsetminus (M\\ddot{o}\\times \\frac{1}{2})\\subset E$, then which is", null, "$E\\smallsetminus Q$?", null, "", null, "", null, "", null, "the last step is", null, "$M\\ddot{o}\\times\\frac{1}{2}$ in orange, and", null, "$M\\ddot{o}\\stackrel{\\sim}\\times I$ without", null, "$M\\ddot{o}\\stackrel{\\sim}\\times (\\frac{1}{2}-\\varepsilon, \\frac{1}{2}+\\varepsilon)$, for", null, "$\\varepsilon=|\\varepsilon|\\to \\frac{1}{2}$\n\n1 Comment\n\nFiled under math\n\n### One response to “möbius doble cover”\n\n1.", null, "prof dr mircea orasanu\n\nthe importance of this question as double over or surfaces is approached often and thus posted from by prof dr mircea orasanu and prof drd horia orasanu and that is followed necessary for LAGRANGIAN AND MOBIUS transforms and surfaces appear in a wide variety of physical problems. For example, separation of the Helmholtz or wave equation in circular cylindrical coordinates leads to Bessel’s equation.\n• Generating function, integer order, Jn (x)\nAlthough Bessel functions are of interest primarily as solutions of differential equations, it is instructive and convenient to develop them from a completely different approach, that of the generating function. Let us introduce a function of two variables," ]
[ null, "https://s0.wp.com/latex.php", null, "https://s0.wp.com/latex.php", null, "https://s0.wp.com/latex.php", null, "https://s0.wp.com/latex.php", null, "https://juanmarqz.files.wordpress.com/2011/12/moetwiste21.png", null, "https://juanmarqz.files.wordpress.com/2011/12/moetwiste23.png", null, "https://juanmarqz.files.wordpress.com/2012/01/moetwiste36.png", null, "https://juanmarqz.files.wordpress.com/2012/01/moetwiste38.png", null, "https://s0.wp.com/latex.php", null, "https://s0.wp.com/latex.php", null, "https://s0.wp.com/latex.php", null, "https://s0.wp.com/latex.php", null, "https://2.gravatar.com/avatar/59b03e9f4ba7c145ed48ab1c1e8be40d", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.92204493,"math_prob":0.99719626,"size":983,"snap":"2019-51-2020-05","text_gpt3_token_len":213,"char_repetition_ratio":0.09397344,"word_repetition_ratio":0.0,"special_character_ratio":0.18921669,"punctuation_ratio":0.101123594,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99794775,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,6,null,6,null,6,null,6,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-27T08:44:29Z\",\"WARC-Record-ID\":\"<urn:uuid:d95ac8a8-d0f0-471a-8517-139dbf9bb581>\",\"Content-Length\":\"124646\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:cde974ba-ad88-406d-adbe-11874fe7d94e>\",\"WARC-Concurrent-To\":\"<urn:uuid:9d133e98-b887-4fe4-88fc-91359e9f9d7c>\",\"WARC-IP-Address\":\"192.0.78.13\",\"WARC-Target-URI\":\"https://juanmarqz.wordpress.com/2011/12/27/mobius-doble-cover/\",\"WARC-Payload-Digest\":\"sha1:7R2O4K62LWOWRL3TUJIKVHQ2I55JSOWR\",\"WARC-Block-Digest\":\"sha1:OLZDSYCGHOPSYM57SJYQGE5RRDNUUO2G\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579251696046.73_warc_CC-MAIN-20200127081933-20200127111933-00480.warc.gz\"}"}
https://haizs.com/post/bzoj1640/
[ "# [BZOJ1640]&&[Usaco2007 Nov]Best Cow Line 队列变换\n\n## 描述 Description\n\nFJ 打算带着他可爱的 N (1 ≤ N ≤ 2,000)头奶牛去参加”年度最佳老农”的比赛. 在比赛中, 每个农夫把他的奶牛排成一列, 然后准备经过评委检验. 比赛中简单地将奶牛的名字缩写为其头字母 (the initial letter of every cow), 举个例子, FJ 带了 Bessie, Sylvia, 和 Dora, 那么就可以缩写为 BSD. FJ 只需将奶牛的一个序列重新排列, 然后参加比赛. 他可以让序列中的第一头奶牛, 或者最后一头走出来, 站到新队列的队尾. 利欲熏心的 FJ 为了取得冠军, 他就必须使新队列的字典序尽量小. 给你初始奶牛序列(用头字母) 表示, 然后按照上述的规则组成新序列, 并使新序列的字典序尽量小.\n\n51\nA\nA\nB\nB\nA\nB\nB\nB\nB\nA\nB\nA\nB\nB\nA\nB\nA\nB\nA\nA\nB\nB\nA\nA\nB\nB\nB\nA\nA\nA\nA\nB\nA\nA\nB\nA\nB\nA\nA\nB\nB\nA\nA\nA\nB\nB\nB\nB\nB\nB\nA\n\n## 样例输出 SampleOutput\n\nAAABBABBBBABABBABABAABBAABBBAAAABAABABAABBAAABBBBBB\n\nSilver\n\nBZOJ 1640\n\n## 代码 Code\n\n``````#include <stdio.h>\n#include <iostream>\n#include <cstring>\n#include <algorithm>\n#include <cmath>\nusing namespace std;\nchar a;\nint i,j,t,n,m,l,r,k,z,y,x;\ninline char read()\n{\nchar ch=getchar();\nwhile (ch<'A' || ch>'Z') ch=getchar();\nreturn ch;\n}\ninline bool comp(int l,int r)\n{\nif (l==r) return true;\nwhile (a[l]==a[r] && l<r) l++,r--;\nreturn a[l]<a[r];\n}\nint main()\n{\nscanf(\"%d\",&n);\nfor (i=1;i<=n;i++) a[i]=read();\nl=1;r=n;\nt=0;\nwhile (l<=r)\n{\nif (comp(l,r))\n{\nprintf(\"%c\",a[l++]);\nt++;\n}\nelse\n{\nprintf(\"%c\",a[r--]);\nt++;\n}\nif (t==80)\n{\nprintf(\"n\");\nt=0;\n}\n}\nreturn 0;\n}``````" ]
[ null ]
{"ft_lang_label":"__label__zh","ft_lang_prob":0.6401274,"math_prob":0.9639183,"size":1303,"snap":"2019-35-2019-39","text_gpt3_token_len":824,"char_repetition_ratio":0.13625866,"word_repetition_ratio":0.15196079,"special_character_ratio":0.35379893,"punctuation_ratio":0.21316615,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9944449,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-23T18:49:22Z\",\"WARC-Record-ID\":\"<urn:uuid:5950dbe0-59b5-464d-91d9-268ce43ce5e2>\",\"Content-Length\":\"30998\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:157a3b94-0e69-4338-a712-89abb9df63db>\",\"WARC-Concurrent-To\":\"<urn:uuid:613b8e8a-4ca4-4941-9e45-1cfe1a77f198>\",\"WARC-IP-Address\":\"47.74.241.133\",\"WARC-Target-URI\":\"https://haizs.com/post/bzoj1640/\",\"WARC-Payload-Digest\":\"sha1:32HQK6T2NFV3IBSPQE3BKNXYV4VDNYPX\",\"WARC-Block-Digest\":\"sha1:3AJP2Z4MYW7IX6FSS4YEZFHDDPQOV46G\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027318952.90_warc_CC-MAIN-20190823172507-20190823194507-00191.warc.gz\"}"}
https://mailmanbroy.informatik.tu-muenchen.de/pipermail/isabelle-dev/2017-August/007550.html
[ "# [isabelle-dev] some results about \"lex\"\n\nChristian Sternagel c.sternagel at gmail.com\nFri Aug 25 06:55:02 CEST 2017\n\n```Dear list,\n\nmaybe the following results about \"lex\" are worthwhile to add to the\nlibrary?\n\nlemma lex_append_right:\n\"(xs, ys) ∈ lex r ⟹ length vs = length us ⟹ (xs @ us, ys @ vs) ∈ lex r\"\nby (force simp: lex_def lexn_conv)\n\nlemma lex_append_left:\n\"(ys, zs) ∈ lex r ⟹ (xs @ ys, xs @ zs) ∈ lex r\"\nby (induct xs) auto\n\nlemma lex_take_index:\nassumes \"(xs, ys) ∈ lex r\"\nobtains i where \"i < length xs\" and \"i < length ys\" and \"take i xs =\ntake i ys\"\nand \"(xs ! i, ys ! i) ∈ r\"\nproof -\nobtain n us x xs' y ys' where \"(xs, ys) ∈ lexn r n\" and \"length xs =\nn\" and \"length ys = n\"\nand \"xs = us @ x # xs'\" and \"ys = us @ y # ys'\" and \"(x, y) ∈ r\"\nusing assms by (fastforce simp: lex_def lexn_conv)\nthen show ?thesis by (intro that [of \"length us\"]) auto\nqed\n\ncheers\n\nchris\n```" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.83745015,"math_prob":0.90697616,"size":923,"snap":"2019-35-2019-39","text_gpt3_token_len":316,"char_repetition_ratio":0.13166486,"word_repetition_ratio":0.0,"special_character_ratio":0.35211268,"punctuation_ratio":0.11640212,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9945403,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-17T06:21:08Z\",\"WARC-Record-ID\":\"<urn:uuid:d9510e88-40ab-426e-954c-27c648abe954>\",\"Content-Length\":\"3941\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8120372c-2439-4bd6-8e7e-43e9fe308d40>\",\"WARC-Concurrent-To\":\"<urn:uuid:591ab8d5-0f8a-4e21-aa12-5f6657207987>\",\"WARC-IP-Address\":\"131.159.46.87\",\"WARC-Target-URI\":\"https://mailmanbroy.informatik.tu-muenchen.de/pipermail/isabelle-dev/2017-August/007550.html\",\"WARC-Payload-Digest\":\"sha1:644RPCCCBOPOUIQIVXKJNMFH3B4SW25E\",\"WARC-Block-Digest\":\"sha1:R54SEVZFH5E7XWVLU6OIXJFXCNTQWVLV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514573053.13_warc_CC-MAIN-20190917061226-20190917083226-00177.warc.gz\"}"}
https://blog.lordash.cf/posts/e077fd41.html
[ "# Game of CS(LightOJ-1355)\n\n## 题面\n\nJolly and Emily are two bees studying in Computer Science. Unlike other bees they are fond of playing two-player games. They used to play Tic-tac-toe, Chess etc. But now since they are in CS they invented a new game that definitely requires some knowledge of computer science.\n\nInitially they draw a random rooted tree (a connected graph with no cycles) in a paper which consists of n nodes, where the nodes are numbered from 0 to n-1 and 0 is the root, and the edges are weighted. Initially all the edges are unmarked. And an edge weigh w, has w identical units.\n\n1. Jolly has a green marker and Emily has a red marker. Emily starts the game first and they alternate turns.\n\n2. In each turn, a player can color one unit of an edge of the tree if that edge has some (at least one) uncolored units and the edge can be traversed from the root using only free edges. An edge is said to be free if the edge is not fully colored (may be uncolored or partially colored).\n\n3. If it’s Emily’s turn, she finds such an edge and colors one unit of it using the red marker.\n\n4. If it’s Jolly’s turn, he finds such an edge and colors one unit of it with the green marker.\n\n5. The player, who can’t find any edges to color, loses the game.\n\nFor example, Fig 1 shows the initial tree they have drawn. The tree contains four nodes and the weights of the edge (0, 1), (1, 2) and (0, 3) are 1, 1 and 2 respectively. Emily starts the game. She can color any edge she wants; she colors one unit of edge (0 1) with her red marker (Fig 2). Since the weight of edge (0 1) is 1 so, this edge is fully colored.", null, "", null, "", null, "", null, "Fig 1Fig 2Fig 3Fig 4\n\nNow it’s Jolly’s turn. He can only color one unit of edge (0 3). He can’t color edge (1 2) since if he wants to traverse it from the root (0), he needs to use (0, 1) which is fully colored already. So, he colors one unit of edge (0 3) with his green marker (Fig 3). And now Emily has only one option and she colors the other unit of (0 3) with the red marker (Fig 4). So, both units of edge (0 3) are colored. Now it’s Jolly’s turn but he has no move left. Thus Emily wins. But if Emily would have colored edge (1 2) instead of edge (0 1), then Jolly would win. So, for this tree Emily will surely win if both of them play optimally.\n\n## 输入\n\nInput starts with an integer T ( ≤ 500), denoting the number of test cases.\n\nEach case starts with a line containing an integer n (2 ≤ n ≤ 1000). Each of the next n-1 lines contains two integers u v w (0 ≤ u, v < n, u ≠ v, 1 ≤ w ≤ 109) denoting that there is an edge between u and v and their weight is w. You can assume that the given tree is valid.\n\n## 输出\n\nFor each case, print the case number and the name of the winner. See the samples for details.\n\n## 思路\n\nSG定理,对于当前节点u,每次考虑字节点v,u-v边的长度为l\n\n## 代码\n\n_/_/_/_/_/ EOF _/_/_/_/_/" ]
[ null, "https://vj.z180.cn/45b31a9bd032a40aea4b9dd272256c27", null, "https://vj.z180.cn/3f96228dd8176c936c951458fd027d77", null, "https://vj.z180.cn/3479468f6b9f55a6cc4679f37b78fa0d", null, "https://vj.z180.cn/06f630f359f8540f805c5e122d7bd9f2", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8895253,"math_prob":0.96765196,"size":2952,"snap":"2020-45-2020-50","text_gpt3_token_len":940,"char_repetition_ratio":0.13093624,"word_repetition_ratio":0.029668411,"special_character_ratio":0.2811653,"punctuation_ratio":0.096582465,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97154903,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,2,null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-25T13:26:41Z\",\"WARC-Record-ID\":\"<urn:uuid:5df3e769-2beb-4f68-ac53-4757ecc52570>\",\"Content-Length\":\"39361\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fecafb9b-86c8-4d46-b3f3-9b7adc12510f>\",\"WARC-Concurrent-To\":\"<urn:uuid:f2ecd398-8965-46b7-8dea-4c63ef207145>\",\"WARC-IP-Address\":\"150.109.19.98\",\"WARC-Target-URI\":\"https://blog.lordash.cf/posts/e077fd41.html\",\"WARC-Payload-Digest\":\"sha1:T3KQSAG3BPBHTJJFHZAZ7UQHVO4RDNLU\",\"WARC-Block-Digest\":\"sha1:PETOBOPZLCJRLDK3W4RDNVZN4BNHJWKZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107889173.38_warc_CC-MAIN-20201025125131-20201025155131-00036.warc.gz\"}"}
https://plainmath.net/47138/definite-integration
[ "", null, "Definite integration\n\n2021-12-26\nThe solid lies  between the Planes perpendicular to the x axis at X=-1amd X=1. Cross-sections perpendicular to the x axis between between these planes are circular disk with the diameters run from the semicircle y =-root(1-x*2)to the semi circle y=root(1-x*2).Find a formula for the area of cross section A(x)\n\n• Questions are typically answered in as fast as 30 minutes\n\nSolve your problem for the price of one coffee\n\n• Math expert for every subject\n• Pay only if we can solve it", null, "karton\n\nThe bounds of the region are x -1 and x =1 so integrate the area function from -1 to 1 to find the volume.\n\n$$\\begin{array}{} V=\\int^1_{-1}A(x)dx\\\\ V=\\int^1_{-1} 4(1-x^2)dx\\\\ =4(x-\\frac{1}{3}x^3)|^1_{-1}\\\\ =4(1-\\frac{1}{3}(1)^3)-4(-1-\\frac{1}{3}(-1)^3)\\\\ =4(1-\\frac{1}{3})-4(-1+\\frac{1}{3})\\\\ =4(\\frac{2}{3})-4(-\\frac{2}{3})\\\\ =\\frac{8}{3}+\\frac{8}{3}\\\\ =\\frac{16}{3} \\end{array}$$" ]
[ null, "https://plainmath.net/qa-theme/BTMath/images/search.png", null, "https://plainmath.net/", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8091847,"math_prob":0.99985933,"size":1205,"snap":"2022-05-2022-21","text_gpt3_token_len":417,"char_repetition_ratio":0.17651957,"word_repetition_ratio":0.0,"special_character_ratio":0.4,"punctuation_ratio":0.12719299,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99981874,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-01-20T08:32:35Z\",\"WARC-Record-ID\":\"<urn:uuid:c3945274-ca88-4205-9ca4-376e09299096>\",\"Content-Length\":\"32815\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1c896c10-2ace-405a-b93b-a83ac48c0dca>\",\"WARC-Concurrent-To\":\"<urn:uuid:f95b07eb-30ae-4c54-a42d-94b1ca057e4a>\",\"WARC-IP-Address\":\"104.21.86.86\",\"WARC-Target-URI\":\"https://plainmath.net/47138/definite-integration\",\"WARC-Payload-Digest\":\"sha1:2VNZRFOFTXZFSPILTGI3JIT46FATEXMJ\",\"WARC-Block-Digest\":\"sha1:6YXOFPX6FOJYHGGWBQKPHQEBSLQ3AKIG\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-05/CC-MAIN-2022-05_segments_1642320301730.31_warc_CC-MAIN-20220120065949-20220120095949-00161.warc.gz\"}"}
https://socratic.org/questions/how-do-you-evaluate-2-542times10-5-4-1times10-10
[ "How do you evaluate (2.542times10^5)/(4.1times10^-10)?\n\nJul 20, 2017\n\nSee a solution process below:\n\nExplanation:\n\nFirst, rewrite the expression as:\n\n$\\left(\\frac{2.542}{4.1}\\right) \\times \\left({10}^{5} / {10}^{-} 10\\right) \\implies 0.62 \\times \\left({10}^{5} / {10}^{-} 10\\right)$\n\nNext, use this rule of exponents to evaluate the $10 s$ terms:\n\n${x}^{\\textcolor{red}{a}} / {x}^{\\textcolor{b l u e}{b}} = {x}^{\\textcolor{red}{a} - \\textcolor{b l u e}{b}}$\n\n$0.62 \\times \\left({10}^{\\textcolor{red}{5}} / {10}^{\\textcolor{b l u e}{- 10}}\\right) \\implies 0.62 \\times {10}^{\\textcolor{red}{5} - \\textcolor{b l u e}{- 10}} \\implies$\n\n$0.62 \\times {10}^{\\textcolor{red}{5} + \\textcolor{b l u e}{10}} \\implies$\n\n$0.62 \\times {10}^{15}$\n\nTo write the result in scientific notation form we need to move the decimal point $1$ place to the right, therefore we need to subtract $1$ from the exponent for the 10 term:\n\n$6.2 \\times {10}^{14}$\n\nIf we want to right this in standard from we need to move the decimal point 14 places to the right:\n\n$620 , 000 , 000 , 000 , 000$" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7201573,"math_prob":0.9999355,"size":521,"snap":"2019-43-2019-47","text_gpt3_token_len":126,"char_repetition_ratio":0.102514505,"word_repetition_ratio":0.072289154,"special_character_ratio":0.25335893,"punctuation_ratio":0.106796116,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99943733,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-21T13:01:14Z\",\"WARC-Record-ID\":\"<urn:uuid:5f748c27-9f56-4f21-87d5-fa37d3a33910>\",\"Content-Length\":\"34505\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:37210aeb-ed1a-47e0-bca2-a7ca8ee774e1>\",\"WARC-Concurrent-To\":\"<urn:uuid:3e18073c-b799-4f36-87b6-610c753894bc>\",\"WARC-IP-Address\":\"54.221.217.175\",\"WARC-Target-URI\":\"https://socratic.org/questions/how-do-you-evaluate-2-542times10-5-4-1times10-10\",\"WARC-Payload-Digest\":\"sha1:YVNWW4UC4EM5YWVUZTTXPPHZZVEHLRCU\",\"WARC-Block-Digest\":\"sha1:NM2R5AEMWKKC2CO4ZMCROYUU66G3JYAA\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570987773711.75_warc_CC-MAIN-20191021120639-20191021144139-00411.warc.gz\"}"}
http://www.scratch-blog.com/2015/01/bertrands-random-chord-paradox-methods.html
[ "## Wednesday, January 14, 2015\n\n### Bertrand's Random Chord Paradox Methods 2 and 3\n\nIn my April 21, 2014 post, Bertrand’s Random Chord Paradox 1  (http://www.scratch-blog.com/2014/04/bertrands-random-chord-paradox-1.html) I presented the first of three methods for randomly selecting a chord in a circle with an inscribed equilateral triangle and then using the Monte Carlo method (coded in Scratch) to experimentally determine the probability that a randomly selected chord is longer than the side of the inscribed triangle. For the random points on the circumference method discussed in the post, the probability is one-third (1/3).\nThe paradox arises from the fact that two other equally valid methods for picking the chord each give a probability different from one-third.\nIn my Scratch project Bertrand’s Random Chord Paradox 2 (http://scratch.mit.edu/projects/20392511/)\nthe Monte Carlo method correctly approximates the probability that a randomly selected chord, using the random radius method, is one-half.\nIn my Scratch project Bertrand’s Random Chord Paradox 3\nusing the random midpoint method, the probability is found to be one-fourth!\nThe theoretical derivations for the three methods are presented in a three free, PDF files that can be obtained by sending an email request to [email protected]." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.81197953,"math_prob":0.71185887,"size":1260,"snap":"2021-43-2021-49","text_gpt3_token_len":291,"char_repetition_ratio":0.12977707,"word_repetition_ratio":0.06703911,"special_character_ratio":0.20793651,"punctuation_ratio":0.094827585,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9796559,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-23T16:33:14Z\",\"WARC-Record-ID\":\"<urn:uuid:3e6e68f3-a364-4888-b1dc-a9a3677f0192>\",\"Content-Length\":\"76853\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3af9bda8-403c-4ff2-b2a5-216f6bbca891>\",\"WARC-Concurrent-To\":\"<urn:uuid:01a655ff-5f62-46f6-8ffe-0b721d45e6d3>\",\"WARC-IP-Address\":\"172.217.15.115\",\"WARC-Target-URI\":\"http://www.scratch-blog.com/2015/01/bertrands-random-chord-paradox-methods.html\",\"WARC-Payload-Digest\":\"sha1:TRAN4OU4PHCTMMKTVDSNVQLMBDZSEGUI\",\"WARC-Block-Digest\":\"sha1:CZCL2TQPI5CUTKZIR5LX46X64V6KSMNA\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585737.45_warc_CC-MAIN-20211023162040-20211023192040-00638.warc.gz\"}"}
https://www.bartleby.com/questions-and-answers/1-calculate-the-ratio-of-k-a-wavelengths-for-uranium-and-carbon.-2-calculate-the-ratio-of-l-a-wavele/1e30748c-e80f-4f0a-9a32-8aa2b8694359
[ "# 1 Calculate the ratio of Kα wavelengths for uranium and carbon. 2 Calculate the ratio of Lα wavelengths for platinum and calcium.\n\nQuestion\n\n1 Calculate the ratio of Kα wavelengths for uranium and carbon.\n\n2 Calculate the ratio of Lα wavelengths for platinum and calcium.\n\n### Want to see this answer and more?\n\nExperts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*\n\n*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.\nTagged in\nScience", null, "" ]
[ null, "https://www.bartleby.com/static/bartleby-logo-tm-tag-inverted.svg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9157194,"math_prob":0.96539205,"size":1685,"snap":"2021-31-2021-39","text_gpt3_token_len":454,"char_repetition_ratio":0.09518144,"word_repetition_ratio":0.012345679,"special_character_ratio":0.29198813,"punctuation_ratio":0.2033097,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95700747,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-07-23T22:49:15Z\",\"WARC-Record-ID\":\"<urn:uuid:07a613c7-c2cf-4626-bcaf-9bd09c211811>\",\"Content-Length\":\"173363\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4556c95e-f143-46fa-abf6-bcae17fe617a>\",\"WARC-Concurrent-To\":\"<urn:uuid:07f292f7-6b6e-4c5d-9e35-eb6039621432>\",\"WARC-IP-Address\":\"13.32.199.101\",\"WARC-Target-URI\":\"https://www.bartleby.com/questions-and-answers/1-calculate-the-ratio-of-k-a-wavelengths-for-uranium-and-carbon.-2-calculate-the-ratio-of-l-a-wavele/1e30748c-e80f-4f0a-9a32-8aa2b8694359\",\"WARC-Payload-Digest\":\"sha1:7MOQ3KJMEJRKYEWJZEKNAGSCDLIHQH53\",\"WARC-Block-Digest\":\"sha1:YA2XIWFI6CBJOVDNS2G2VA272WGLJSC3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046150067.51_warc_CC-MAIN-20210723210216-20210724000216-00336.warc.gz\"}"}
http://www.mymcas.com/Mm_g7/Mm_g7_Number_Sense_Q1/number_sense_g7_Q1_sol_2.htm
[ "", null, "Answer to problem number 2 on the Grade 7 Numbers and Operations Quiz 1", null, "To find the speed of an object, divide the distance traveled by the time it takes to travel that distance. In this problem, you are told that the ball rolls 90 feet in 1 minute, so one way to write the speed is 90 feet/min. However, you are asked to find the answer in feet per second. There are 60 seconds in one mintue, so the speed (distance/time) can also be written as 90 feet/60 sec or 3/2 feet per second which is the same as 1.5 feet per second." ]
[ null, "http://www.mymcas.com/misc_images/mymcas_logo_scaled.jpg", null, "http://www.mymcas.com/Mm_g7/Mm_g7_Number_Sense_Q1/number_sense_g7_Q1_sol_2.htm", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9614665,"math_prob":0.97731334,"size":525,"snap":"2019-51-2020-05","text_gpt3_token_len":141,"char_repetition_ratio":0.134357,"word_repetition_ratio":0.0,"special_character_ratio":0.26095238,"punctuation_ratio":0.084033616,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96735704,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-29T22:13:49Z\",\"WARC-Record-ID\":\"<urn:uuid:228459df-b4cc-47ca-a2bf-c3b648cdc990>\",\"Content-Length\":\"1274\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a1df4292-bd4a-4d0d-957c-56bbe9d0cefd>\",\"WARC-Concurrent-To\":\"<urn:uuid:ea10b775-4e69-443e-87cf-d3e0a2369811>\",\"WARC-IP-Address\":\"198.105.215.36\",\"WARC-Target-URI\":\"http://www.mymcas.com/Mm_g7/Mm_g7_Number_Sense_Q1/number_sense_g7_Q1_sol_2.htm\",\"WARC-Payload-Digest\":\"sha1:S7JGHURV2HIY3TR64EPVTVOCYAVAZAEF\",\"WARC-Block-Digest\":\"sha1:V4UVA7F3TR5DYXXDZTW5WKVAYYO5CVTI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579251802249.87_warc_CC-MAIN-20200129194333-20200129223333-00007.warc.gz\"}"}
https://examtube.in/white-box-testing/
[ "# White Box Testing\n\n## WHITE-BOX TESTING [Structural Testing]\n\n• White box testing is a way of testing the external functionality of the code by examining and testing the program code that realizes the external functionality.\n• This is also known as clear box, or glass box, or open-box testing. White box testing takes into account the program code, code structure, and internal design flow.\n• White box testing is classified into static and structural testing.\n• White-box testing, sometimes called Glass-Box Testing, is a test case design method that uses the control structure of the procedural design to derive test cases.\n• Using white-box testing methods, the software engineer can derive test cases that\n1. Guarantee that all independent paths within a module have been exercised at least once,\n2. Exercise all logical decisions on their true and false sides,\n3. Execute all loops at their boundaries and within their operational bounds, and\n4. Exercise internal data structures to ensure their validity.\n\n• It concentrates on the examination of coding.\n• It uncovers typographical errors.\n• Detects design errors.\n\n• Do not full fill all testing goals since it only focuses on the examination of code.\n• Many other system problems may be left out\n• Test case needs to be changed for implementation of changes\n\n## Methods\n\nBasis path testing\n\n1.  Flow graph notation\n2.  Independent program paths\n3.  Deriving test cases\n4.  Graph matrices\n\nControl structure testing\n\n1. Conditions Testing\n2.  Loop Testing\n3.  Testing of Simple Loops\n4.  Testing of Nested Loops\n•  Testing of Concatenated Loops\n•  Testing of Unstructured Loops\n\n### Basis Path testing\n\nReferring to the figure, each circle, called a flow graph node, represents one or more procedural statements. A sequence of process boxes and a decision diamond can map into a single node.\n\nFlow chart (a) Flow graph (b)\n\nThe arrows on the flow graph, called edges or links, represent the flow of control. An edge must terminate at a node, even if the node does not represent any procedural statements (e.g., see the symbol for the if-then-else construct).\n\nAreas bounded by edges and nodes are called regions. When counting regions, we include the area outside the graph as a region. Each node that contains a condition is called a predicate node and is characterized by two or more edges emanating from it.\n\n### Independent program paths\n\nAn independent program path is any program that introduces at least one new set of   processing statement or a new condition.\n\nFor example: paths illustrated in figure\n\n• Path 1: 1 – 11\n• Path 2: 1 – 2 – 3 – 4 – 5 – 10 – 1 – 11\n• Path 3: 1 – 2 – 3 – 6 – 8 – 9 – 10 – 1 – 11\n• Path 4: 1- 2 – 3 – 6 – 7 – 9 – 10 – 1 – 11\n\nHow many paths to look for can be counted by using cyclomatic complexity?\n\nCyclomatic complexity is software metric that provides a quantitative measure of the logical complexity of a program.\n\nThree ways to identify cyclomatic complexity:\n\n• The number of regions 1. V (G) =E – N + 2\n• Where E= number of edges in a flow graph and N = number of nodes in a flow graph 2. V (G) =P + 1\n• Where, P= Predicate nodes in a flow graph\n\n### Deriving test cases\n\nSteps to derive test cases:\n\n• Draw a corresponding flow graph\n• Determine cyclomatic complexity\n• The number of regions E.g. 4\n• V (G) =E – N + 2 E.g. : V(G)=11 – 9 + 2 =4\n• V (G) =P + 1 E.g. V(G) = 3 +1 =4\n\nDetermine a basis set of linearly independent paths\n\n• Path 1 : 1 – 11\n• Path 2: 1 – 2 – 3 – 4 – 5 – 10 – 1-…\n• Path 3: 1 – 2 – 3 – 6 – 8 – 9 – 10 – 1-…\n• Path 4 : 1- 2 – 3 – 6 – 7 – 9 – 10 – 1 -…\n• (…) indicates that any path through the remainder of the control structure is acceptable.\n\n### Graph matrices\n\n• In graph matrix based testing, we convert our flow graph into a square matrix with one row and one column for every node in the graph. If the size of graph increases, it becomes difficult to do path tracing manually.\n• A graph matrix is a square matrix whose size is equal to the number of nodes on the flow graph. It is the tabular representation of a flow graph and use to develop tool that assist in basis path testing.\n\n## Control structure testing\n\n### Condition testing\n\n• Condition testing aims to exercise all logical conditions in a program module. Logical conditions may be complex or simple. Logical conditions may be nested with many relational operations.\n• Relational expression: (E1 op E2), where E1 and E2 are arithmetic expressions.\n• For example, (x+y) – (s/t), where x, y, s and t are variables.\n• Simple condition: Boolean variable or relational expression, possibly proceeded by a NOT operator.\n• Compound condition: composed of two or more simple conditions, Boolean operators and parentheses along with relational operators.\n• Boolean expression: Condition without relational expressions\n\n### Loop testing\n\n➢ Loops are fundamental to many algorithms. Loops can be categorized as, define loops as simple, concatenated, nested, and unstructured. Loops can be defined in many ways.\n\n### Testing simple loop\n\n1. Skip the loop entirely\n2. Only one passes through the loop\n3. Two passes through the loop\n4. M passes through the loop, where m < n\n5. n –1, n, n + 1 passes through the loop ‘n’ is the maximum number of allowable passes through the loop\n\n### Testing Nested loop\n\n• Start at the innermost loop; set all other loops to minimum values\n• Conduct simple loop tests for the innermost loop while holding the outer loops at their minimum iteration parameter values; add other tests for out-of-range or excluded values\n• Work outward, conducting tests for the next loop, but keeping all other outer loops at minimum values and other nested loops to “typical” values.\n• Continue until all loops have been tested\n\n#### Testing concatenated loop\n\n• For independent loops, use the same approach as for simple loops\n• Otherwise, use the approach applied for nested loops\n\n#### Testing unstructured loop\n\n• Redesign the code to reflect the use of structured programming practices\n• Depending on the resultant design, apply testing for simple loops, nested loops, or concatenated loops" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8798482,"math_prob":0.92143816,"size":5982,"snap":"2023-14-2023-23","text_gpt3_token_len":1433,"char_repetition_ratio":0.12111074,"word_repetition_ratio":0.09597806,"special_character_ratio":0.24707456,"punctuation_ratio":0.09662717,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9670984,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-06-05T03:57:58Z\",\"WARC-Record-ID\":\"<urn:uuid:35306818-b81f-4340-91bf-d700417b2741>\",\"Content-Length\":\"122550\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:cce37b3e-1869-4d74-89c8-4b8afdc61686>\",\"WARC-Concurrent-To\":\"<urn:uuid:dce2459d-d103-4784-83b8-6da10c5b4434>\",\"WARC-IP-Address\":\"217.21.91.111\",\"WARC-Target-URI\":\"https://examtube.in/white-box-testing/\",\"WARC-Payload-Digest\":\"sha1:NRPNIIABMNGLJ6QZROTVUZJTN7SNOTPU\",\"WARC-Block-Digest\":\"sha1:6FDP45KYB7HQH2NJPKCF7OZRTFCAN64U\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224650620.66_warc_CC-MAIN-20230605021141-20230605051141-00020.warc.gz\"}"}
https://ask.sagemath.org/question/10268/open-a-plot-window-from-sage-console/
[ "# open a plot window from sage-console\n\nI have sage notebook working perfectly on my Mac (including plots of course). now I would like to use the sage-shell too. I use the -ipython -pylab options but when I try to draw anything, using for instance:\n\nx=randn(1000); hist(x)\n\n\nor\n\nf = plt.figure()\nplt.plot(range(10),range(10))\nplt.show()\n\n\nnothing happend. Nevetheless if I ask for plt.savefig('blahblah.png') I have the image on my disk...\n\nwhat did I messed?\n\nvery strange...\n\nsage: f1 = lambda x:1\nsage: f2 = lambda x:1-x\nsage: f3 = lambda x:exp(x)\nsage: f4 = lambda x:sin(2*x)\nsage: f = Piecewise([[(0,1),f1],[(1,2),f2],[(2,3),f3],[(3,10),f4]])\nsage: f.plot()\n\n\nwith the -pylab option alone works, it seems that -ipython is to blame; any idea?\n\nedit retag close merge delete\n\nSort by » oldest newest most voted\n\nYou probably will have to set SAGE_MATPLOTLIB_GUI and rebuild matplotlib (probably sage -f matplotlib). See the installation guide.\n\nmore" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8077217,"math_prob":0.79890764,"size":732,"snap":"2021-43-2021-49","text_gpt3_token_len":238,"char_repetition_ratio":0.12087912,"word_repetition_ratio":0.0,"special_character_ratio":0.33606556,"punctuation_ratio":0.23404256,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9688012,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-24T12:13:00Z\",\"WARC-Record-ID\":\"<urn:uuid:70b0d8a4-f91b-45a2-8ca8-35d25edad6b5>\",\"Content-Length\":\"52157\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:74f79aea-457d-4535-98a6-817dd4bd26d4>\",\"WARC-Concurrent-To\":\"<urn:uuid:e98eba0a-b631-41cc-ac21-7d5ed4ebafed>\",\"WARC-IP-Address\":\"194.254.163.53\",\"WARC-Target-URI\":\"https://ask.sagemath.org/question/10268/open-a-plot-window-from-sage-console/\",\"WARC-Payload-Digest\":\"sha1:KIAC2FCPQ6NPOFJG25OQLS2IAFGY7XIT\",\"WARC-Block-Digest\":\"sha1:7F3VG2FGICLAY6N2JPXZFJD7RC43VSIC\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585997.77_warc_CC-MAIN-20211024111905-20211024141905-00067.warc.gz\"}"}
https://istandwithilhan.org/tag/worksheet-or-work-sheet/
[ "Worksheet Or Work Sheet Color By Number Halloween Math Worksheets Mixed Addition Subtraction Worksheets Ks2 New English Worksheets For Kindergarten minute math test does kumon work worksheet or work sheet kumon reading worksheets my math test papers kids learning worksheets kids learning worksheets free printable puzzles for middle school students integrated math answers subtraction word problems year 3 natural numbers and whole numbers 2 to a fraction third grade subtraction | Best Worksheet for all" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8809721,"math_prob":0.5361521,"size":1932,"snap":"2021-21-2021-25","text_gpt3_token_len":430,"char_repetition_ratio":0.1307054,"word_repetition_ratio":0.10204082,"special_character_ratio":0.21635611,"punctuation_ratio":0.14577259,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9810647,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-09T16:14:33Z\",\"WARC-Record-ID\":\"<urn:uuid:4efba0b7-7d44-4c69-b39e-ece068ed8442>\",\"Content-Length\":\"61755\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c7c3124b-80f8-42a0-9f5b-a5a332156fd3>\",\"WARC-Concurrent-To\":\"<urn:uuid:c3997806-d863-4a63-bbf3-6cca95e2f841>\",\"WARC-IP-Address\":\"104.21.26.213\",\"WARC-Target-URI\":\"https://istandwithilhan.org/tag/worksheet-or-work-sheet/\",\"WARC-Payload-Digest\":\"sha1:Q67OIOIV3YSPMMCUUKIAANA4SLEPDOS5\",\"WARC-Block-Digest\":\"sha1:3SLRDYBBA3MF3BXR2P7MQA2M4UOFQ5KH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243989006.71_warc_CC-MAIN-20210509153220-20210509183220-00544.warc.gz\"}"}
https://pubs.aip.org/sor/jor/article-split/66/3/639/2846210/Nonlinear-rheology-of-entangled-wormlike-micellar
[ "We examine linear and nonlinear shear and extensional rheological properties using a “micelle-slip-spring model” [T. Sato et al., J. Rheol. 64, 1045–1061 (2020)] that incorporates breakage and rejoining events into the slip-spring model originally developed by Likhtman [Macromolecules 38, 6128–6139 (2005)] for unbreakable polymers. We here employ the Fraenkel potential for main chain springs and slip-springs to address the effect of finite extensibility. Moreover, to improve extensional properties under a strong extensional flow, stress-induced micelle breakage (SIMB) is incorporated into the micelle-slip-spring model. Thus, this model is the first model that includes the entanglement constraint, Rouse modes, finite extensibility, breakage and rejoining events, and stress-induced micelle breakage. Computational expense currently limits the model to micellar solutions with moderate numbers of entanglements ($≲7$), but for such solutions, nearly quantitative agreement is attained for the start-up of the shearing flow. The model in the extensional flow cannot yet be tested owing to the lack of data for this entanglement level. The transient and steady shear properties predicted by the micelle-slip-spring model for a moderate shear rate region without significant chain stretch are fit well by the Giesekus model but not by the Phan–Thien/Tanner (PTT) model, which is consistent with the ability of the Giesekus model to match experimental shear data. The extensional viscosities obtained by the micelle-slip-spring model with SIMB show thickening followed by thinning, which is in qualitative agreement with experimental trends. Additionally, the extensional rheological properties of the micelle-slip-spring model with or without SIMB are poorly predicted by both the Giesekus and the PTT models using a single nonlinear parameter. Thus, future work should seek a constitutive model able to capture the behavior of the slip-spring model in shear and extensional flows and so provide an accurate, efficient model of micellar solution rheology.\n\nSurfactant molecules, consisting of a hydrophilic head and a hydrophobic tail, are widely utilized in our daily life . They form self-assembled structures, such as spherical and cylindrical micelles, depending on surfactant and salt compositions. Cylindrical micelles or wormlike micelles (WLMs) with entanglements typically show significant viscoelastic properties and have attracted significant attention from the rheological community.\n\nThere have been extensive experimental studies that examine linear rheology [2–4], nonlinear shear rheology [5–12], nonlinear extensional rheology [13–17], and the corresponding microstructures of WLMs [18–20]. In this study, we especially focus on modeling the nonlinear rheological properties of WLM solutions and begin by briefly summarizing the relevant experimental studies. If the WLM solutions remain spatially homogeneous, their rheological properties are similar to those of entangled polymers; that is, the transient shear viscosity growth shows a stress overshoot, and the steady shear viscosity shows shear thinning [5–7]. An important finding is that the Giesekus model, which is a common phenomenological constitutive equation , can accurately reproduce the shear rheological properties of WLM solutions [8,9]. An important difference in shear rheological properties between WLM and polymer solutions can be observed, however, at high shear rates, where macroscopic flows can become spatially inhomogeneous. An example of this is shear-banding [22,23], which has been extensively investigated, for example, by Helgeson and co-workers for cetyltrimethylammonium bromide (CTAB) solutions modeled using the Giesekus equation with a stress-diffusion term [10,11]. Extensional flow properties of WLM solutions can be measured by several experimental techniques , such as filament-stretching extensional rheometry (FiSER) , capillary breakup extensional rheometry (CaBER) , and the opposed jet device [15–17]. Rothstein and co-workers reported that the WLM solutions show strain hardening followed by filament rupture before reaching a steady state. This filament rupture was considered to be due to flow-induced scission of micelle chains. Steady extensional viscosities measured by the opposed jet device for several surfactant and salt systems show extension thickening followed by extension thinning [15–17].\n\nTo deeply understand such experimental findings, theoretical and numerical approaches are highly desirable. From a theoretical perspective, Cates developed a so-called reptation-reaction model to describe linear “living” polymers that can break at a random point along a chain and whose ends can each randomly fuse with the end of some other chain in a reversible scission scheme. The reptation-reaction model can successfully capture the Maxwell-type relaxation with a single relaxation time as observed in experiments . However, other polymer-like relaxation mechanisms, including chain-length fluctuations and constraint release, which are important to reproduce the rheology of entangled polymers, are not addressed in the original Cates’ model. (In addition to reversible scission, Turner and Cates considered an end-interchange scheme that makes a three-arm star intermediate, and a bond-interchange scheme that makes a four-arm star intermediate . They showed that the relaxation behavior is changed by these mechanisms.)\n\nBased on Cates’ reaction-reptation model, the “pointer algorithm” was developed by Zou and Larson to accurately predict the linear rheology of WLM solutions . In the pointer algorithm, reptation, chain length fluctuations, and constraint release are combined with breakage/rejoining. To compute the relaxation modulus, the boundaries between relaxed and unrelaxed parts of WLM chains are tracked. Analytic formulas for the high-frequency modes are then added to account for the high-frequency region. Zou and Larson showed that this pointer algorithm can reproduce linear rheological properties over a wide frequency range . After their original work, the pointer algorithm was extended in several directions; e.g., the end-interchange and bond-interchange schemes were addressed , and relaxation mechanisms of unentangled micelles were included . More recently, Tan and co-workers have established a formula based on pointer algorithm simulations to estimate the micelle length from linear rheological data . Utilizing the pointer algorithm, we can, thus, obtain accurate microscopic micelle parameters from linear rheological data. Compared to these modeling developments in linear rheology, nonlinear rheological models are relatively underdeveloped.\n\nOne of the most utilized models for the nonlinear rheology of WLMs is the Vasquez–Cook–McKinley (VCM) model . The VCM model is composed of two species of Hookean dumbbells: long and short dumbbells. A long dumbbell can break to make two short dumbbells and vice versa to mimic the reversible scission scheme. Since the Hookean dumbbell model is employed, the VCM model with a constant breakage rate cannot reproduce nonlinear rheological properties, such as shear thinning observed in WLM solutions. Thus, the VCM model includes the stress-induced micelle breakage under flow . While several nonlinear properties under a homogeneous flow have been successfully reproduced by the VCM model , the effects of entanglements (i.e., the constraints they imposed on chain relaxation, and how they might be lost and gained under flow) are not included in the VCM model, which, thus, neglects the most important source of shear thinning in WLM solutions. Shear thinning is predicted by the VCM model, but only through inclusion of shear-induced micelle breakage, whose rate is adjusted arbitrarily to produce shear thinning strong enough to agree with experiments.\n\nVery recently, Peterson and co-workers developed two molecular-based constitutive models for entangled WLM solutions [33–35]. One is simplified tube approximation for the rapid-breaking micelles (STARM) model , and the other model is the living Rolie-Poly model . The basic idea of these models is to combine the population balances and polymeric relaxations, i.e., reptation, contour length fluctuation, and constraint release. While these models are physics-based and sophisticated, it is difficult to implement them in macroscopic flow calculations due to their model complexity. It should be noted that there is a simplified version of the living Rolie-Poly model in the fast-breakage limit, where micelle breakage is much faster than reptation, that might be used for macroscopic flow calculations. However, the fast-breakage limit is often not attained in common micellar solutions, and to the best of our knowledge, a simplified physics-based constitutive model beyond the fast-breakage limit has not been developed yet. To avoid complexity appearing in these constitutive models, it may be useful instead to develop an accurate mesoscopic simulation model and fit the predictions of this model with a simpler constitutive equation. This strategy would allow a tractable equation to be developed whose parameters could be correlated with micelle properties, rather than simply being adjusted to fit the experiments, without yielding any connection to microscopic physics.\n\nWe developed such a mesoscopic “micelle-slip-spring simulation model” to predict rheological properties of WLM solutions . Our model is based on the slip-spring model proposed by Likhtman . Slip-link and slip-spring models were originally developed for unbreakable entangled polymers and have been found to predict well their linear and nonlinear rheological properties . To address the rheology of WLM solutions, breakage and rejoining events were included in the polymer slip-spring model, and the results were validated through comparison with predictions of the pointer algorithm and with experimental linear viscoelastic data. Moreover, using the micelle-slip-spring model, we examined nonlinear shear properties including shear thinning, which naturally emerge from our micelle-slip-spring model due to the effect of the entanglement constraint .\n\nIn this article, we further investigate nonlinear rheological properties obtained by the micelle-slip-spring model. For such a purpose, instead of the Hookean springs utilized in our previous study following the original slip-spring model , we use the Fraenkel springs to prevent the overstretch of springs so that higher shear rates and extensional flows can be simulated where finite extensibility of the chain becomes important. Additionally, to improve extensional properties under a strong extensional flow, we incorporate stress-induced micelle breakage into the micelle-slip-spring model. Using the extended micelle-slip-spring model, we examine nonlinear shear and extensional properties. After defining and explaining the model in Sec. II, results are presented in Sec. III and summarized in Sec. IV.\n\nHere, we briefly explain the original micelle-slip-spring model . A micellar chain is expressed by a main chain and slip-springs that impose motional constraints on the main chain, as shown in the upper figure in Fig. 1. A micellar chain $i$$[1≤i≤Nchain(t)]$ consists of $N(i)(t)+1$ beads connected by $N(i)(t)$ springs. Here, the superscript $(i)$ distinguishes different micellar chains, and $Nchain(t)$ is the number of micellar chains in the system at time $t$. Because of breakage and rejoining events, $Nchain(t)$ and $N(i)(t)$ fluctuate in time in our micelle-slip-spring model.\n\nEach main chain spring is modeled by a single Kuhn segment with Kuhn length $b$, and each main chain bead is given a friction coefficient $ξ$. Here, the Kuhn length is related to the persistence length $ℓp$ as $b=2ℓp$ . On length scales less than $ℓp$, the chain is locally rigid.\n\nThe main chain $i$ has $Zss(i)(t)$ slip-springs at time $t$. A slip-spring illustrated in Fig. 1 consists of a slip-link shown with the red open circle connected to an anchoring point shown with the red filled diamond by a red slip-spring. The slip-link $k$ on the chain $i$, $sk(i)$, is constrained to move along the main chain $i$. Different from current “discrete” slip-spring models, in which the positions of the slip-links are restricted to jump main chain beads [40,41], in our model, as in the original slip-spring model of Likhtman, the slip-links can move anywhere along the chain . The time evolution of $sk(i)$ is defined by a 1D continuous dummy variable $xk(i)$, which spans between $0$ and $N(i)(t)$. In this study, slip-links are allowed to pass through each other since this has little effect on the results, as noted by Likhtman . While the slip-link can travel along the main chain, the corresponding anchoring point, $ak(i)$, is pinned in space unless the flow is applied. When the shear or extensional flow is applied, the anchoring point moves affinely, as in our previous study .\n\nEach slip-spring has $Ns$ Kuhn segments with the Kuhn length $bss$, and each slip-link has a friction coefficient $ξs$. As in our previous study that follows the original study by Likhtman , we assume that the Kuhn length of main chain springs is the same as that of slip-springs (i.e., $b=bss$). The slip-link friction coefficient $ξs$ is introduced to control the dynamics of the slip-springs. The initial number of slip-springs per chain is determined by an additional parameter, the average number of beads between slip-links, $Ness$. The slip-links are initially distributed randomly along the chains, and the anchoring points are placed around the corresponding slip-links according to a Gaussian potential of a Hookean spring as in the original model of Likhtman even though we employ the Fraenkel potential. We note that the microscopic detail of the model should not appear in long-time rheological behavior, and thus, the effect of this approximation would be expected to vanish in the long-time region.\n\nThe remaining relaxation mechanism needed to reproduce the dynamics of entangled polymers is constraint release (CR). We implement CR as in the original Likhtman’s slip-spring model , in which a slip-link is paired with a partner slip-link on a different chain. The CR occurs when the slip-link slides off the end of the chain [i.e., $xk(i)(t)<0$ or $N(i)(t)]. When CR occurs, this slip-link and the partner slip-link are removed from the chain and the partner chain, respectively. At the same time, two new slip-links are placed on two different randomly chosen chains. One slip-link is placed near the end of a chain, and the other is placed at a random position on a different chain. The corresponding anchoring points are distributed using the same procedure explained previously. Thus, while the number of slip-springs on a given chain $i$, $Zss(i)(t)$, fluctuates in time due to CR or breakage/rejoining events, the total number of slip-springs in the system is unchanged even under flow in most of our simulations. However, the effects of flow-induced reduction in entanglement density are quite possibly important and are, therefore, considered in Sec. III D, where we have examined a limiting case in which the total number of entanglements continuously decreases and eventually becomes zero.\n\nIn the original micelle-slip-spring model, we utilized a Hookean spring law following the original polymer slip-spring model. However, in this study, we focus on nonlinear shear and extensional properties of entangled WLMs. Thus, it is important to address the effect of finite extensibility. For springs that each correspond to a single Kuhn length, it is typical to employ the Fraenkel spring law . The total potential energy of the chain $i$ is then expressed as\n\n$U(i)=KkBT2b2∑j=1N(i)(|Rj(i)|−b)2+KsskBT2Nsbss2∑k=1Zss(i)(|qk(i)|−Nsbss)2,$\n(1)\n\nwhere $K$ and $Kss$ are the Fraenkel parameters for main-chain springs and slip-springs, respectively; $kB$ is the Boltzmann constant, $T$ is the temperature, $Rj(i)$ is the vector between two adjacent beads defined as $Rj(i)=rj+1(i)−rj(i)$, with $rj(i)$ being the position of the $j$th bead on the $i$th main chain, and $qk(i)$ is the vector between the slip-link and the anchoring point defined as $qk(i)=ak(i)−sk(i)$. Using this potential, we can express the spring force originating from spring $j$ of the main chain, $Fsp,j(i)$, as\n\n$Fsp,j(i)=−∂U(i)∂Rj(i)=−KkBTb2(|Rj(i)|−b)Rj(i)|Rj(i)|.$\n(2)\n\nFurthermore, the spring force originating from slip-spring $k$, $Fss,k(i)$, can be written as\n\n$Fss,k(i)=−∂U(i)∂qk(i)=−KsskBTNsbss2(|qk(i)|−Nsbss)qk(i)|qk(i)|.$\n(3)\n\nFrom these forces, bead and slip-link positions are updated over time. For more details regarding the dynamical equations, please see our previous study .\n\nFrom the forces and conformations of main chains and slip-springs, the $αβ$ [$α,β∈(x,y,z)$] components of the stress tensor of the main chain (i.e., real chain) and of the virtual-spring are expressed as\n\n$σαβR=−cchain⟨∑j=1N(i)Fsp,jα(i)Rjβ(i)⟩,$\n(4)\n$σαβV=−cchain⟨∑k=1Zss(i)Fss,kα(i)qkβ(i)⟩,$\n(5)\n\nrespectively, where $cchain$ is the chain concentration and $⟨⋯⟩$ is the ensemble average. To compute the relaxation modulus $G(t)$ accurately from an equilibrium simulation using the Green–Kubo formula, Ramírez and co-workers pointed out that the virtual-spring stress tensor $σαβV$ needs to be included so that\n\n$G(t)=σxyR(t)γ=VkBT{⟨σxyR(t)σxyR(0)⟩+⟨σxyR(t)σxyV(0)⟩},$\n(6)\n\nwhere $x$ is the velocity direction, $y$ is the velocity gradient direction, $γ$ is the step strain magnitude, and $V$ is the volume of the system. It should be noted that only the stress from main-chain springs is utilized to obtain $G(t)$ in the original work by Likhtman [i.e., $G(t)=(V/kBT)⟨σxyR(t)σxyR(0)⟩$] . However, this $G(t)$ deviates from relaxation modulus computed by the relaxation after a small step strain, $σxyR(t)/γ$, as explained by Ramírez and co-workers . We note that the virtual stress contribution is not more than around $25%$ of the main-chain contribution and shows similar dependence on time as the main chain contribution under shear flow and is negligibly small under an extensional flow (for more detail, see Sec. S1 in the supplementary material ). Thus, because of the rather long runs with small $Δt$ values needed to adequately resolve the virtual-spring contribution and its rather weak effect, we use only the main-chain stress $σαβR$ to compute the nonlinear rheological properties.\n\nBreakage and rejoining events are included in our model as done in our previous study ; that is, we use the reversible scission scheme and do not consider the end-interchange and the bond-interchange schemes. To incorporate these events, we introduce the probability $Pbreak$ that a breakage event occurs for any micelle among all micelles during each time step,\n\n$Pbreakeq=1−exp⁡(−ΔtΔtbreakeq),$\n(7)\n\nwhere $Δt$ is the simulation time step size and $Δtbreakeq$ is the average time between breakage events at equilibrium. In this study, a rejoining event occurs during each time step with probability $Prejoin$ that is the same as $Pbreakeq$ over all time steps even under flow. At each simulation time step, breakage and rejoining events independently occur with the probabilities of $Pbreakeq$ and $Prejoin$, respectively. Thus, the number of micelles $Nchain(t)$ fluctuates in time. (It should be noted that the breakage probability is increased under the strong extensional flow due to stress-induced micelle breakage, as explained in Sec. II B.) The average breakage time per chain with average length at equilibrium or under weak flow, $τ¯breakeq$, can be defined using $Δtbreakeq$ as\n\n$τ¯breakeq=Δtbreakeq⟨Nchain⟩,$\n(8)\n\nwhere $⟨Nchain⟩$ is the average number of WLM chains in the system. The dimensionless breakage time, $ζ$, is defined using $τ¯breakeq$ as\n\n$ζ≡τ¯breakeqτ¯rep,$\n(9)\n\nwhere $τ¯rep≡3⟨Ztube⟩3τe$ is the pure reptation time in the absence of other relaxation mechanisms of a micelle of average number of entanglements $⟨Ztube⟩$ and $τe≡(Netube)2τ0/(3π2)$ is the Rouse time of the chain segment between entanglements .\n\nThe assumptions regarding breakage/rejoining events are as follows. When a breakage event occurs at a certain simulation time step, a randomly selected main-chain bead is chosen to be a breakage point. At the breakage point, the chosen bead is duplicated, and these two beads are made the new ends of the resulting chains, as can be seen in Fig. 1. Since beads are inertialess, there is no fundamental problem with adding a bead. For a rejoining event, any two micelles can fuse with equal probability. That is, we assume the rejoining probability does not depend on micelle length and employ a mean-field approach that does not track the relative positions of micelles. Before and after breakage and rejoining events, configurations of main chains and slip-springs and pairing information of slip-links remain the same. To reduce computational costs, we impose upper and lower bounds on $Nchain(t)$, $Nchainmax$ and $Nchainmin$, respectively. Additionally, we maintain upper and lower bounds on $N(i)(t)$ by introducing the maximum and minimum numbers of springs per chain, $Nmax$ and $Nmin$, respectively.\n\nThus far, we have explained the case where the breakage and rejoining times are assumed to be constant, which is valid at equilibrium or under a weak flow. Extensional flow experiments by FiSER for the CTAB/NaSal system suggest that a micelle will break when the extensional stress per micelle reaches around $3.6×105$ Pa . This stress is about $104$ times larger than the experimental plateau modulus of $GN0∼10$ Pa for the CTAB/NaSal system . Under a strong extensional flow, the extensional stress obtained from the micelle-slip-spring model is expected to become higher than the micelle breakage stress and stress-induced micelle breakage (SIMB) might become evident. To accurately model the nonlinear rheology under strong extensional flow, we address the effect of SIMB in this study.\n\nThere are several ways to address SIMB in our micelle-slip-spring model. A simple way is to set the threshold stress for micelle breakage over which the micelles break. The threshold stress can be estimated from experimental data of extensional stress before rupture . However, the experimental threshold stress might be so high that all micelles break very fast. More realistically, under high stress, the micelles can be allowed to break faster than the time scale $τ¯breakeq$ for breakage at lower stress than the threshold stress. Mandal and Larson developed the activation formula that can address the acceleration of breakage at any stress . In this article, we use this formula to obtain the extensional rheological properties under more reasonable conditions. The average breakage time of the chain $i$ can be expressed as\n\n$τ¯break=τ°exp⁡(EscisskBT),$\n(10)\n\nwhere $τ°$ is the time constant and $Esciss$ is the scission free energy. The molecular dynamics simulations by Mandal and Larson revealed that the dimensionless scission energy $E~sciss=Esciss/kBT$ decreases linearly with stress. Thus, $E~sciss$ of the chain $i$ can be expressed as\n\n$E~sciss=E~scisseq−σ~Eσ~Ebreak,$\n(11)\n\nwhere $E~scisseq$ is the scission energy under no external force, $σ~E≡σE/GN0$ is the normalized extensional stress per chain, and $σ~Ebreak≡σEbreak/GN0$ is the normalized characteristic extensional stress of micelle breakage, which can be estimated from molecular dynamics simulations. It should be noted that $σEbreak$ is not identical to the experimental breakage stress per micelle ($∼3.6×105$ Pa for the CTAB/NaSal system ) and is expected to be smaller than the experimental breakage stress per micelle for the reason mentioned above. Combining Eqs. (10) and (11), we can obtain the breakage time under the extensional flow as\n\n$τ¯break=τ°exp⁡(E~scisseq−σ~Eσ~Ebreak)=τ¯breakeqexp⁡(−σ~Eσ~Ebreak),$\n(12)\n\nwhere the average breakage time at equilibrium, $τ¯breakeq$, is expressed as $τ¯breakeq=τ°exp⁡(E~scisseq)$.\n\nWe incorporate SIMB into the slip-spring model as follows. At each simulation time step, we compute the extensional stress of individual chains, which means that each chain has different extensional stress. This is used to determine whether or not breakage occurs using Eq. (12) and a random number. Namely, the breakage probability shown in Eq. (7) is increased under the strong extensional flow. In general, the tension varies along the chain with the highest tension being near the center of the chain. In this study, however, for simplicity, we use the averaged stress over the whole chain and assume that every bead of the breaking chain has an equal probability to be the breakage point. Thus, the bead at which breakage occurs is randomly selected, as done in our original micelle-slip-spring model. For rejoining events, we assume that the rejoining rate retains its equilibrium value even under the strong extensional flow.\n\nSimulations are carried out using dimensionless variables. Units of stress, time, and length are $Gchain≡cchainkBT$, with $cchain$ being the chain density, $τ0≡ξb2/kBT$, and the Kuhn length $b$, respectively. Here, $τ0$ in this study differs from the Rouse time of a single Kuhn segment by a factor of $3π2$.\n\nBasic parameter values used in this article are the same as those in our previous study . For slip-spring parameters, we use $Ness=4$, $Ns=0.5$, and $ξs/ξ=0.1$, which are the same as in Likhtman’s original work . Here, a comment on the number of “entanglements” needs to be made. The average number of slip-springs introduced to reproduce the entangled polymer dynamics, $⟨Zss⟩=⟨N⟩/Ness$, is not the same as the number of entanglements, $⟨Ztube⟩=⟨N⟩/Netube$, defined in the tube model. Here, $Netube$ is the number of beads per entanglement. Comparing the slip-spring model with the Likhtman–McLeish tube model , Likhtman found that $Netube≃7$ gives the number of beads per entanglement when using the standard slip-spring model parameters, $Ness=4$ and $Ns=0.5$ . (More precisely, $Netube$ with and without CR is $Netube=6.7$ and $5.7$, respectively .) Thus, we use $Netube=7$ to determine the number of entanglements per chain $⟨Ztube⟩$.\n\nThe Fraenkel parameters for main chain springs and slip-springs are both set to $K=Kss=102$ for all simulations. The Fraenkel parameter is arbitrary as long as it is large enough to prevent spring stretch. We chose the above value because it accomplishes this without excessive computational cost required when employing very large Fraenkel parameter values. Our choice of $K=Kss=102$ is of the same order as used in several other studies [50–52], while larger values were employed in one particular study . The simulation time step $Δt$ is kept less than $10−3τ0$. A $Δt$ value smaller than $10−3τ0$ is required to accurately obtain the stress under the strong shear and extensional flow. For a shear rate range of $γ˙>τ¯R−1$, where $γ˙$ is the shear rate and $τ¯R$ is the average Rouse time defined as $τ¯R≡(⟨N⟩+1)2τ0/(6π2)$, we set the time step less than the value of $10−3τ0/(γ˙τ¯R)$. Here, in typical simulations, the time step size should be set to be inversely proportional to the strain rate so that the strain increment in each time step is constant. Furthermore, even for the same strain rate, we used a smaller time step in the extensional flow than in the shear flow. Due to the computational cost, we examined the time step size range of $Δt≥10−5τ0$. As discussed later in Sec. III C, the smallest time step size $Δt=10−5τ0$ might not be enough to prevent overstretch under extension. Nevertheless, we confirmed that the $Δt$ values used in this study are small enough to that the stress from main chains $σR$ does not show significant divergence. We show the effect of changing the time step size in Fig. S2 in the supplementary material .\n\nFor breakage and rejoining events, $Δtbreakeq$ is an input parameter for simulation that is obtained from the micelle average breakage time $τ¯breakeq$ at equilibrium from Eq. (8). To compare results from slip-spring simulations with those from other models or experiments, it is convenient to use the dimensionless breakage time $ζ$ that can be computed from Eq. (9) once $τ¯breakeq$ and $τ¯rep$ are obtained.\n\nIn this study, we mainly set the average number of chains in the system to $⟨Nchain⟩=2000$. For several shear and extensional simulations with large strain rates, which require a small $Δt$, we set $⟨Nchain⟩=1000$. Under the strong flow, since the fluctuation in the stress becomes small, we can safely use the smaller number of chains. We set the maximum and minimum numbers of springs to $Nmax=4⟨N⟩$ and $Nmin=2$ in all simulations. The total number of micelles $Nchain(t)$ without SIMB is allowed to change within the range of $0.95⟨Nchain⟩≤Nchain(t)≤1.05⟨Nchain⟩$. The above values are the same as in our previous study . We have checked the effect of changing the ranges of $N(i)(t)$ and $Nchain(t)$ and confirmed that the expansion of these ranges has little effect on $G(t)$ . On the other hand, there is no upper limit to $Nchain(t)$ for simulations with SIMB.\n\nSince the experimental shear rheological properties of WLM solutions can be successfully fitted by the Giesekus model [8,9], we will see the Giesekus model can also fit the micelle-slip-spring simulation results. If we can systematically map micelle parameters of the slip-spring model (e.g., the number of entanglements and the breakage rate) onto a nonlinear parameter appearing in the Giesekus model, physical insights could thereby be indirectly incorporated into macroscopic (inhomogeneous) flow simulations, which might give better understanding of inhomogeneous flows of WLM solutions and how they depend on micellar parameters, such as the breakage rate, rather than merely on the phenomenological nonlinear parameter of the Giesekus model.\n\nWe briefly explain the Giesekus model and its steady state solutions under shear and extensional flows. The Giesekus model is a well-known phenomenological constitutive equation [21,54], which for mode $p$ ($1≤p≤Nmode$) is expressed as\n\n$τpσ▽p+(σp−GpI)+αG(σpGp−I)⋅(σp−GpI)=0,$\n(13)\n\nwhere $σp$ is the stress for mode $p$; $σ▽p$ is the upper convected derivative defined as $σ▽p=σ˙p−σp⋅κ+−κ⋅σp$, with $σ˙p$ being the time derivative of $σp$ and $κ$ being the velocity gradient tensor; $αG$ is the anisotropic parameter, which is the same for all modes ; $I$ is the unit tensor; and $τp$ and $Gp$ are the relaxation time and modulus for mode $p$, respectively. Here, $τp$ and $Gp$ are determined by the multimode Maxwell model fitting of the relaxation modulus. The total stress $σ$ is $σ=∑p=1Nmodeσp$.\n\nIn the shear flow, the steady shear viscosity for mode $p$, $ηp$, is written as \n\n$ηpη0,p=(1−fpS[γ˙,αG])21+(1−2αG)fpS[γ˙,αG],$\n(14)\n\nwhere $η0,p$$(=Gpτp)$ is the zero shear viscosity for mode $p$, and $fpS[γ˙,αG]$ is the function defined as\n\n$fpS[γ˙,αG]=1−gpS[γ˙,αG]1+(1−2αG)gpS[γ˙,αG],$\n(15)\n\nwith\n\n${gpS[γ˙,αG]}2={1+16αG(1−αG)(τpγ˙)2}1/2−18αG(1−αG)(τpγ˙)2.$\n(16)\n\nHere, $γ˙$ is the shear rate. Under the extensional flow, the steady extensional viscosity for mode $p$, $ηE,p$, is \n\n$ηE,p3η0,p=16αG(3+fpE[ϵ˙,αG]+gpE[ϵ˙,αG]),$\n(17)\n\nwith\n\n$fpE[ϵ˙,αG]=1τpϵ˙{1−4(1−2αG)τpϵ˙+4(τpϵ˙)2}1/2$\n(18)\n\nand\n\n$gpE[ϵ˙,αG]=−1τpϵ˙{1+2(1−2αG)τpϵ˙+(τpϵ˙)2}1/2,$\n(19)\n\nwhere $ϵ˙$ is the extension rate. The anisotropic parameter $αG$ is determined by fitting steady shear or extensional viscosity data.\n\nIn addition to the comparison of slip-spring simulation results with predictions of the Giesekus model, we will test another common constitutive equation, namely, the Phan–Thien/Tanner (PTT) model [54,57]. The PTT model is expressed as\n\n$τpσ□p+Y[Tr(σp−Gp∗a2I)](σp−Gp∗a2I)=0,$\n(20)\n\nwhere $σ□p$ is the Gordon–Schowalter convected derivative defined as $σ□p=σ˙p−σp⋅κ+−κ⋅σp+(1−a)(σp⋅D+D⋅σp)$, with $a$ being the parameter describing a slippage of the strand and $D=(κ+κ+)/2$ being the strain rate tensor, $Y$ is a function of the term in brackets that depends on the average conformation of the polymer chains through the trace of the stress tensor as indicated, and $Gp∗$ is the modulus defined as $Gp∗=a2Gp$. In this study, we set $a=1$ to avoid unphysical oscillations produced by the Gordon–Schowalter convected derivative under the shear flow . Thus, $σ□p$ and $Gp∗$ reduce to $σ▽p$ and $Gp$, respectively. As is the case for the Giesekus model, $τp$ and $Gp$ are determined by the multimode Maxwell model fitting of $G(t)$.\n\nTwo functional forms for the dependence of $Y$ on conformation have been suggested, namely, a linear function and an exponential function. The difference between the two forms is evident in the steady extensional viscosity as a function of the extensional rate. For the linear function, the extensional viscosity shows extension hardening followed by a high-extension-rate plateau. For the exponential function, the extensional viscosity shows extension hardening followed by extension thinning. Since typical experimental extensional viscosities obtained by the opposed jet device show extension hardening followed by extension thinning [15–17], we use the exponential function expressed as\n\n$Y[Tr(σp−GpI)]=exp⁡{αPTTGpTr(σp−GpI)},$\n(21)\n\nwhere $αPTT$ is the nonlinear parameter in the PTT model. As in the Giesekus model, the nonlinear parameter $αPTT$ is the same for all modes. That is, we use a single nonlinear parameter $αPTT$ to fit the slip-spring data. When we use the exponential function shown in Eq. (21), the steady shear viscosity can be expressed as \n\n$ηpη0,p=12τpγ˙(W[4αPTTτp2γ˙2]αPTT)1/2,$\n(22)\n\nwhere $W[x]$ is the Lambert W function. Since no analytical solution exists for the steady-state solution under the uniaxial extensional flow, we numerically solve Eq. (20) to obtain steady extensional viscosity.\n\nFinally, in this study, we do not use the popular VCM model to fit the slip-spring data because the VCM model is a two species dumbbell model, whose linear viscoelastic behavior is expressed by the superposition of two relaxation times. Thus, it does not give a good fit to the linear viscoelastic data of the slip-spring model. In addition, the VCM model is based on dilute dumbbells with no entanglement effects, making it physically unsuitable to describe the shear thinning produced by entanglements in entangled WLM solutions.\n\nWe first show the linear viscoelastic (LVE) properties of the micelle-slip-spring model with the Fraenkel spring potential. Before calculating the LVE data, all WLM chains in the ensemble are equilibrated without flow for time $teq$. The relaxation time needed to equilibrate the micelles $teq$ depends on the dimensionless breakage time $ζ$ as $teq≥2(τ¯repτ¯breakeq)1/2$ for $ζ<1$ or $teq≥2τ¯rep$ for $ζ≥1$. Here, $(τ¯repτ¯breakeq)1/2$ is the theoretically estimated longest relaxation time in the fast-breakage limit by Cates .\n\nIn our previous paper , we presented $G(t)$ data from the slip-spring model using Hookean springs obtained by relaxation after a small step shear strain. We here recompute $G(t)$ for the Fraenkel springs from equilibrium simulations using the Green–Kubo formula. We carry out this recalculation for the following two reasons. First, $G(t)$ of Fraenkel springs is slightly different from that of Hookean springs with the same numbers of main chain springs and slip-springs. (For more detail, see Fig. S3 in the supplementary material .) Since $G(t)$ is a small-strain property, predictions of it from the slip-spring model with Fraenkel springs should converge to those with Hookean springs when the Fraenkel spring constant is very large and there are enough short Fraenkel springs to recover Hookean behavior. To simulate with a large Fraenkel spring constant, a very small $Δt$ is required, and thus, it takes a long simulation time to obtain reliable results. Even with this, since the nonlinearity arising from the Fraenkel potential exists even in the small strain region, it is difficult to obtain an accurate $G(t)$ from relaxation after a small step shear strain, as also reported by Lin and Das who compared the relaxation behavior of Hookean and Fraenkel springs . For more detail, see Sec. S4 in the supplementary material . Thus, we use the Green–Kubo formula to obtain accurate $G(t)$ data. To compute $G(t)$, we utilize Eq. (6) and the multiple-tau correlator for efficient calculations .\n\nFigure 2 shows the relaxation modulus $G(t)$ for (a) $⟨Ztube⟩=5$ and (b) $7$ at four dimensionless breakage times $ζ=0.01$ (black), $0.1$ (red), $1$ (blue), and $10$ (magenta). Here, $G0$ is the modulus defined as $G0=⟨N⟩Gchain$ utilized as the unit of stress in Likhtman’s work . After the equilibrium simulation for the time period $teq$, we performed the simulation with $κ=0$ for a time duration $tLVE=(ttotal−teq)=1×105τ0$ to compute $G(t)$, where $ttotal$ is the total simulation time. This $tLVE$ is at least 50 times longer than the longest relaxation time (cf. Table S1 and S2 in the supplementary material ). It should be noted that $G(t)$ for $⟨Ztube⟩=7$ and $ζ=10$ shown in Fig. 2(b) for $t≳3000τ0$ seems not to be converged due to the limited computational time. Thus, only the $G(t)$ data for $t≲3000τ0$ is utilized in the later analysis. From Fig. 2, the short-time relaxation behavior wherein $G(t)$ exceeds unity for $t≲10−2τ0$ is absent for Hookean chains, for which $G(t)$ normalized as described above approaches unity at short times. The rise of $G(t)$ above unity at short time is due to the Fraenkel potential used in this study, as noted in the literature . Moreover, relaxation behavior in the relatively short time region $t≲τ0$ is almost identical for all breakage rates. This is because the breakage time is much larger than the unit time of the system. The difference between different breakage times can be seen in the long-time region. As expected, the relaxation becomes slower with increasing breakage time (i.e., decreasing breakage rate). The $G(t)$ results obtained from slip-spring simulations with the Fraenkel potential are then fitted by the multimode Maxwell model $G(t)=∑pGpexp⁡(−t/τp)$, where $τp$ and $Gp$, respectively, are the relaxation time and strength for mode $p$. The fitting results are shown in Fig. 2 with solid lines. We will use the set of parameters ${τp,Gp}$ determined by these fits to $G(t)$ in the following analysis of nonlinear rheology under the flow. We tabulate the values of ${τp,Gp}$ in Sec. S5 of the supplementary material .\n\nNext, we investigate nonlinear shear rheological properties. In all of the slip-spring simulations in this subsection, which focuses on shear properties, the breakage and rejoining times are assumed to retain constant values (i.e., $τ¯break=τ¯rejoin=τ¯breakeq$) so that the breakage rate does not depend on configuration or stress. Extensional flow experiments for the CTAB/NaSal system suggest that a micelle will break when under a stress of around $3.6×105$ Pa, roughly consistent with molecular dynamics simulations . This scission stress is high enough that micelle scission is likely to occur only under the strong extensional flow and not under the shear flow. The effect of stress-induced micelle breakage at the high-stress level under the shear flow will be addressed in our future work, if necessary.\n\nFigure 3 shows the steady shear viscosities $η≡σxyR/γ˙$ for three dimensionless breakage times (a) $ζ=0.01$, (b) $0.1$, and (c) $1$. The slip-spring simulation results with $⟨N⟩=35$ springs and $⟨Ztube⟩=5$ entanglements are plotted with symbols. As can be seen in Fig. 3, the micelle-slip-spring model can reproduce shear thinning due to the effect of the entanglement constraint. Here, it should be noted that the shear-rate dependencies of the shear viscosity of WLM and polymer solutions are characterized by a power law, i.e., $η∝γ˙n$, but with different exponents. The exponent $n$ for WLM solutions is typically around $n≃−1$ , whereas for nearly monodisperse polymer solutions, it is typically around $n≃−0.8$ . This is an important difference since the power law of $η∝γ˙−1$ in WLM solutions, which corresponds to a stress plateau in the steady-state flow curve, is responsible for shear banding. In Fig. 3, however, the number of entanglements and the shear rate ranges are too small to observe this characteristic exponent for WLMs ($n≃−1$). To investigate the higher shear rate region, the missing mechanisms here (e.g., the entanglement loss under flow) should be incorporated into the micelle-slip-spring model. Although the limiting case in which there is flow-induced loss of entanglements but no regeneration of them is examined in Sec. III D, consideration of a better slip-spring regeneration algorithm under flow is deferred to a future work. Red solid and blue dotted lines in Fig. 3 are the fitting results for $γ˙τ¯R≲1$, where $τ¯R$ is the average Rouse relaxation time, by the Giesekus model [cf. Eqs. (14)$∼$(16)] and the PTT model [cf. Eq. (22)], respectively. The nonlinear parameter appearing in each constitutive equation is the same for all modes. Thus, a single nonlinear parameter is used in each constitutive model to fit the slip-spring data. We observe that the steady shear viscosities for $γ˙τ¯R≲1$ obtained by the slip-spring model can be successfully reproduced by both the Giesekus and the PTT models with nonlinear parameter values summarized in Table I. On the other hand, the slip-spring simulation data for $γ˙τ¯R>1$ are not well reproduced by the constitutive models. Here, we note that there is no physical reason that a near perfect agreement should be obtained since the constitutive models used here are phenomenological and are not microstructurally based. Almost the same trend can be observed for the case of $⟨N⟩=49$ springs and $⟨Ztube⟩=7$ entanglements, as shown in Fig. S5(a) in the supplementary material .\n\nFigure 4 shows transient shear viscosities $η+(t)≡σxyR(t)/γ˙$ for (a) $ζ=0.01$, (b) $0.1$, and (c) $1$. Slip-spring simulation results with $⟨N⟩=35$ (i.e., $⟨Ztube⟩=5$) are plotted with symbols. Here, the same color in each figure means the same strain rate. The linear viscosity growth function $η0+(t)$ computed from the LVE data is shown with the black bold dotted line. The stress overshoot shown by the slip-spring model predictions for $γ˙τ¯R≲1$ qualitatively matches that seen in experiments [5,6]. For the high strain rate region ($γ˙τ¯R>1$), the shear viscosity exceeds the linear viscosity growth function, thus showing a “hardening” prior to the stress overshoot. This may be related to the nonlinearity of the chain extension at high strain rates because of the small number of Kuhn steps per spring in our model. This hardening behavior under strong shear, which is attributed to the finite extensibility of springs, is observed in experiments for CTAB/NaSal systems, as reported by Inoue and co-workers . Similarly, stiff entangled polymers are known to produce strain hardening in shear . This strain hardening in our model will likely weaken if strain-induced entanglement loss at high shear rates is included. As can be seen in the solid lines of Fig. 4, the transient shear viscosities, including the stress overshoots seen for $γ˙τ¯R≲1$, are in good agreement with those predicted by the Giesekus model with the nonlinear parameter determined by the steady state data in Fig. 3. While the steady-state slip-spring simulation data for $γ˙τ¯R≲1$ are reasonably captured by the PTT model as shown in Fig. 3, the transient shear viscosity predictions are poorer than those of the Giesekus model in that the stress overshoot in the PTT model is less prominent than in the slip-spring model. The hardening behavior seen in $γ˙τ¯R>1$ is not reproduced by these constitutive models, where the effect of finite extensibility is not addressed. Almost the same trend can be observed for the case of $⟨N⟩=49$ springs and $⟨Ztube⟩=7$ entanglements, as shown in Fig. S5(b) in the supplementary material . Better predictions by the PTT model might be obtained by setting the slip-parameter in the Gordon–Schowalter convected derivative to $a≠1$. However, doing so produces unphysical stress oscillations under the shear flow, which are not seen in current slip-spring simulations.\n\nFigure 5 shows normal stress coefficients $Ψ1+(t)$$≡N1(t)/γ˙2={σxxR(t)−σyyR(t)}/γ˙2$ for (a) $ζ=0.01$, (b) $0.1$, and (c) $1$ with the same parameters as those in Fig. 4. The first normal stress growth function $Ψ1,0+(t)$ computed from the LVE data is also shown with the black bold dotted line. The Giesekus model (solid lines) can reproduce both the transient and the steady state data predicted by the slip-spring model for $γ˙τ¯R≲1$. However, as is the case for the transient shear viscosity, the PTT model predictions (dotted lines) for both the transient and steady normal stress coefficients deviate from the slip-spring simulation data for $γ˙τ¯R≲1$. Moreover, both constitutive models cannot reproduce $Ψ1+(t)$ for $γ˙τ¯R>1$. Almost the same trend can be observed for the case of $⟨N⟩=49$ springs and $⟨Ztube⟩=7$ entanglements, as shown in Fig. S5(c) in the supplementary material .\n\nFrom the comparison of slip-spring simulation data with the Giesekus and PTT models in Figs. 4 and 5, the Giesekus model matches better the slip-spring data than does the PTT model under a moderate shear flow where the chains do not show significant stretch. Since experimental studies show that the Giesekus model can also reproduce the shear rheological data of WLM solutions [8,9], the micelle-slip-spring model will also be in qualitative agreement with the experimental shear data. We note that the strain hardening behavior seen in both the slip-spring model and the experiments for the CTAB/NaSal system is not reproduced by the Giesekus model. Thus, we can conclude that a constitutive model that can predict rheological properties under a strong shear flow has not yet been developed.\n\nIn experiments of shear-rate regions showing shear thinning, flows of typical WLM solutions show shear banding [22,23]. To predict shear banding, spatially dependent simulations are required. Such simulations with the micelle-slip-spring model incur excessive computational costs. Since the slip-spring model predictions for $γ˙τ¯R≲1$ are well reproduced by the Giesekus model, the latter can be used for such spatially dependent simulations. This will be the goal of our future research whose aim is to use slip-spring simulations to choose and tune a constitutive model to produce similar responses in flows such as shear, extensional, and mixed flows, thus validating it for use in more complex flows.\n\nNext, we investigate uniaxial extensional rheological properties obtained by the micelle-slip-spring model again with Fraenkel springs. As for the shear flow, we first omit stress-induced micelle breakage (i.e., $τ¯break=τ¯breakeq$) and show the basic properties of the micelle-slip-spring model under the extensional flow. However, as discussed above, experiments and recent molecular dynamics simulations reveal that stress-induced micelle breakage (SIMB) is expected when the stress becomes several orders of magnitude larger than the plateau modulus. This might be the case at the high extensional rates examined in this study. Thus, we will also test the effect of SIMB for several conditions.\n\nFigure 6 shows steady extensional viscosities $ηE=σE/ϵ˙$ normalized by the zero shear viscosity $η0$ for three dimensionless breakage times (a) $ζ=0.01$, (b) $0.1$, and (c) $1$ with the steady extensional stress $σE$ defined by $σE=σxxR−(σyyR+σzzR)/2$. Slip-spring simulation results without SIMB are plotted with open symbols. To compare simulation results with the experimental data, it is convenient to introduce the Weissenberg number defined as $Wiext≡ϵ˙⟨τ⟩$, where $⟨τ⟩$ is an average relaxation time defined as $⟨τ⟩=(∑p=1NmodeGpτp2)/(∑p=1NmodeGpτp)$. In Fig. 6, the simulation results showing significant spring stretch beyond the theoretical maximum value are plotted with open squares. Under high extensional flows, the average squared end-to-end vector for the micellar chains, $⟨REE2⟩$, becomes larger than the theoretical maximum value $⟨REE,max2⟩=(⟨N⟩b)2$ since longer chains in the ensemble show significant stretch (for more details, see Fig. S6 in the supplementary material ). This is evident for slower breakage cases where longer chains less frequently break. There are two possible reasons for this overstretch: one is the Fraenkel spring constant that is not large enough; the other is $Δt$ values ($Δt∼10−5τ0$ for high extensional rates) that are not small enough. However, it is not practical to employ larger Fraenkel parameters or smaller $Δt$ values due to the large computational cost. In the current case, however, since the number of these chains is small, the extensional stress is expected not to be much affected by these chains. This is partly supported by the fact that the extensional stress does not show significant divergence (cf. Fig. 7). In Fig. 6, we also plot with gray solid and dotted lines the predictions of the Giesekus model and the PTT model, respectively, with the same nonlinear parameter as that under the shear flow. From Fig. 6, we can observe that extensional viscosities from slip-spring simulations without SIMB monotonically increase at $Wiext≳0.5$. This is a typical behavior obtained by the bead-spring models . On the other hand, extensional viscosities predicted by the Giesekus and PTT models show extension thickening followed by a high Weissenberg number plateau and extension thinning, respectively. Experimentally, Walker and co-workers reported that the extensional viscosities for CPyCl/NaSal solutions show extension thickening followed by extension thinning, where the increase in $ηE$ occurs at $Wiext(expt)≃0.7$ and the maximum in $ηE$ is seen at around $Wiext(expt)$$≃4∼7$ . Here, $Wiext(expt)$ is obtained by multiplying experimental apparent strain rates and a terminal relaxation time $τexpt$, which is evaluated by $τexpt=η0/GN0$. While the slip-spring simulations can reasonably capture the onset of the increase in $ηE$, the original slip-spring simulations without SIMB cannot reproduce extension thinning seen in experiments. Thus, there should be a missing mechanism(s) in the original micelle-slip-spring model under a strong extensional flow. It should be noted that the PTT model can qualitatively capture experimental extensional viscosities, i.e., extension thickening followed by extension thinning. However, the maximum in $ηE$ becomes less prominent with increasing dimensionless breakage time.\n\nAs discussed earlier, we incorporate stress-induced micelle breakage (SIMB) to improve slip-spring predictions under a strong extensional flow. To implement SIMB, the characteristic extensional stress, $σEbreak$, appearing in Eq. (12) should be determined. This can be done with the assistance of the molecular dynamics simulation . For example, for the cetyltrimethylammonium chloride (CTAC)/NaSal system, utilizing the scission energy vs stress data shown in Fig. 6(b) of the work by Mandal and Larson and performing a linear fit [cf. Eq. (11)], we can estimate $σEbreak$ to be $σEbreak≃3×105$ Pa for the CTAC/NaSal system at the salt concentration giving the lowest breakage rate. This value is much higher than the experimental plateau modulus of CTAC/NaSal systems . It should be noted that the characteristic stress might be system dependent and has not been systematically examined. To the best of our knowledge, for the CPyCl/NaSal system, whose extensional properties are reported by Walker and co-workers , no information to estimate the characteristic stress has been reported. Here, based on the finding that $σEbreak$ is much higher than the plateau modulus, we assume a value much lower than that estimated by Mandal and Larson, that is we take $σEbreak=2×104$ Pa, which allows us to find a significant effect of SIMB on rheological properties. (Comparison to the larger value of $σEbreak$, i.e., $σEbreak=1×105$ Pa closer to the value of Mandal and Larson , giving much less extension thinning, is shown in Sec. S8 in the supplementary material .) If we assume the experimental plateau modulus as $GN0≃10$ Pa, the dimensionless characteristic extensional stress is evaluated as $σ~Ebreak≃2×103$. In the slip-spring model, the plateau modulus can be approximated as $GN,ss0=0.18×0.8G0=0.144G0$ . During simulations, we rescale the extensional stress by $GN,ss0$ to compute $σ~E$ and evaluate the breakage time by Eq. (12).\n\nIn Fig. 6, slip-spring simulation results with SIMB are plotted with filled symbols. We can observe that the extensional viscosities show the maximum at around $Wiext$$≃2∼3$, which is almost the same as in the experimental results by Walker and co-workers . Here, $⟨REE2⟩$ with SIMB is smaller than or at most slightly larger than the theoretical maximum value. As compared to the simulations without SIMB, the degree of overstretch is, thus, significantly suppressed (for more details, see Fig. S6 in the supplementary material ). The constitutive models using the nonlinear parameter derived from fitting the shear flow (gray lines in Fig. 6) underestimate $ηE$ obtained by the slip-spring model with SIMB (filled symbols in Fig. 6). To improve the predictions of the constitutive models, we separately fit the Giesekus and PTT models to the extensional data with SIMB of $Wiext≳1$. While we use Eqs. (17)–(19) for the Giesekus model fit, an optimal PTT fit to the extensional data can be obtained by minimizing the value of $∑j{(ηE,jPTT−ηE,j)/ηE,j}2$, where $j$ is the individual data points with different strain rates, $ηE,jPTT$ is the steady extensional viscosity of the PTT model, and $ηE,j$ is the steady extensional viscosity of the slip-spring model. The parameter values under the extensional flow are summarized in Table I. The fitting results are shown in Fig. 6 with red lines. As can be seen in Table I, the Giesekus and PTT models with smaller nonlinear parameter values than under shear flow give better predictions under a uniaxial extensional flow. We can see that the Giesekus model can reproduce the slip-spring simulation results better than the PTT model. However, the Giesekus model cannot predict extension thinning observed in experiments and slip-spring simulations with SIMB. On the other hand, the PTT model can reproduce extension thinning but provides poorer predictions at the onset of extension thickening. It should be noted that the Giesekus and PTT models with the nonlinear parameter determined under the extensional flow give poorer predictions under the shear flow than those shown in Figs. 4 and 5 (for more details, see Fig. S8 in the supplementary material ).\n\nFigure 7 shows transient uniaxial extensional viscosities $ηE+(t)$ for (a) $ζ=0.01$, (b) $0.1$, and (c) $1$. For each $ζ$ value, $ηE+(t)$ curves of the slip-spring model with the smallest strain rate ($ϵ˙τ0=1×10−2$ for $ζ=0.01$, $ϵ˙τ0=3×10−3$ for $ζ=0.1$, and $ϵ˙τ0=1×10−3$ for $ζ=1$) are almost identical to $ηE0+$, which indicates that these strain rates are in the linear response regions. In the small strain rate region ($ϵ˙τ0≤3×10−2$ for $ζ=0.01$, and $ϵ˙τ0≤1×10−2$ for $ζ=0.1$ and $ζ=1$), $ηE+(t)$ curves with and without SIMB are almost identical, which indicates that SIMB does not affect $ηE+(t)$ in the small strain rate region. In the larger strain rate region, the effect of SIMB can be detected for all $ζ$ cases. While transient extension hardening behavior with SIMB is almost identical to that without SIMB, $ηE+(t)$ with SIMB shows a maximum before reaching a steady state, which is the qualitatively different behavior from that without SIMB. As shown in Fig. 6 with filled symbols, the steady extensional viscosities show weak extension thinning.\n\nIn Fig. 8, we plot the Giesekus and PTT model predictions with modified nonlinear parameters for the extensional flow. In the small strain rate region, the Giesekus model predictions (solid lines) can be brought into reasonable agreement with transient extensional data from the slip-spring model. However, deviations from the slip-spring simulation results can be observed for the larger strain rate region. In particular, the viscosity overshoot observed in the slip-spring simulations is not reproduced by the Giesekus model. Almost the same arguments are true for the PTT model predictions (dotted lines). Thus, the nonlinear shear and extensional slip-spring data are not simultaneously reproduced by the Giesekus and PTT models with a single nonlinear parameter.\n\nThus, our attempt to fit slip-spring model predictions with those of common constitutive equations under both shear and extensional flows has not yet succeeded, although the Giesekus model can give good predictions under the moderate shear flow. A complete constitutive equation might, however, be developed by replacing the nonlinear term of the Giesekus equation with a functional form sensitive to the flow type or by changing the nonlinear parameter $αG$ to a flow-type parameter that can distinguish shear from the extensional flow. The latter idea would be tricky and would require choosing a suitable metric of flow type that satisfies the proper invariance principles. If such a flow-type parameter is found that allows the model to predict results in both shear and extension, it would need to be checked by comparing its predictions to those of slip-spring simulations in mixed flows. These mixed flows are intermediate between shear and extension, for which the flow switches between shear to extension as a function of time. Such work is beyond the scope of this study and, therefore, deferred to our future work.\n\nHere, we examine the effect of the entanglement loss, which is one of the important nonlinear mechanisms and is not considered so far, on the rheological properties. We implement this effect by considering only a limiting case where the total number of slip-springs ($Ztotal$) continually decreases and eventually becomes zero. Namely, when a slip-link goes through its chain end, this slip-link and the partner slip-link are simultaneously destroyed, and no regeneration of slip-links is considered. This method is similar to that employed by Moghadam and co-workers . From Figs. 9(a) and 9(b), the shear and extensional viscosities without slip-spring regeneration are smaller than those with slip-spring regeneration. This stress reduction corresponds to the decrease in the number of slip-springs seen in the insets of Figs. 9(a) and 9(b) and should contribute to shear or extension thinning behavior. As can be seen in Fig. 9(a), the strain hardening is hardly observed for the case without slip-spring regeneration. This is because the effect of slip-spring constraint is quickly lost due to fast breakage. Nevertheless, the hardening behavior is expected to reappear since the unentangled bead-spring model with the Fraenkel springs itself shows the hardening under fast shear, as shown in Fig. S9 in the supplementary material .\n\nSince the extent of entanglement loss in the nonlinear flow is still under investigation, our limiting cases of constant entanglement density and no regeneration of entanglements provide useful bounds on the expected behavior. A correct algorithm is somewhere between two cases since the entanglement regeneration process should exist even under the flow. The correct entanglement regeneration algorithm should be developed first for polymers without breakage and rejoining events.\n\nFinally, we present a comparison between the slip-spring results and experimental data for an aqueous solution of 100 mM cetylpyridinium chloride (CPyCl) with 45 mM sodium salicylate (NaSal) examined by Gaudino and co-workers . It should be noted that the experimental results for 100 mM CPyCl with 45 mM NaSal have a rather broad relaxation time distribution, as can be seen in Fig. 10. However, it is typical that entangled linear WLM solutions with a sufficiently high surfactant or salt concentration show a Maxwell-type stress relaxation with a single relaxation time [2–4]. This relaxation behavior is observed if the number of entanglements is large enough that the reptation dynamics is well separated from Rouse modes, and the breakage rate is fast enough that the relaxation process can be described by a single relaxation time. In this study, the computational cost limits the model to WLM solutions with moderate numbers of entanglements ($≲7$), which is not enough to show the Maxwell-type stress relaxation with a single relaxation time. Nevertheless, in the future, we hope to perform nonlinear simulations with a larger number of entanglements by developing a further computationally efficient code or a constitutive model for well-entangled WLMs based on our micelle-slip-spring model.\n\nTo test the ability of the slip-spring model to predict the nonlinear experimental data, the slip-spring parameters (i.e., the number of entanglements $⟨Ztube⟩$ and the dimensionless breakage time $ζ$) should be determined before performing linear and nonlinear rheological simulations. We can estimate $⟨Ztube⟩$ from the linear rheological data with the aid of the following relationship developed from the pointer algorithm by Tan and co-workers :\n\n$Gmin′Gmin″=0.317(⟨L⟩ℓe)0.82=0.317⟨Ztube⟩0.82.$\n(23)\n\nHere, $Gmin″$ is the local minimum in $G″$, $Gmin′$ is the $G′$ value at the frequency at which $G″$ shows its minimum value $Gmin″$, $⟨L⟩$ is the average micelle length, and $ℓe$ is the entanglement length. However, the target experimental data for the CPyCl/NaSal system does not have a clear minimum in $G″$ [see Fig. 1(a) of ]. In this case, it is reasonable to assume that the $Gmin′/Gmin″$ value is a small number, $1−2$, which gives $⟨Ztube⟩≃4−9$. In this study, we, therefore, assume that $Gmin′/Gmin″$ is $1.5$, which gives $⟨Ztube⟩≃7$. (The experimental data showing $Gmin′/Gmin″=1.5$ are at about $ω≃20$$s−1$.) This $⟨Ztube⟩$ value is larger than the value $⟨Ztube⟩=2.5$ that Gaudino and co-workers obtained from an earlier scaling formula lacking a prefactor, namely, $⟨Ztube⟩=GN0/Gmin″$, with $GN0$ being a rough estimate of the plateau modulus since the experimental data do not show a clear plateau from which to obtain $GN0$ . Thus, the value of $⟨Ztube⟩=2.5$ is expected to be smaller than the more realistic value estimated from Eq. (23). For the dimensionless breakage time $ζ$, we use a relatively large value $ζ=10$ since the WLM solution is expected to be well outside the fast breakage limit. This can be inferred from the fact that four modes are required to fit the LVE data (cf. Table I of ).\n\nIn addition to $⟨Ztube⟩$ and $ζ$, we need to estimate the theoretical values of the unit stress $G0(theory)$ and the unit time $τ0(theory)$ of the slip-spring model. Before computing these values, we estimate the plateau modulus of this WLM solution, $GN0$. We use the following relation established by Tan and co-workers : $GN0/Gmin′=4.25/(Gmin′/Gmin″)+0.625$. This equation is recommended for $Gmin′/Gmin″<10$, which is the case in our study. From our assumption of $Gmin′/Gmin″=1.5$ and $Gmin′=G′(ω≃20$$s−1)≃10$ Pa, $GN0$ is determined as $GN0≃35$ Pa. Using the same procedure shown in our previous study , we can determine $G0(theory)$ as $G0(theory)=GN0/(0.8×0.18)≃2×102$ Pa. In the loosely entangled regime, $GN0$ is expressed as $GN0=9.75kBT/ℓblob3$ where $ℓblob$ is the blob size . Using this equation and setting $T=300$ K, we can compute $ℓblob$ as $1.1×10−7$ m. Taking for the persistence length $ℓp$ the typical value $ℓp=25$ nm and using the relation $ℓblob=ℓe0.6ℓp0.4$, we can determine the entanglement length $ℓe$ as $ℓe≃280$ nm. Thus, the semiflexibility factor $αe$ is $αe=ℓe/ℓp≃11$, which is close to the standard value used in the slip-spring model, $αess=14$. In the slip-spring model, the unit of time $τ0$ is $τ0=ξb2/kBT=ξ′b3/kBT$, with $ξ′$ being the drag coefficient per unit micelle length. The value of $ξ′$ can be computed using the drag coefficient for a cylinder of length $ℓblob$ and micelle diameter $d$ as $ξ′=2πηs/ln⁡(ℓblob/d)$. Here, $ηs$ is the solvent viscosity. From $T=300$ K, $ηs=0.85$$mPa⋅s$, and the typical value of $d=4$ nm, the theoretical value of the unit time can be computed as $τ0(theory)≃5×10−5$ s.\n\nFigure 10 compares the storage and loss moduli for the slip-spring simulation with $⟨Ztube⟩=7$ and $ζ=10$ (symbols) with the experimental data (lines). As noted in Sec. III A, we can use the slip-spring data for $t/τ0≲3000$ to accurately evaluate $G′$ and $G″$ (cf. Fig. 2). Here, rather than plot the original $G′$ and $G″$ experimental data, we smooth these data using the fits to them by a set of Maxwell modes whose relaxation times and strengths are given in Table I of . The unit time and unit stress determined by shifting the dimensionless $G′$ and $G″$ curves to match the experimental $G′$ and $G″$ are $τ0=5×10−5s$ and $G0=2×102Pa$, respectively. These values are the same as the theoretically determined unit time and stress since the semiflexibility factor of the slip-spring model $αess=14$ is close to the experimental value of $αe≃11$. Unlike our previous study , we need not correct $τ0$ and $G0$ to address the different $αe$ values between the slip-spring simulation and the experiment. From Fig. 10, we can see that $G′$ and $G″$ obtained from slip-spring simulation are in reasonable agreement with the experimental data. This indicates that the choices of slip-spring parameters, i.e., $⟨Ztube⟩$ and $ζ$, are reasonable.\n\nFigure 11 compares $η+(t)$ predicted by the slip-spring simulations without SIMB and entanglement loss for $⟨Ztube⟩=7$ and $ζ=10$ (lines) with the experimental data (symbols). Here, we also use the values of $τ0$ and $G0$ determined in Fig. 10. The dimensionless shear rates $γ˙τ0$ in the slip-spring model that correspond to the experimental values of $20$, $40$, and $80s−1$ are, therefore, about $γ˙τ0≃1×10−3$, $2×10−3$, and $4×10−3$, respectively. The slip-spring results in Fig. 11 are shown with solid lines, and $η0+(t)$ computed from the LVE data is presented with the black dotted line. Figure 11 indicates that the slip-spring data are in good agreement with the experimental shear data. Again, this shows that the choices of slip-spring parameters are reasonable.\n\nTo the best of our knowledge, experimental data in the extensional flow for WLM solutions with micelles of length accessible by the slip-spring model are not available currently. Extensional measurements for WLM solutions with low viscosities are typically conducted by the Capillary Breakup Extensional Rheometry (CaBER). However, the strain rate of the CaBER measurements is not constant over time, making it difficult to compare the extensional experimental data with the slip-spring data. Additionally, an initial step extensional strain in the CaBER measurements might affect the extensional viscosity . It is difficult to produce the initial state of micellar chains for the slip-spring simulations. The comparison with extensional experiments is an important problem to study in the future.\n\nWe have presented linear and nonlinear rheological predictions of a mesoscopic simulation model for entangled WLM solutions, the so-called “micelle-slip-spring model” based on the polymer slip-spring model proposed by Likhtman with breakage and rejoining events added to reproduce WLM dynamics . To capture the nonlinear rheological properties, instead of the Hookean springs employed in our previous study , we introduced the Fraenkel potential for main-chain springs and slip-springs. Additionally, to improve extensional properties under the strong extensional flow, we incorporated stress-induced micelle breakage into the micelle-slip-spring model. We used this extended model to examine both linear and nonlinear rheological properties.\n\nIn the linear response region, the relaxation modulus $G(t)$ was computed using the Green–Kubo formula from equilibrium simulation. We found that $G(t)$ for Frankel springs differs slightly from that for Hookean springs due to the difference in spring potential. The results for $G(t)$ are fitted using the multimode Maxwell model to determine relaxation times and strengths.\n\nThis micelle-slip-spring model with Fraenkel springs can reproduce the characteristic rheological behavior in start-up and steady-state shear of WLM solutions. That is, the transient shear viscosities for moderate strain rates show the experimentally observed overshoot and the steady shear viscosities show the observed shear thinning. The experimentally observed hardening behavior under the strong shear flow can be reproduced by the micelle-slip-spring model with finite extensibility. The slip-spring simulation results for the strain rates where the chains do not show significant chain stretch were fitted by two common phenomenological constitutive equations: the Giesekus model and the PTT model. The steady shear viscosity obtained by the slip-spring model can be well reproduced by both constitutive models. Transient shear predictions by the Giesekus model are also in good agreement with those of the slip-spring model. This result is qualitatively the same as in experimental observations. In contrast, transient predictions by the PTT model (with the non-affine deformation parameter set to zero to avoid spurious oscillations in shear) deviate from those by the slip-spring model. These results indicate that the Giesekus model captures better the shear properties of the slip-spring model for not so high shear rates than does the PTT model.\n\nThe micelle-slip-spring model was also applied to predict rheological properties under the uniaxial extensional flow. The Fraenkel potential prevents the overstretch of WLM chains under the extensional flow, and thus, we can reach steady-state extensional viscosities. While the micelle-slip-spring model reasonably reproduces the onset of extension thickening behavior, this model fails to predict extension thinning behavior observed in experiments. Thus, we incorporated stress-induced micelle breakage (SIMB), which allows the simulation results with SIMB to successfully capture extension thinning behavior. We also show the Giesekus and PTT constitutive model predictions with the same nonlinear parameter as under shear flow underestimate the slip-spring results. To reproduce the steady extensional data of the slip-spring model, a smaller value of the nonlinear parameter (corresponding to smaller deviations from the upper-convected Maxwell model) is needed to fit the slip-spring results in the extensional flow. However, the constitutive model predictions even with the modified nonlinear parameter cannot capture the transient extensional viscosities especially under the strong flow. Thus, it is not possible to predict both shear and extensional properties by the Giesekus and PTT models with a single constant nonlinear parameter.\n\nFurthermore, we examined the effect of entanglement loss on rheological properties by considering the limiting case in which we disable the regeneration of slip-springs when previous ones disappear, so that the number of slip-springs continuously decreases and eventually becomes zero. We found that the stress without the slip-spring regeneration is smaller than that with slip-spring regeneration. Thus, the effect of entanglement loss should contribute to shear/extension thinning behavior. A correct algorithm for entanglement loss is somewhere between two cases of constant entanglement density and no regeneration of slip-springs and should be developed first for unbreakable polymers.\n\nThe slip-spring simulation results were also compared with experimental linear rheological and nonlinear shear data. The number of entanglements $⟨Ztube⟩$ was estimated from the linear rheological data using the recent relation found by Tan and co-workers , and the dimensionless breakage time $ζ$ was set to be large based on the inference that the WLM solution is well outside the fast breakage limit. The simulation results for $G′$ and $G″$ were compared with the experimental results, and the unit time $τ0$ and the stress $G0$ were determined. These $τ0$ and $G0$ are the same as expected theoretical values, indicating the validity of the chosen parameters. Moreover, nonlinear shear viscosities obtained by the slip-spring model are in reasonable agreement with the experimental shear data. These results support the predictive ability of the slip-spring model under the homogeneous shear flow.\n\nFurther studies are required to understand more deeply the rheological properties of WLM solutions using the micelle-slip-spring model. For example, strain hardening in nonlinear stress relaxation is experimentally detected in several WLM systems [64,65], which has been linked to shear-induced associations of WLMs. Hence, to reproduce strain hardening in nonlinear stress relaxation, it might be important to incorporate this mechanism into the micelle-slip-spring model. Moreover, it would be interesting to examine the change in strain-rate dependence of shear stress, which is related to shear banding, caused by stress-induced acceleration of micelle breakage. Additionally, the extensional rheology obtained by the slip-spring model should be compared with experimental results. The current simulations are limited to the homogeneous flow. To incorporate inhomogeneous shear such as shear banding, the equations of conservation of mass and momentum should be coupled. While “multiscale” slip-link simulations have been performed for unbreakable polymer melts , such simulations are currently too extensive to be carried out for WLM solutions since an ensemble of many WLM chains is required. Thus, the fitting of predictions of the slip-spring model by a phenomenological constitutive equation, which is attempted for the first time in this study, might be effective for such a purpose. This might be done more efficiently in the future with the aid of machine-learning techniques . We hope to continue our study along these directions.\n\nT.S. would like to express gratitude to Professor T. Taniguchi for his comments and fruitful discussion on this work. This work was partially supported by JSPS KAKENHI under Grant No. 21K13893. R.G.L. was funded by the National Science Foundation (NSF) under Grant No. CBET-1907517. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of NSF.\n\nThe authors have no conflicts to disclose.\n\nEthics approval is not required.\n\n1.\nLarson\n,\nR. G.\n,\nThe Structure and Rheology of Complex Fluids\n(\nOxford University\n,\nNew York\n,\n1999\n).\n2.\nShikata\n,\nT.\n,\nH.\nHirata\n, and\nT.\nKotaka\n, “\nMicelle formation of detergent molecules in aqueous media: Viscoelastic properties of aqueous cetyltrimethylammonium bromide solutions\n,”\nLangmuir\n3\n,\n1081\n1086\n(\n1987\n).\n3.\nBerret\n,\nJ. F.\n,\nJ.\nAppell\n, and\nG.\nPorte\n, “\nLinear rheology of entangled wormlike micelles\n,”\nLangmuir\n9\n,\n2851\n2854\n(\n1993\n).\n4.\nSoltero\n,\nJ. F. A.\n,\nJ. E.\nPuig\n, and\nO.\nManero\n, “\nRheology of the cetyltrimethylammonium tosilate-water system. 2. Linear viscoelastic regime\n,”\nLangmuir\n12\n,\n2654\n2662\n(\n1996\n).\n5.\nShikata\n,\nT.\n,\nH.\nHirata\n,\nE.\nTakatori\n, and\nK.\nOsaki\n, “\nNonlinear viscoelastic behavior of aqueous detergent solutions\n,”\nJ. Non-Newtonian Fluid Mech.\n28\n,\n171\n182\n(\n1988\n).\n6.\nRehage\n,\nH.\n, and\nH.\nHoffmann\n, “\nViscoelastic surfactant solutions: Model systems for rheological research\n,”\nMol. Phys.\n74\n,\n933\n973\n(\n1991\n).\n7.\nGaudino\n,\nD.\n,\nS.\nCostanzo\n,\nG.\nIanniruberto\n,\nN.\nGrizzuti\n, and\nR.\nPasquino\n, “\nLinear wormlike micelles behave similarly to entangled linear polymers in fast shear flows\n,”\nJ. Rheol.\n64\n,\n879\n888\n(\n2020\n).\n8.\nYesilata\n,\nB.\n,\nC.\nClasen\n, and\nG. H.\nMcKinley\n, “\nNonlinear shear and extensional flow dynamics of wormlike surfactant solutions\n,”\nJ. Non-Newtonian Fluid Mech.\n133\n,\n73\n90\n(\n2006\n).\n9.\nGurnon\n,\nA. K.\n, and\nN. J.\nWagner\n, “\nLarge amplitude oscillatory shear (LAOS) measurements to obtain constitutive equation model parameters: Giesekus model of banding and nonbanding wormlike micelles\n,”\nJ. Rheol.\n56\n,\n333\n351\n(\n2012\n).\n10.\nHelgeson\n,\nM. E.\n,\nM. D.\nReichert\n,\nY. T.\nHu\n, and\nN. J.\nWagner\n, “\nRelating shear banding, structure, and phase behavior in wormlike micellar solutions\n,”\nSoft Matter\n5\n,\n3858\n3869\n(\n2009\n).\n11.\nHelgeson\n,\nM. E.\n,\nP. A.\nVasquez\n,\nE. W.\nKaler\n, and\nN. J.\nWagner\n, “\nRheology and spatially resolved structure of cetyltrimethylammonium bromide wormlike micelles through the shear banding transition\n,”\nJ. Rheol.\n53\n,\n727\n756\n(\n2009\n).\n12.\nInoue\n,\nT.\n,\nY.\nInoue\n, and\nH.\nWatanabe\n, “\nNonlinear rheology of CTAB/NaSal aqueous solutions: Finite extensibility of a network of wormlike micelles\n,”\nLangmuir\n21\n,\n1201\n1208\n(\n2005\n).\n13.\nRothstein\n,\nJ. P.\n, “\nTransient extensional rheology of wormlike micelle solutions\n,”\nJ. Rheol.\n47\n,\n1227\n1247\n(\n2003\n).\n14.\nBhardwaj\n,\nA.\n,\nE.\nMiller\n, and\nJ. P.\nRothstein\n, “\nFilament stretching and capillary breakup extensional rheometry measurements of viscoelastic wormlike micelle solutions\n,”\nJ. Rheol.\n51\n,\n693\n719\n(\n2007\n).\n15.\nPrud’homme\n,\nR. K.\n, and\nG. G.\nWarr\n, “\nElongational flow of solutions of rodlike micelles\n,”\nLangmuir\n10\n,\n3419\n3426\n(\n1994\n).\n16.\nHu\n,\nY.\n,\nS. Q.\nWang\n, and\nA. M.\nJamieson\n, “\nElongational flow behavior of cetyltrimethylammonium bromide/sodium salicylate surfactant solutions\n,”\nJ. Phys. Chem.\n98\n,\n8555\n8559\n(\n1994\n).\n17.\nWalker\n,\nL. M.\n,\nP.\nMoldenaers\n, and\nJ.-F.\nBerret\n, “\nMacroscopic response of wormlike micelles to elongational flow\n,”\nLangmuir\n12\n,\n6309\n6314\n(\n1996\n).\n18.\nShikata\n,\nT.\n,\nS. J.\nDahman\n, and\nD. S.\nPearson\n, “\nRheo-optical behavior of wormlike micelles\n,”\nLangmuir\n10\n,\n3470\n3476\n(\n1994\n).\n19.\nSchubert\n,\nB. A.\n,\nE. W.\nKaler\n, and\nN. J.\nWagner\n, “\nThe microstructure and rheology of mixed cationic/anionic wormlike micelles\n,”\nLangmuir\n19\n,\n4079\n4089\n(\n2003\n).\n20.\nOelschlaeger\n,\nC.\n,\nM.\nSchopferer\n,\nF.\nScheffold\n, and\nN.\nWillenbacher\n, “\nLinear-to-branched micelles transition: A rheometry and diffusing wave spectroscopy (DWS) study\n,”\nLangmuir\n25\n,\n716\n723\n(\n2009\n).\n21.\nGiesekus\n,\nH.\n, “\nA simple constitutive equation for polymer fluids based on the concept of deformation-dependent tensorial mobility\n,”\nJ. Non-Newtonian Fluid Mech.\n11\n,\n69\n109\n(\n1982\n).\n22.\nOlmsted\n,\nP. D.\n, “\nPerspectives on shear banding in complex fluids\n,”\nRheol. Acta\n47\n,\n283\n300\n(\n2008\n).\n23.\nLerouge\n,\nS.\n, and\nJ. F.\nBerret\n, “Shear-induced transitions and instabilities in surfactant wormlike micelles,” in Polymer Characterization. Advances in Polymer Science, edited by K. Dusek and J. F. Joanny (Springer, Berlin, 2010), Vol. 230.\n24.\nRothstein\n,\nJ. P.\n, and\nH.\n, “\nComplex flows of viscoelastic wormlike micelle solutions\n,”\nJ. Non-Newtonian Fluid Mech.\n285\n,\n104382\n(\n2020\n).\n25.\nCates\n,\nM. E.\n, “\nReptation of living polymers: Dynamics of entangled polymers in the presence of reversible chain-scission reactions\n,”\nMacromolecules\n20\n,\n2289\n2296\n(\n1987\n).\n26.\nTurner\n,\nM. S.\n, and\nM. E.\nCates\n, “\nLinear viscoelasticity of wormlike micelles: A comparison of micellar reaction kinetics\n,”\nJ. Phys. II Fr.\n2\n,\n503\n519\n(\n1992\n).\n27.\nZou\n,\nW.\n, and\nR. G.\nLarson\n, “\nA mesoscopic simulation method for predicting the rheology of semi-dilute wormlike micellar solutions\n,”\nJ. Rheol.\n58\n,\n681\n721\n(\n2014\n).\n28.\nZou\n,\nW.\n,\nX.\nTang\n,\nM.\nWeaver\n,\nP.\nKoenig\n, and\nR. G.\nLarson\n, “\nDetermination of characteristic lengths and times for wormlike micelle solutions from rheology using a mesoscopic simulation method\n,”\nJ. Rheol.\n59\n,\n903\n934\n(\n2015\n).\n29.\nZou\n,\nW.\n,\nG.\nTan\n,\nH.\nJiang\n,\nK.\nVogtt\n,\nM.\nWeaver\n,\nP.\nKoenig\n,\nG.\nBeaucage\n, and\nR. G.\nLarson\n, “\nFrom well-entangled to partially-entangled wormlike micelles\n,”\nSoft Matter\n15\n,\n642\n655\n(\n2019\n).\n30.\nTan\n,\nG.\n,\nW.\nZou\n,\nM.\nWeaver\n, and\nR. G.\nLarson\n, “\nDetermining threadlike micelle lengths from rheometry\n,”\nJ. Rheol.\n65\n,\n59\n71\n(\n2021\n).\n31.\nVasquez\n,\nP. A.\n,\nG. H.\nMcKinley\n, and\nL. P.\nCook\n, “\nA network scission model for wormlike micellar solutions. I. Model formulation and viscometric flow predictions\n,”\nJ. Non-Newtonian Fluid Mech.\n144\n,\n122\n139\n(\n2007\n).\n32.\nPipe\n,\nC. J.\n,\nN. J.\nKim\n,\nP. A.\nVasquez\n,\nL. P.\nCook\n, and\nG. H.\nMcKinley\n, “\nWormlike micellar solutions: II. Comparison between experimental data and scission model predictions\n,”\nJ. Rheol.\n54\n,\n881\n913\n(\n2010\n).\n33.\nPeterson\n,\nJ. D.\n, and\nM. E.\nCates\n, “\nA full-chain tube-based constitutive model for living linear polymers\n,”\nJ. Rheol.\n64\n,\n1465\n1496\n(\n2020\n).\n34.\nPeterson\n,\nJ. D.\n, and\nL. G.\nLeal\n, “\nPredictions for flow-induced scission in well-entangled living polymers: The ‘living Rolie-Poly’ model\n,”\nJ. Rheol.\n65\n,\n959\n982\n(\n2021\n).\n35.\nPeterson\n,\nJ. D.\n, and\nM. E.\nCates\n, “\nConstitutive models for well-entangled living polymers beyond the fast-breaking limit\n,”\nJ. Rheol.\n65\n,\n633\n662\n(\n2021\n).\n36.\nSato\n,\nT.\n,\nS.\n,\nG.\nTan\n, and\nR. G.\nLarson\n, “\nA slip-spring simulation model for predicting linear and nonlinear rheology of entangled wormlike micellar solutions\n,”\nJ. Rheol.\n64\n,\n1045\n1061\n(\n2020\n).\n37.\nLikhtman\n,\nA. E.\n, “\nSingle-chain slip-link model of entangled polymers: Simultaneous description of neutron spin-echo, rheology, and diffusion\n,”\nMacromolecules\n38\n,\n6128\n6139\n(\n2005\n).\n38.\nMasubuchi\n,\nY.\n, “\nSimulating the flow of entangled polymers\n,”\nAnnu. Rev. Chem. Biomol. Eng.\n5\n,\n11\n33\n(\n2014\n).\n39.\nRubinstein\n,\nM.\n, and\nR. H.\nColby\n,\nPolymer Physics\n(\nOxford University\n,\nNew York\n,\n2003\n).\n40.\nUneyama\n,\nT.\n, and\nY.\nMasubuchi\n, “\nMulti-chain slip-spring model for entangled polymer dynamics\n,”\nJ. Chem. Phys.\n137\n,\n154902\n(\n2012\n).\n41.\nZhu\n,\nJ.\n,\nA. E.\nLikhtman\n, and\nZ.\nWang\n, “\nArm retraction dynamics of entangled star polymers: A forward flux sampling method study\n,”\nJ. Chem. Phys.\n147\n,\n044907\n(\n2017\n).\n42.\nHu\n,\nY. T.\n, and\nA.\nLips\n, “\nKinetics and mechanism of shear banding in an entangled micellar solution\n,”\nJ. Rheol.\n49\n,\n1001\n1027\n(\n2005\n).\n43.\nFraenkel\n,\nG. K.\n, “\nVisco-elastic effect in solutions of simple particles\n,”\nJ. Chem. Phys.\n20\n,\n642\n647\n(\n1952\n).\n44.\nRamírez\n,\nJ.\n,\nS. K.\nSukumaran\n, and\nA. E.\nLikhtman\n, “\nSignificance of cross correlations in the stress relaxation of polymer melts\n,”\nJ. Chem. Phys.\n126\n,\n244904\n(\n2007\n).\n45.\nSee supplementary material at https://www.scitation.org/doi/suppl/10.1122/8.0000426 for further results obtained from the slip-spring simulations.\n46.\nDoi\n,\nM.\n, and\nS. F.\nEdwards\n,\nThe Theory of Polymer Dynamics\n(\nOxford University\n,\nNew York\n,\n1986\n).\n47.\nMandal\n,\nT.\n, and\nR. G.\nLarson\n, “\nStretch and breakage of wormlike micelles under uniaxial strain: A simulation study and comparison with experimental results\n,”\nLangmuir\n34\n,\n12600\n12608\n(\n2018\n).\n48.\nLikhtman\n,\nA. E.\n, and\nT. C. B.\nMcLeish\n, “\nQuantitative theory for linear dynamics of linear entangled polymers\n,”\nMacromolecules\n35\n,\n6332\n6343\n(\n2002\n).\n49.\nRamírez\n,\nJ.\n,\nS. K.\nSukumaran\n, and\nA. E.\nLikhtman\n, “\nHierarchical modeling of entangled polymers\n,”\nMacromol. Symp.\n252\n,\n119\n129\n(\n2007\n).\n50.\nLin\n,\nY.-H.\n, and\nA. K.\nDas\n, “\nMonte Carlo simulations of stress relaxation of entanglement-free Fraenkel chains. I. Linear polymer viscoelasticity\n,”\nJ. Chem. Phys.\n126\n,\n074902\n(\n2007\n).\n51.\nIanniruberto\n,\nG.\n,\nA.\nBrasiello\n, and\nG.\nMarrucci\n, “\nModeling unentangled polystyrene melts in fast elongational flows\n,”\nMacromolecules\n52\n,\n4610\n4616\n(\n2019\n).\n52.\nIanniruberto\n,\nG.\n, and\nG.\nMarrucci\n, “\nOrigin of shear thinning in unentangled polystyrene melts\n,”\nMacromolecules\n53\n,\n1338\n1345\n(\n2020\n).\n53.\nDalal\n,\nI. S.\n,\nN.\nHoda\n, and\nR. G.\nLarson\n, “\nMultiple regimes of deformation in shearing flow of isolated polymers\n,”\nJ. Rheol.\n56\n,\n305\n332\n(\n2012\n).\n54.\nLarson\n,\nR. G.\n,\nConstitutive Equations for Polymer Melts and Solutions, Butterworths Series in Chemical Engineering\n(\nButterworth\n,\nSydney\n,\n1988\n).\n55.\nKhan\n,\nS. A.\n, and\nR. G.\nLarson\n, “\nComparison of simple constitutive equations for polymer melts in shear and biaxial and uniaxial extensions\n,”\nJ. Rheol.\n31\n,\n207\n234\n(\n1987\n).\n56.\nBird\n,\nR. B.\n,\nR. C.\nArmstrong\n, and\nO.\nHassager\n, Dynamics of Polymeric Liquids, Fluid Mechanics Vol. 1 (John Wiley & Sons, New York, 1987).\n57.\nPhan Thien\n,\nN.\n, and\nR. I.\nTanner\n, “\nA new constitutive equation derived from network theory\n,”\nJ. Non-Newtonian Fluid Mech.\n2\n,\n353\n365\n(\n1977\n).\n58.\nSyrakos\n,\nA.\n,\nY.\nDimakopoulos\n, and\nJ.\nTsamopoulos\n, “\nTheoretical study of the flow in a fluid damper containing high viscosity silicone oil: Effects of shear-thinning and viscoelasticity\n,”\nPhys. Fluids\n30\n,\n030708\n(\n2018\n).\n59.\nRamírez\n,\nJ.\n,\nS. K.\nSukumaran\n,\nB.\nVorselaars\n, and\nA. E.\nLikhtman\n, “\nEfficient on the fly calculation of time correlation functions in computer simulations\n,”\nJ. Chem. Phys.\n133\n,\n154103\n(\n2010\n).\n60.\nFerry\n,\nJ. D.\n,\nViscoelastic Properties of Polymers\n(\nJohn Wiley & Sons\n,\nNew York\n,\n1980\n).\n61.\nXu\n,\nJ.\n,\nY.\nTseng\n, and\nD.\nWirtz\n, “\nStrain hardening of actin filament networks: Regulation by the dynamic cross-linking protein $α$-actinin\n,”\nJ. Biol. Chem.\n275\n,\n35886\n35892\n(\n2000\n).\n62.\nLutz-Bueno\n,\nV.\n,\nR.\nPasquino\n,\nM.\nLiebi\n,\nJ.\nKohlbrecher\n, and\nP.\nFischer\n, “\nViscoelasticity enhancement of surfactant solutions depends on molecular conformation: Influence of surfactant headgroup structure and its counterion\n,”\nLangmuir\n32\n,\n4239\n4250\n(\n2016\n).\n63.\n,\nS.\n,\nI. S.\nDalal\n, and\nR. G.\nLarson\n, “\nSlip-spring and kink dynamics models for fast extensional flow of entangled polymeric fluids\n,”\nPolymers\n11\n,\n465\n(\n2019\n).\n64.\nBrown\n,\nE. F.\n,\nW. R.\nBurghardt\n, and\nD. C.\nVenerus\n, “\nTests of the Lodge-Meissner relation in anomalous nonlinear step strain of an entangled wormlike micelle solution\n,”\nLangmuir\n13\n,\n3902\n3904\n(\n1997\n).\n65.\n,\nA. A.\n,\nM. J.\nSolomon\n,\nR. G.\nLarson\n, and\nX.\nXia\n, “\nConcentration, salt and temperature dependence of strain hardening of step shear in CTAB/NaSal surfactant solutions\n,”\nJ. Rheol.\n61\n,\n967\n977\n(\n2017\n).\n66.\nSato\n,\nT.\n,\nK.\n, and\nT.\nTaniguchi\n, “\nMultiscale simulations of flows of a well-entangled polymer melt in a contraction-expansion channel\n,”\nMacromolecules\n52\n,\n547\n564\n(\n2019\n).\n67.\nSeryo\n,\nN.\n,\nT.\nSato\n,\nJ. J.\nMolina\n, and\nT.\nTaniguchi\n, “\nLearning the constitutive relation of polymeric flows with memory\n,”\nPhys. Rev. Res.\n2\n,\n033107\n(\n2020\n)." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9117658,"math_prob":0.9851735,"size":69909,"snap":"2023-40-2023-50","text_gpt3_token_len":14591,"char_repetition_ratio":0.18708247,"word_repetition_ratio":0.05564213,"special_character_ratio":0.19398075,"punctuation_ratio":0.100884244,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99064994,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-02T20:39:49Z\",\"WARC-Record-ID\":\"<urn:uuid:b56104c5-b41f-47a1-91e5-df2063359e62>\",\"Content-Length\":\"787575\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:60ceae6c-0a63-42e3-8316-38d86c81fd1e>\",\"WARC-Concurrent-To\":\"<urn:uuid:ef7a6aa4-2d73-4c08-9d0b-e0e79f5f4d74>\",\"WARC-IP-Address\":\"20.85.172.21\",\"WARC-Target-URI\":\"https://pubs.aip.org/sor/jor/article-split/66/3/639/2846210/Nonlinear-rheology-of-entangled-wormlike-micellar\",\"WARC-Payload-Digest\":\"sha1:UPZEYG2B3QEXWW6T5TPTP567YCUYQW2H\",\"WARC-Block-Digest\":\"sha1:NVTMPSCIAOS45QU77CNGUWQ7ROSM232B\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233511021.4_warc_CC-MAIN-20231002200740-20231002230740-00316.warc.gz\"}"}
https://metacpan.org/release/RKOBES/Math-Cephes-0.47/view/lib/Math/Cephes/Matrix.pm
[ "# NAME\n\nMath::Cephes::Matrix - Perl interface to the cephes matrix routines\n\n# SYNOPSIS\n\n`````` use Math::Cephes::Matrix qw(mat);\n# 'mat' is a shortcut for Math::Cephes::Matrix->new\nmy \\$M = mat([ [1, 2, -1], [2, -3, 1], [1, 0, 3]]);\nmy \\$C = mat([ [1, 2, 4], [2, 9, 2], [6, 2, 7]]);\nmy \\$D = \\$M->add(\\$C); # D = M + C\nmy \\$Dc = \\$D->coef;\nfor (my \\$i=0; \\$i<3; \\$i++) {\nprint \"row \\$i:\\n\";\nfor (my \\$j=0; \\$j<3; \\$j++) {\nprint \"\\tcolumn \\$j: \\$Dc->[\\$i]->[\\$j]\\n\";\n}\n}``````\n\n# DESCRIPTION\n\nThis module is a layer on top of the basic routines in the cephes math library for operations on square matrices. In the following, a Math::Cephes::Matrix object is created as\n\n`` my \\$M = Math::Cephes::Matrix->new(\\$arr_ref);``\n\nwhere `\\$arr_ref` is a reference to an array of arrays, as in the following example:\n\n`` \\$arr_ref = [ [1, 2, -1], [2, -3, 1], [1, 0, 3] ]``\n\nwhich represents\n\n`````` / 1 2 -1 \\\n| 2 -3 1 |\n\\ 1 0 3 /``````\n\nA copy of a Math::Cephes::Matrix object may be done as\n\n`` my \\$M_copy = \\$M->new();``\n\n## Methods\n\ncoef: get coefficients of the matrix\n`````` SYNOPSIS:\n\nmy \\$c = \\$M->coef;\n\nDESCRIPTION:``````\n\nThis returns an reference to an array of arrays containing the coefficients of the matrix.\n\nclr: set all coefficients equal to a value.\n`````` SYNOPSIS:\n\n\\$M->clr(\\$n);\n\nDESCRIPTION:``````\n\nThis sets all the coefficients of the matrix identically to \\$n. If \\$n is not given, a default of 0 is used.\n\n`````` SYNOPSIS:\n\nDESCRIPTION:``````\n\nThis sets \\$P equal to \\$M + \\$N.\n\nsub: subtract two matrices\n`````` SYNOPSIS:\n\n\\$P = \\$M->sub(\\$N);\n\nDESCRIPTION:``````\n\nThis sets \\$P equal to \\$M - \\$N.\n\nmul: multiply two matrices or a matrix and a vector\n`````` SYNOPSIS:\n\n\\$P = \\$M->mul(\\$N);\n\nDESCRIPTION:``````\n\nThis sets \\$P equal to \\$M * \\$N. This method can handle matrix multiplication, when \\$N is a matrix, as well as matrix-vector multiplication, where \\$N is an array reference representing a column vector.\n\ndiv: divide two matrices\n`````` SYNOPSIS:\n\n\\$P = \\$M->div(\\$N);\n\nDESCRIPTION:``````\n\nThis sets \\$P equal to \\$M * (\\$N)^(-1).\n\ninv: invert a matrix\n`````` SYNOPSIS:\n\n\\$I = \\$M->inv();\n\nDESCRIPTION:``````\n\nThis sets \\$I equal to (\\$M)^(-1).\n\ntransp: transpose a matrix\n`````` SYNOPSIS:\n\n\\$T = \\$M->transp();\n\nDESCRIPTION:``````\n\nThis sets \\$T equal to the transpose of \\$M.\n\nsimq: solve simultaneous equations\n`````` SYNOPSIS:\n\nmy \\$M = Math::Cephes::Matrix->new([ [1, 2, -1], [2, -3, 1], [1, 0, 3]]);\nmy \\$B = [2, -1, 10];\nmy \\$X = \\$M->simq(\\$B);\nfor (my \\$i=0; \\$i<3; \\$i++) {\nprint \"X[\\$i] is \\$X->[\\$i]\\n\";\n}``````\n\nwhere \\$M is a Math::Cephes::Matrix object, \\$B is an input array reference, and \\$X is an output array reference.\n\n`` DESCRIPTION:``\n\nA set of N simultaneous equations may be represented in matrix form as\n\n`` M X = B``\n\nwhere M is an N x N square matrix and X and B are column vectors of length N.\n\neigens: eigenvalues and eigenvectors of a real symmetric matrix\n`````` SYNOPSIS:\n\nmy \\$S = Math::Cephes::Matrix->new([ [1, 2, 3], [2, 2, 3], [3, 3, 4]]);\nmy (\\$E, \\$EV1) = \\$S->eigens();\nmy \\$EV = \\$EV1->coef;\nfor (my \\$i=0; \\$i<3; \\$i++) {\nprint \"For i=\\$i, with eigenvalue \\$E->[\\$i]\\n\";\nmy \\$v = [];\nfor (my \\$j=0; \\$j<3; \\$j++) {\n\\$v->[\\$j] = \\$EV->[\\$i]->[\\$j];\n}\nprint \"The eigenvector is @\\$v\\n\";\n}``````\n\nwhere \\$M is a Math::Cephes::Matrix object representing a real symmetric matrix. \\$E is an array reference containing the eigenvalues of \\$M, and \\$EV is a Math::Cephes::Matrix object representing the eigenvalues, the ith row corresponding to the ith eigenvalue.\n\n`` DESCRIPTION:``\n\nIf M is an N x N real symmetric matrix, and X is an N component column vector, the eigenvalue problem\n\n`` M X = lambda X``\n\nwill in general have N solutions, with X the eigenvectors and lambda the eigenvalues.\n\n# BUGS\n\nPlease report any to Randy Kobes <[email protected]>\n\nThe C code for the Cephes Math Library is Copyright 1984, 1987, 1989, 2002 by Stephen L. Moshier, and is available at http://www.netlib.org/cephes/. Direct inquiries to 30 Frost Street, Cambridge, MA 02140.\n\nThe perl interface is copyright 2000, 2002 by Randy Kobes. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.6172007,"math_prob":0.9923845,"size":4735,"snap":"2021-43-2021-49","text_gpt3_token_len":1564,"char_repetition_ratio":0.13548933,"word_repetition_ratio":0.07429963,"special_character_ratio":0.34530094,"punctuation_ratio":0.21626794,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9995877,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-24T06:32:56Z\",\"WARC-Record-ID\":\"<urn:uuid:c9d8d3ba-4a63-4047-a6e2-93708809b90f>\",\"Content-Length\":\"37867\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a72c7161-4535-4b16-8c47-e10cb736034f>\",\"WARC-Concurrent-To\":\"<urn:uuid:a131d96b-07b4-484d-9de2-9acfe35e2b1c>\",\"WARC-IP-Address\":\"151.101.66.217\",\"WARC-Target-URI\":\"https://metacpan.org/release/RKOBES/Math-Cephes-0.47/view/lib/Math/Cephes/Matrix.pm\",\"WARC-Payload-Digest\":\"sha1:XCH6B2X2RJYRNRZOGLWVSVQG5D5XXAMI\",\"WARC-Block-Digest\":\"sha1:UJOONCIFP4DYIWRAVDPOAIQNCGENZ4R2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585911.17_warc_CC-MAIN-20211024050128-20211024080128-00641.warc.gz\"}"}
https://ww2.mathworks.cn/help/reinforcement-learning/ug/ppo-agents.html
[ "Main Content\n\n## Proximal Policy Optimization Agents\n\nProximal policy optimization (PPO) is a model-free, online, on-policy, policy gradient reinforcement learning method. This algorithm is a type of policy gradient training that alternates between sampling data through environmental interaction and optimizing a clipped surrogate objective function using stochastic gradient descent. The clipped surrogate objective function improves training stability by limiting the size of the policy change at each step .\n\nFor more information on the different types of reinforcement learning agents, see Reinforcement Learning Agents.\n\nPPO agents can be trained in environments with the following observation and action spaces.\n\nObservation SpaceAction Space\nDiscrete or continuousDiscrete or continuous\n\nPPO agents use the following actor and critic representations.\n\nCriticActor\n\nValue function critic V(S), which you create using `rlValueRepresentation`\n\nStochastic policy actor π(S), which you create using `rlStochasticActorRepresentation`\n\nDuring training, a PPO agent:\n\n• Estimates probabilities of taking each action in the action space and randomly selects actions based on the probability distribution.\n\n• Interacts with the environment for multiple steps using the current policy before using mini-batches to update the actor and critic properties over multiple epochs.\n\nIf the `UseDeterministicExploitation` option in `rlPPOAgentOptions` is set to `true` the action with maximum likelihood is always used in `sim` and `generatePolicyFunction`. This causes the simulated agent and the generated policy to behave deterministically.\n\n### Actor and Critic Functions\n\nTo estimate the policy and value function, a PPO agent maintains two function approximators:\n\n• Actor μ(S) — The actor takes observation S and returns the probabilities of taking each action in the action space when in state S.\n\n• Critic V(S) — The critic takes observation S and returns the corresponding expectation of the discounted long-term reward.\n\nWhen training is complete, the trained optimal policy is stored in actor μ(S).\n\nFor more information on creating actors and critics for function approximation, see Create Policy and Value Function Representations.\n\n### Agent Creation\n\nYou can create a PPO agent with default actor and critic representations based on the observation and action specifications from the environment. To do so, perform the following steps.\n\n1. Create observation specifications for your environment. If you already have an environment interface object, you can obtain these specifications using `getObservationInfo`.\n\n2. Create action specifications for your environment. If you already have an environment interface object, you can obtain these specifications using `getActionInfo`.\n\n3. If needed, specify the number of neurons in each learnable layer or whether to use an LSTM layer. To do so, create an agent initialization option object using `rlAgentInitializationOptions`.\n\n4. Specify agent options using an `rlPPOAgentOptions` object.\n\n5. Create the agent using an `rlPPOAgent` object.\n\nAlternatively, you can create actor and critic representations and use these representations to create your agent. In this case, ensure that the input and output dimensions of the actor and critic representations match the corresponding action and observation specifications of the environment.\n\n1. Create an actor using an `rlStochasticActorRepresentation` object.\n\n2. Create a critic using an `rlValueRepresentation` object.\n\n3. If needed, specify agent options using an `rlPPOAgentOptions` object.\n\n4. Create the agent using the `rlPPOAgent` function.\n\nPPO agents support actors and critics that use recurrent deep neural networks as functions approximators.\n\nFor more information on creating actors and critics for function approximation, see Create Policy and Value Function Representations.\n\n### Training Algorithm\n\nPPO agents use the following training algorithm. To configure the training algorithm, specify options using an `rlPPOAgentOptions` object.\n\n1. Initialize the actor μ(S) with random parameter values θμ.\n\n2. Initialize the critic V(S) with random parameter values θV.\n\n3. Generate N experiences by following the current policy. The experience sequence is\n\n`${S}_{ts},{A}_{ts},{R}_{ts+1},{S}_{ts+1},\\dots ,{S}_{ts+N-1},{A}_{ts+N-1},{R}_{ts+N},{S}_{ts+N}$`\n\nHere, St is a state observation, At is an action taken from that state, St+1 is the next state, and Rt+1 is the reward received for moving from St to St+1.\n\nWhen in state St, the agent computes the probability of taking each action in the action space using μ(St) and randomly selects action At based on the probability distribution.\n\nts is the starting time step of the current set of N experiences. At the beginning of the training episode, ts = 1. For each subsequent set of N experiences in the same training episode, tsts + N.\n\nFor each experience sequence that does not contain a terminal state, N is equal to the `ExperienceHorizon` option value. Otherwise, N is less than `ExperienceHorizon` and SN is the terminal state.\n\n4. For each episode step t = ts+1, ts+2, …, ts+N, compute the return and advantage function using the method specified by the `AdvantageEstimateMethod` option.\n\n• Finite Horizon (`AdvantageEstimateMethod = \"finite-horizon\"`) — Compute the return Gt, which is the sum of the reward for that step and the discounted future reward .\n\n`${G}_{t}=\\sum _{k=t}^{ts+N}\\left({\\gamma }^{k-t}{R}_{k}\\right)+b{\\gamma }^{N-t+1}V\\left({S}_{ts+N}|{\\theta }_{V}\\right)$`\n\nHere, b is `0` if Sts+N is a terminal state and `1` otherwise. That is, if Sts+N is not a terminal state, the discounted future reward includes the discounted state value function, computed using the critic network V.\n\nCompute the advantage function Dt.\n\n`${D}_{t}={G}_{t}-V\\left({S}_{t}|{\\theta }_{V}\\right)$`\n• Generalized Advantage Estimator (`AdvantageEstimateMethod = \"gae\"`) — Compute the advantage function Dt, which is the discounted sum of temporal difference errors .\n\n`$\\begin{array}{c}{D}_{t}=\\sum _{k=t}^{ts+N-1}{\\left(\\gamma \\lambda \\right)}^{k-t}{\\delta }_{k}\\\\ {\\delta }_{k}={R}_{t}+b\\gamma V\\left({S}_{t}|{\\theta }_{V}\\right)\\end{array}$`\n\nHere, b is `0` if Sts+N is a terminal state and `1` otherwise. λ is a smoothing factor specified using the `GAEFactor` option.\n\nCompute the return Gt.\n\n`${G}_{t}={D}_{t}-V\\left({S}_{t}|{\\theta }_{V}\\right)$`\n\nTo specify the discount factor γ for either method, use the `DiscountFactor` option.\n\n5. Learn from mini-batches of experiences over K epochs. To specify K, use the `NumEpoch` option. For each learning epoch:\n\n1. Sample a random mini-batch data set of size M from the current set of experiences. To specify M, use the `MiniBatchSize` option. Each element of the mini-batch data set contains a current experience and the corresponding return and advantage function values.\n\n2. Update the critic parameters by minimizing the loss Lcritic across all sampled mini-batch data.\n\n`${L}_{critic}\\left({\\theta }_{V}\\right)=\\frac{1}{M}\\sum _{i=1}^{M}{\\left({G}_{i}-V\\left({S}_{i}|{\\theta }_{V}\\right)\\right)}^{2}$`\n3. Update the actor parameters by minimizing the loss Lactor across all sampled mini-batch data. If the `EntropyLossWeight` option is greater than zero, then additional entropy loss is added to Lactor, which encourages policy exploration.\n\n`$\\begin{array}{c}{L}_{actor}\\left({\\theta }_{\\mu }\\right)=-\\frac{1}{M}\\sum _{i=1}^{M}\\mathrm{min}\\left({r}_{i}\\left({\\theta }_{\\mu }\\right)\\ast {D}_{i},{c}_{i}\\left({\\theta }_{\\mu }\\right)\\ast {D}_{i}\\right)\\\\ {r}_{i}\\left({\\theta }_{\\mu }\\right)=\\frac{{\\mu }_{Ai}\\left({S}_{i}|{\\theta }_{\\mu }\\right)}{{\\mu }_{Ai}\\left({S}_{i}|{\\theta }_{\\mu ,old}\\right)}\\\\ {c}_{i}\\left({\\theta }_{\\mu }\\right)=\\mathrm{max}\\left(\\mathrm{min}\\left({r}_{i}\\left({\\theta }_{\\mu }\\right),1+\\epsilon \\right),1-\\epsilon \\right)\\end{array}$`\n\nHere:\n\n• Di and Gi are the advantage function and return value for the ith element of the mini-batch, respectively.\n\n• μi(Si|θμ) is the probability of taking action Ai when in state Si, given the updated policy parameters θμ.\n\n• μi(Si|θμ,old) is the probability of taking action Ai when in state Si, given the previous policy parameters (θμ,old) from before the current learning epoch.\n\n• ε is the clip factor specified using the `ClipFactor` option.\n\n6. Repeat steps 3 through 5 until the training episode reaches a terminal state.\n\n Schulman, John, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. “Proximal Policy Optimization Algorithms.” ArXiv:1707.06347 [Cs], July 19, 2017. https://arxiv.org/abs/1707.06347.\n\n Mnih, Volodymyr, Adrià Puigdomènech Badia, Mehdi Mirza, Alex Graves, Timothy P. Lillicrap, Tim Harley, David Silver, and Koray Kavukcuoglu. “Asynchronous Methods for Deep Reinforcement Learning.” ArXiv:1602.01783 [Cs], February 4, 2016. https://arxiv.org/abs/1602.01783.\n\n Schulman, John, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel. “High-Dimensional Continuous Control Using Generalized Advantage Estimation.” ArXiv:1506.02438 [Cs], October 20, 2018. https://arxiv.org/abs/1506.02438.\n\nDownload ebook" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.772618,"math_prob":0.960828,"size":7647,"snap":"2021-04-2021-17","text_gpt3_token_len":1687,"char_repetition_ratio":0.13450216,"word_repetition_ratio":0.11634103,"special_character_ratio":0.19628613,"punctuation_ratio":0.1290082,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9943756,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-20T18:57:00Z\",\"WARC-Record-ID\":\"<urn:uuid:cc0fdb07-6f09-4ebd-bc8f-49579c239c9a>\",\"Content-Length\":\"89528\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:45949aa5-0f68-4c78-aac4-8d083fcd2110>\",\"WARC-Concurrent-To\":\"<urn:uuid:a7f7e35f-2253-4e67-b772-61518ff0d910>\",\"WARC-IP-Address\":\"23.2.151.17\",\"WARC-Target-URI\":\"https://ww2.mathworks.cn/help/reinforcement-learning/ug/ppo-agents.html\",\"WARC-Payload-Digest\":\"sha1:ONDY5AXOBWNBPFHST67EXYPSM67HK5GM\",\"WARC-Block-Digest\":\"sha1:JSDFZMWE2U7LBSL43JPEGBK7LYPGNC4W\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618039490226.78_warc_CC-MAIN-20210420183658-20210420213658-00411.warc.gz\"}"}
https://www.toppr.com/guides/maths/determinants/area-triangle-using-determinants/
[ "", null, "> > Area of a Triangle Using Determinants\n\n# Area of a Triangle Using Determinants\n\nImagine a triangle with vertices at (x1,y1), (x2,y2), and (x3,y3). If the triangle was a right-angled triangle, it would be pretty easy to compute the area of a triangle by finding one-half the product of the base and the height (area of triangle formula). However, when the triangle is not a right-angled triangle there are multiple different ways to do so. It turns out that the area of triangle formula can also be found using determinants. Let us see in detail how do we go about it.\n\n### Suggested Videos", null, "", null, "", null, "", null, "", null, "", null, "", null, "", null, "Properties of Determinants", null, "Applications of Determinants", null, "Minors and Cofactors_H", null, "## Area of Triangle Formula Using Determinants\n\nIn earlier classes, we have studied that the area of a triangle whose vertices are  (x1, y1), (x2, y2) and (x3, y3), is given by the expression $$\\frac{1}{2} [x1(y2–y3) + x2 (y3–y1) + x3 (y1–y2)]$$. Now this expression can be written in the form of a determinant as", null, "### Points to be Noted\n\n• Since the area is a positive quantity, we always take the absolute value of the determinant in (1).\n• If the area is given, uses both positive and negative values of the determinant for calculation.\n• The area of the triangle formed by three collinear points is zero.\n\nExample: Find the area of the triangle whose vertices are (3, 8), (– 4, 2) and (5, 1).\nSolution: The area of the triangle is given by", null, "= $$\\frac{1}{2} [ 3(2 –1) – 8(– 4 – 5) + 1(– 4 –10)]$$\n= $$\\frac{1}{2} ( 3 + 72 – 14 ) = 61/2$$", null, "", null, "## Derivation of the Area of Triangle Formula", null, "• We know that the Area of Rectangle can be written as follows", null, "• Area of Triangle A: Technically, each of those distances should be the absolute value of the difference. But the problem is much easier to work without the absolute values.", null, "• Area of Triangle B: Realize, however, as if the points don’t lie in the same positions (point 2 is both the rightmost and the uppermost), that the area found using these formulas will be negative.", null, "• Area of Triangle C: For that reason, caution should be exerted to always make the final answer non-negative. The area of a triangle, after all, can’t be negative.", null, "### Let’s add the areas of the three outside triangles together.", null, "Simplifying further,", null, "Now, to subtract the areas of the three triangles from the area of the rectangle.", null, "Simplifying further,", null, "Let’s regroup those terms", null, "………….. (1)\n\nNow, consider the determinant formed by placing the x-coordinates in the first column, the y-coordinates in the second column, and the constant 1 in the last column.", null, "Let’s evaluate the determinant by expanding along the 3rd column.", null, "…………… (2)\n\nOn comparing both (1) and (2) we notice that the area of the triangle differs only in sign. The reason for this is because of the order the points were chosen in. If the points were chosen to be points 1, 2, and 3 in a different order, then the determinant would change only in sign.\n\nSignup and access 1000+ hours of video lectures of Class 12 for free.\n\n## Solved Examples on Area of Triangle Formula\n\nQuestion 1: If the lines p1x + q1y = 1, p2x + q2y = 1 and p3x + q3y = 1 be concurrent, then the points (p1,q1), (p2,q2) and (p3,q3) ,\n\n1. form scalene triangle\n2. form equilateral triangle\n3. are collinear\n4. form a right-angled triangle\n\nAnswer : p1q11, p2q21 p3q31. Given lines are concurrent $$\\begin{vmatrix} p_{1} & q_{1} & 1\\\\ p_{2} & q_{2} & 1 \\\\ p_{3} & q_{3} & 1\\end{vmatrix} = 0$$\n\nThe left-hand side of the above equation is also equal to twice the area of a triangle with coordinates (p1,q1)(p2,q2)(p3,q3). From the area of triangle formula, and since the area is equal to zero, (p1,q1)(p2,q2)(p3,q3are collinear.\n\nQuestion 2: Explain the formula of finding the area of triangle?\n\nAnswer: In order to find the area of a triangle, one must multiply the base by the height. Afterward, one must divide it by 2. The division by 2 comes is because one can divide a parallelogram into 2 triangles.\n\nQuestion 3: How can one find the area of a right triangle?\n\nAnswer: In order to find the area of any right triangle, multiplication of the lengths of the two sides must take place. These two sides are perpendicular to each other. Afterward, one must take half of that.\n\nQuestion 4: Define the area of a triangle?\n\nAnswer: One can define the area of a triangle as the total space enclosed by a given triangle.\n\nQuestion 5: How can one calculate the area of a scalene triangle?\n\nAnswer: A scalene triangle is one which all three sides of different lengths. The area of a scalene triangle that has a base b and height h is given by 1/2 bh. If one knows the lengths of all three sides, one can find area by making use of the Heron’s Formula without the need to find the height.\n\nShare with friends\n\n## Customize your course in 30 seconds\n\n##### Which class are you in?\n5th\n6th\n7th\n8th\n9th\n10th\n11th\n12th\nGet ready for all-new Live Classes!\nNow learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.", null, "", null, "Ashhar Firdausi\nIIT Roorkee\nBiology", null, "", null, "Dr. Nazma Shaik\nVTU\nChemistry", null, "", null, "Gaurav Tiwari\nAPJAKTU\nPhysics\nGet Started\n\n## Browse\n\n##### Determinants", null, "1 Followers\n\nMost reacted comment\n1 Comment authors", null, "Recent comment authors\nSubscribe\nNotify of", null, "Guest\njannat\n\nIs determinant available just for square matrix?", null, "Guest\nStephen\n\nYes, it is only defined for square matrices.", null, "Guest\nJ. A. Zahálka\n\nIt actually is. It is equal to zero for all non-square matrices.\n\n## Question Mark?\n\nHave a doubt at 3 am? Our experts are available 24x7. Connect with a tutor instantly and get your concepts cleared in less than 3 steps.\n\nNo thanks." ]
[ null, "https://www.facebook.com/tr", null, "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OCA0OCI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGN4PSIyNCIgY3k9IjI0IiByPSIyNCIgZmlsbD0iIzAwMCIgb3BhY2l0eT0iLjYiLz48cGF0aCBmaWxsPSIjRkZGIiBkPSJNMTkuOCAzMmMtLjEyNCAwLS4yNDctLjAyOC0uMzYtLjA4LS4yNjQtLjExNi0uNDM2LS4zNzUtLjQ0LS42NjRWMTYuNzQ0Yy4wMDUtLjI5LjE3Ni0uNTUuNDQtLjY2Ni4yNzMtLjEyNi41OTItLjEuODQuMDdsMTAuNCA3LjI1N2MuMi4xMzIuMzIuMzU1LjMyLjU5NXMtLjEyLjQ2My0uMzIuNTk1bC0xMC40IDcuMjU2Yy0uMTQuMS0uMzEuMTUtLjQ4LjE1eiIvPjwvZz48L3N2Zz4=", null, "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OCA0OCI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGN4PSIyNCIgY3k9IjI0IiByPSIyNCIgZmlsbD0iIzAwMCIgb3BhY2l0eT0iLjYiLz48cGF0aCBmaWxsPSIjRkZGIiBkPSJNMTkuOCAzMmMtLjEyNCAwLS4yNDctLjAyOC0uMzYtLjA4LS4yNjQtLjExNi0uNDM2LS4zNzUtLjQ0LS42NjRWMTYuNzQ0Yy4wMDUtLjI5LjE3Ni0uNTUuNDQtLjY2Ni4yNzMtLjEyNi41OTItLjEuODQuMDdsMTAuNCA3LjI1N2MuMi4xMzIuMzIuMzU1LjMyLjU5NXMtLjEyLjQ2My0uMzIuNTk1bC0xMC40IDcuMjU2Yy0uMTQuMS0uMzEuMTUtLjQ4LjE1eiIvPjwvZz48L3N2Zz4=", null, "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OCA0OCI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGN4PSIyNCIgY3k9IjI0IiByPSIyNCIgZmlsbD0iIzAwMCIgb3BhY2l0eT0iLjYiLz48cGF0aCBmaWxsPSIjRkZGIiBkPSJNMTkuOCAzMmMtLjEyNCAwLS4yNDctLjAyOC0uMzYtLjA4LS4yNjQtLjExNi0uNDM2LS4zNzUtLjQ0LS42NjRWMTYuNzQ0Yy4wMDUtLjI5LjE3Ni0uNTUuNDQtLjY2Ni4yNzMtLjEyNi41OTItLjEuODQuMDdsMTAuNCA3LjI1N2MuMi4xMzIuMzIuMzU1LjMyLjU5NXMtLjEyLjQ2My0uMzIuNTk1bC0xMC40IDcuMjU2Yy0uMTQuMS0uMzEuMTUtLjQ4LjE1eiIvPjwvZz48L3N2Zz4=", null, "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTEuNDMzIDE1Ljk5MkwyMi42OSA1LjcxMmMuMzkzLS4zOS4zOTMtMS4wMyAwLTEuNDItLjM5My0uMzktMS4wMy0uMzktMS40MjMgMGwtMTEuOTggMTAuOTRjLS4yMS4yMS0uMy40OS0uMjg1Ljc2LS4wMTUuMjguMDc1LjU2LjI4NC43N2wxMS45OCAxMC45NGMuMzkzLjM5IDEuMDMuMzkgMS40MjQgMCAuMzkzLS40LjM5My0xLjAzIDAtMS40MmwtMTEuMjU3LTEwLjI5IiBmaWxsPSIjZmZmZmZmIiBvcGFjaXR5PSIwLjgiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", null, "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTAuNzIyIDQuMjkzYy0uMzk0LS4zOS0xLjAzMi0uMzktMS40MjcgMC0uMzkzLjM5LS4zOTMgMS4wMyAwIDEuNDJsMTEuMjgzIDEwLjI4LTExLjI4MyAxMC4yOWMtLjM5My4zOS0uMzkzIDEuMDIgMCAxLjQyLjM5NS4zOSAxLjAzMy4zOSAxLjQyNyAwbDEyLjAwNy0xMC45NGMuMjEtLjIxLjMtLjQ5LjI4NC0uNzcuMDE0LS4yNy0uMDc2LS41NS0uMjg2LS43NkwxMC43MiA0LjI5M3oiIGZpbGw9IiNmZmZmZmYiIG9wYWNpdHk9IjAuOCIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", null, "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjYiIGhlaWdodD0iMjYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxjaXJjbGUgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIG9wYWNpdHk9Ii41IiBmaWxsPSIjMDAwIiBjeD0iMTMiIGN5PSIxMyIgcj0iMTIiLz4KICAgICAgICA8cGF0aCBkPSJNMTMuNDM1IDkuMTc4Yy0uMTI2LS4xMjEtLjI3LS4xODItLjQzNi0uMTgyLS4xNjQgMC0uMzA2LjA2MS0uNDI4LjE4MmwtNC4zOCA0LjE3NWMtLjEyNi4xMjEtLjE4OC4yNjItLjE4OC40MjQgMCAuMTYxLjA2Mi4zMDIuMTg4LjQyM2wuNjUuNjIyYy4xMjYuMTIxLjI3My4xODIuNDQxLjE4Mi4xNyAwIC4zMTQtLjA2MS40MzYtLjE4MmwzLjMxNC0zLjE2MSAzLjI0OSAzLjE2MWMuMTI2LjEyMS4yNjkuMTgyLjQzMi4xODIuMTY0IDAgLjMwNy0uMDYxLjQzMy0uMTgybC42NjItLjYyMmMuMTI2LS4xMjEuMTg5LS4yNjIuMTg5LS40MjMgMC0uMTYyLS4wNjMtLjMwMy0uMTg5LS40MjRsLTQuMzczLTQuMTc1eiIgZmlsbD0iI2ZmZiIvPgogICAgPC9nPgo8L3N2Zz4=", null, "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNiIgaGVpZ2h0PSIyNiI+CiAgICA8ZyBmaWxsPSJub25lIj4KICAgICAgICA8Y2lyY2xlIGN4PSIxMyIgY3k9IjEzIiByPSIxMiIgZmlsbD0iIzAwMCIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjIiIG9wYWNpdHk9Ii41Ii8+CiAgICAgICAgPHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEyLjU2NSAxNi44MjJjLjEyNi4xMi4yNy4xODIuNDM2LjE4Mi4xNjggMCAuMzEtLjA2LjQzLS4xODJsNC4zOC00LjE3NWMuMTI4LS4xMi4xOS0uMjYyLjE5LS40MjQgMC0uMTYtLjA2Mi0uMzAyLS4xOS0uNDIzbC0uNjUtLjYyMmMtLjEyNS0uMTItLjI3Mi0uMTgyLS40NC0uMTgyLS4xNyAwLS4zMTQuMDYtLjQzNi4xODJsLTMuMzE0IDMuMTYtMy4yNS0zLjE2Yy0uMTI2LS4xMi0uMjctLjE4Mi0uNDMtLjE4Mi0uMTY2IDAtLjMxLjA2LS40MzUuMTgybC0uNjYyLjYyMmMtLjEyNi4xMi0uMTkuMjYyLS4xOS40MjMgMCAuMTYyLjA2NC4zMDMuMTkuNDI0bDQuMzczIDQuMTc1eiIvPgogICAgPC9nPgo8L3N2Zz4=", null, "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4Ij4KICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgPGNpcmNsZSBjeD0iMjQiIGN5PSIyNCIgcj0iMjQiIGZpbGw9IiMwMDAiIG9wYWNpdHk9Ii42Ii8+CiAgICA8cGF0aCBmaWxsPSIjRkZGIiBkPSJNMTkuOCAzMmMtLjEyNCAwLS4yNDctLjAyOC0uMzYtLjA4LS4yNjQtLjExNi0uNDM2LS4zNzUtLjQ0LS42NjRWMTYuNzQ0Yy4wMDUtLjI5LjE3Ni0uNTUuNDQtLjY2Ni4yNzMtLjEyNi41OTItLjEuODQuMDdsMTAuNCA3LjI1N2MuMi4xMzIuMzIuMzU1LjMyLjU5NXMtLjEyLjQ2My0uMzIuNTk1bC0xMC40IDcuMjU2Yy0uMTQuMS0uMzEuMTUtLjQ4LjE1eiIvPgogIDwvZz4KPC9zdmc+Cg==", null, "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4Ij4KICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgPGNpcmNsZSBjeD0iMjQiIGN5PSIyNCIgcj0iMjQiIGZpbGw9IiMwMDAiIG9wYWNpdHk9Ii42Ii8+CiAgICA8cGF0aCBmaWxsPSIjRkZGIiBkPSJNMTkuOCAzMmMtLjEyNCAwLS4yNDctLjAyOC0uMzYtLjA4LS4yNjQtLjExNi0uNDM2LS4zNzUtLjQ0LS42NjRWMTYuNzQ0Yy4wMDUtLjI5LjE3Ni0uNTUuNDQtLjY2Ni4yNzMtLjEyNi41OTItLjEuODQuMDdsMTAuNCA3LjI1N2MuMi4xMzIuMzIuMzU1LjMyLjU5NXMtLjEyLjQ2My0uMzIuNTk1bC0xMC40IDcuMjU2Yy0uMTQuMS0uMzEuMTUtLjQ4LjE1eiIvPgogIDwvZz4KPC9zdmc+Cg==", null, "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4Ij4KICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgPGNpcmNsZSBjeD0iMjQiIGN5PSIyNCIgcj0iMjQiIGZpbGw9IiMwMDAiIG9wYWNpdHk9Ii42Ii8+CiAgICA8cGF0aCBmaWxsPSIjRkZGIiBkPSJNMTkuOCAzMmMtLjEyNCAwLS4yNDctLjAyOC0uMzYtLjA4LS4yNjQtLjExNi0uNDM2LS4zNzUtLjQ0LS42NjRWMTYuNzQ0Yy4wMDUtLjI5LjE3Ni0uNTUuNDQtLjY2Ni4yNzMtLjEyNi41OTItLjEuODQuMDdsMTAuNCA3LjI1N2MuMi4xMzIuMzIuMzU1LjMyLjU5NXMtLjEyLjQ2My0uMzIuNTk1bC0xMC40IDcuMjU2Yy0uMTQuMS0uMzEuMTUtLjQ4LjE1eiIvPgogIDwvZz4KPC9zdmc+Cg==", null, "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMCIgd2lkdGg9IjEyMDAiIGhlaWdodD0iNTAwIiA+PC9zdmc+", null, "http://www.kshitij-iitjee.com/Maths/Matrices-and-Determinants/234.jpg", null, "http://www.kshitij-iitjee.com/Maths/Matrices-and-Determinants/235.jpg", null, "https://d1whtlypfis84e.cloudfront.net/guides/wp-content/uploads/2019/06/27105703/downlod-pdf-button1.jpg", null, "https://d1whtlypfis84e.cloudfront.net/guides/wp-content/uploads/2018/08/26012922/Determinants_Part_01_V_03-666x1024.jpg", null, "https://d1whtlypfis84e.cloudfront.net/guides/wp-content/uploads/2018/04/10125109/img2.gif", null, "https://d1whtlypfis84e.cloudfront.net/guides/wp-content/uploads/2018/04/10125015/img3.gif", null, "https://d1whtlypfis84e.cloudfront.net/guides/wp-content/uploads/2018/04/10124930/img4.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img5.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img6.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img7.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img8.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img9.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img10.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img11.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img12.gif", null, "https://people.richland.edu/james/lecture/m116/matrices/applications.htg/img13.gif", null, "https://www.toppr.com/bytes/wp-content/themes/bytes-v2/images/live-classes/fame.svg", null, "https://www.toppr.com/bytes/wp-content/themes/bytes-v2/images/live-classes/tutor-1.png", null, "https://www.toppr.com/bytes/wp-content/themes/bytes-v2/images/live-classes/fame.svg", null, "https://www.toppr.com/bytes/wp-content/themes/bytes-v2/images/live-classes/tutor-2.png", null, "https://www.toppr.com/bytes/wp-content/themes/bytes-v2/images/live-classes/fame.svg", null, "https://www.toppr.com/bytes/wp-content/themes/bytes-v2/images/live-classes/tutor-3.png", null, "https://2.gravatar.com/avatar/", null, "https://2.gravatar.com/avatar/bd3b925f4919329e0152ee29c58996e2", null, "https://2.gravatar.com/avatar/bd3b925f4919329e0152ee29c58996e2", null, "https://0.gravatar.com/avatar/f9f8d7797cfd47ff994c45e0da5e0a8d", null, "https://0.gravatar.com/avatar/089f2dd19dca1e0018884e7d95d98a54", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.88009757,"math_prob":0.9925005,"size":5077,"snap":"2021-04-2021-17","text_gpt3_token_len":1361,"char_repetition_ratio":0.18430908,"word_repetition_ratio":0.041036718,"special_character_ratio":0.2727989,"punctuation_ratio":0.11854684,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99899215,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,3,null,3,null,null,null,10,null,3,null,3,null,3,null,4,null,4,null,4,null,4,null,4,null,4,null,4,null,4,null,4,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-21T05:45:04Z\",\"WARC-Record-ID\":\"<urn:uuid:6498d67b-e725-4b16-ae0f-460ba3a4ef17>\",\"Content-Length\":\"200716\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6e2fd9ad-a9b2-4e85-b664-f185ff7c3b44>\",\"WARC-Concurrent-To\":\"<urn:uuid:39c11e63-8c5e-462e-a554-ea0ce26c720c>\",\"WARC-IP-Address\":\"104.20.83.29\",\"WARC-Target-URI\":\"https://www.toppr.com/guides/maths/determinants/area-triangle-using-determinants/\",\"WARC-Payload-Digest\":\"sha1:MAGTGWSP7NSSWPQ6SD3BDDKXYN5T6DPF\",\"WARC-Block-Digest\":\"sha1:V6WDVJ57K3BZ73LROV5USZWNNKV2W5GZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703522242.73_warc_CC-MAIN-20210121035242-20210121065242-00578.warc.gz\"}"}
https://forum.freecodecamp.org/t/chunky-monkey-why-i-cant-do-math-on-the-second-argument-of-for/206215
[ "# Chunky Monkey (why I can't do math on the second argument of For)\n\nHi,\n\nI have found the solution to the Chunky Monkey challenges, however, I don’t know why I had to create a variable for the math that I was trying to add to the second argument of for.\n\nI mean It works …\n\n``````let division = Math.ceil(arr.length/size)\nfor (let x=1; x<=division;x++){\n``````\n\nbut it didn’t work\n\n``````for (let x=1; x<=Math.ceil(arr.length/size);x++){\n\n``````\n\nIt is possible to declare math on it?\n\n``````\nfunction chunkArrayInGroups(arr, size) {\n\nlet newArr = [];\nlet division = Math.ceil(arr.length/size)\nfor (let x=1; x<=division;x++){\nnewArr.push(arr.splice(0,size));\n}\nreturn newArr;\n}\n\nchunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2);\n\n``````\n\nSince splice changes arr’s length, your calculation of arr.length/size would be different each time. You want it to be the same, which is why you had to create a variable to hold the number splices that will take place (your variable named division).\n\n1 Like\n\nThis way, calculate the division, and keep it in a variable.\n\nbut:\n\nfor each iteration(loop) this Math.ceil(arr.length/size) is called, while first approach uses the cached(only once) value.\n\nNow in your code, you push new element on array, so for next iteration(if second form) the Math.ceil() result different value, while the var(first approach) doesn’t(unless you make the var as a function call to do that Math again)\n\nDepends on case-study, you may better go for first way, or second way. There is no rule.\n\n1 Like" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.83385336,"math_prob":0.9260339,"size":1386,"snap":"2022-05-2022-21","text_gpt3_token_len":351,"char_repetition_ratio":0.12011577,"word_repetition_ratio":0.04587156,"special_character_ratio":0.26046175,"punctuation_ratio":0.16181229,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.995582,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-28T06:42:36Z\",\"WARC-Record-ID\":\"<urn:uuid:b48690e2-51d8-413f-ba5d-a92fac2bddeb>\",\"Content-Length\":\"29194\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b9c238fb-0002-44d4-9d98-af2fb541a62f>\",\"WARC-Concurrent-To\":\"<urn:uuid:de496652-9915-43af-9b0f-234e58d0bf8a>\",\"WARC-IP-Address\":\"64.71.144.205\",\"WARC-Target-URI\":\"https://forum.freecodecamp.org/t/chunky-monkey-why-i-cant-do-math-on-the-second-argument-of-for/206215\",\"WARC-Payload-Digest\":\"sha1:OUAHB33E7ZFCVAAIFLVWCOMDSDL3OPDP\",\"WARC-Block-Digest\":\"sha1:ECYLGEXHYCZF5644YKHXJGVOKSHICEZB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652663013003.96_warc_CC-MAIN-20220528062047-20220528092047-00166.warc.gz\"}"}
https://bclin.tw/2022/01/11/leetcode-116/
[ "# 116. Populating Next Right Pointers in Each Node / Medium\n\nYou are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:\n\nstruct Node {\nint val;\nNode *left;\nNode *right;\nNode *next;\n}\n\nPopulate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.\n\nInitially, all next pointers are set to NULL.\n\n## Example 1:", null, "Input: root = [1,2,3,4,5,6,7]\nOutput: [1,#,2,3,#,4,5,6,7,#]\nExplanation: Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with ‘#’ signifying the end of each level.\n\nInput: root = []\nOutput: []\n\n## Constraints:\n\n• The number of nodes in the tree is in the range [0, 2^12 - 1].\n• -1000 <= Node.val <= 1000\n\n# Solution 1: Level Order Traversal / BFS\n\n## 效能\n\n### Complexity\n\n• Time Complexity: O(N)\n• Space Complexity: O(N)\n\n### LeetCode Result\n\n• Runtime: 16 ms\n• Memory Usage: 17.2 MB\n\n# Solution 2: Recursive\n\n## 效能\n\n### Complexity\n\n• Time Complexity: O(N)\n• Space Complexity: O(N) (The stack is counted)\n\n### LeetCode Result\n\n• Runtime: 12 ms\n• Memory Usage: 18.6 MB" ]
[ null, "https://assets.leetcode.com/uploads/2019/02/14/116_sample.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5296428,"math_prob":0.95894426,"size":1881,"snap":"2022-27-2022-33","text_gpt3_token_len":863,"char_repetition_ratio":0.10175812,"word_repetition_ratio":0.10830325,"special_character_ratio":0.2780436,"punctuation_ratio":0.17166212,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98635805,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-29T06:21:40Z\",\"WARC-Record-ID\":\"<urn:uuid:79ff6b8c-0016-4a07-948c-cd4d4a695fd3>\",\"Content-Length\":\"28957\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2dcc1fc9-2590-471f-b6a7-d7ec57a1808b>\",\"WARC-Concurrent-To\":\"<urn:uuid:f95a161f-7a9f-4829-bb58-06fd24826b99>\",\"WARC-IP-Address\":\"172.67.202.122\",\"WARC-Target-URI\":\"https://bclin.tw/2022/01/11/leetcode-116/\",\"WARC-Payload-Digest\":\"sha1:K2BSXRI3JHISPRUXI7UQA5ZRIW73Y5RV\",\"WARC-Block-Digest\":\"sha1:WO4V5OZFJVYJA6VJPVI6TR7PSMB7GJBJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103624904.34_warc_CC-MAIN-20220629054527-20220629084527-00637.warc.gz\"}"}
http://forums.wolfram.com/mathgroup/archive/2012/Mar/msg00303.html
[ "", null, "", null, "", null, "", null, "", null, "", null, "", null, "Re: yg = \\frac{{d(yv)}}{{dt}}, how to solve this differential equation.\n\n• To: mathgroup at smc.vnet.net\n• Subject: [mg125525] Re: yg = \\frac{{d(yv)}}{{dt}}, how to solve this differential equation.\n• From: Murray Eisenberg <murray at math.umass.edu>\n• Date: Sat, 17 Mar 2012 02:52:11 -0500 (EST)\n• Delivered-to: [email protected]\n\nYou presented the differential equation using LaTeX syntax, not\nMathematica syntax. This suggest you know essentially nothing about\nMathematica.\n\nTo begin: since multi-character names are allowed in Mathematica, you\nhave to indicate multiplication explicitly, perhaps with just a space,\nrather than juxtaposition. Thus:\n\ny g\n\nSecond, the Mathematica notation for a function y of a variable t is y[t].\n\nThird, one notation for taking the derivative of a function y of t is\njust y'[t]. Another is D[y[t], t], and the latter is more convenient for\ntaking the derivative of a product such as that of y v:\n\nD[y[t] v[t], t]\n\nNow of course velocity is the derivative of position, so you really have\nthere:\n\nD[y[t] y'[t], t]\n\nYou can either let Mathematica figure out what that is or use the\nProduct Rule from calculus:\n\nD[y[t] y'[t], t] == (y'[t])^2 + y[t] y''[t]\nTrue\n\nNote the double-equal sign == for indicating an equation.\n\nFinally, use the Mathematica function DSolve to solve a differential\nequation. In your example, this will be:\n\nDSolve[g y[t] == D[y[t] y'[t], t], y[t], t]\n\nYou probably won't like the pair of solutions you obtain, as they will\nbe expressed as inverse functions of some rather complicated expressions\ninvolving complex cube- and sixth-rots of -1 along with elliptic integrals.\n\nYou may have better luck with tractable solutions if you specify initial\nconditions, but I doubt it. So you may have to try for numerical\nsolutions, use DSolve.\n\nOn 3/16/12 7:30 AM, Hongyi Zhao wrote:\n> Hi all,\n>\n> I've a differential equation looks like following:\n>\n> yg = \\frac{{d(yv)}}{{dt}}\n>\n> where, g is gravity acceleration, y is the displacement, and the v is\n> velocity. Could you please give me some hints by using mathematica to\n> solve it?\n>\n> Best regards\n\n--\nMurray Eisenberg murray at math.umass.edu\nMathematics & Statistics Dept.\nLederle Graduate Research Tower phone 413 549-1020 (H)\nUniversity of Massachusetts 413 545-2859 (W)\n710 North Pleasant Street fax 413 545-1801\nAmherst, MA 01003-9305\n\n\n\n• Prev by Date: Re: How can I make a sequence that includes lists?\n• Next by Date: Re: Solving multiple equations\n• Previous by thread: yg = \\frac{{d(yv)}}{{dt}}, how to solve this differential equation.\n• Next by thread: More powerful text processing" ]
[ null, "http://forums.wolfram.com/mathgroup/images/head_mathgroup.gif", null, "http://forums.wolfram.com/mathgroup/images/head_archive.gif", null, "http://forums.wolfram.com/mathgroup/images/numbers/2.gif", null, "http://forums.wolfram.com/mathgroup/images/numbers/0.gif", null, "http://forums.wolfram.com/mathgroup/images/numbers/1.gif", null, "http://forums.wolfram.com/mathgroup/images/numbers/2.gif", null, "http://forums.wolfram.com/mathgroup/images/search_archive.gif", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.85396,"math_prob":0.9560478,"size":2346,"snap":"2022-27-2022-33","text_gpt3_token_len":616,"char_repetition_ratio":0.108881295,"word_repetition_ratio":0.047872342,"special_character_ratio":0.28473997,"punctuation_ratio":0.14553015,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99780035,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-09T19:50:09Z\",\"WARC-Record-ID\":\"<urn:uuid:b34ce202-ee43-4f64-80de-75359c80dad0>\",\"Content-Length\":\"45994\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8c828832-fd0d-4d82-91cc-85f2383bda5b>\",\"WARC-Concurrent-To\":\"<urn:uuid:b8bfd01f-c977-4a74-be86-29102d682062>\",\"WARC-IP-Address\":\"140.177.205.73\",\"WARC-Target-URI\":\"http://forums.wolfram.com/mathgroup/archive/2012/Mar/msg00303.html\",\"WARC-Payload-Digest\":\"sha1:NHLSG27JEWHY57AQ66VZXT3I256YXGWA\",\"WARC-Block-Digest\":\"sha1:RCG4EAEEUJYFBVS4Z574LZBHUTDYXTLV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882571086.77_warc_CC-MAIN-20220809185452-20220809215452-00707.warc.gz\"}"}
https://answers.everydaycalculation.com/simplify-fraction/18-1400
[ "Solutions by everydaycalculation.com\n\n## Reduce 18/1400 to lowest terms\n\nThe simplest form of 18/1400 is 9/700.\n\n#### Steps to simplifying fractions\n\n1. Find the GCD (or HCF) of numerator and denominator\nGCD of 18 and 1400 is 2\n2. Divide both the numerator and denominator by the GCD\n18 ÷ 2/1400 ÷ 2\n3. Reduced fraction: 9/700\nTherefore, 18/1400 simplified to lowest terms is 9/700.\n\nMathStep (Works offline)", null, "Download our mobile app and learn to work with fractions in your own time:" ]
[ null, "https://answers.everydaycalculation.com/mathstep-app-icon.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7603931,"math_prob":0.70889777,"size":364,"snap":"2021-31-2021-39","text_gpt3_token_len":122,"char_repetition_ratio":0.14444445,"word_repetition_ratio":0.0,"special_character_ratio":0.43406594,"punctuation_ratio":0.08695652,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9535244,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-07-27T00:09:01Z\",\"WARC-Record-ID\":\"<urn:uuid:3ef97a7f-7a2b-4f88-bb77-fcaa70ba428c>\",\"Content-Length\":\"6607\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e50e4a88-c4d1-4ce8-a501-3a612bc1df6b>\",\"WARC-Concurrent-To\":\"<urn:uuid:a16f5185-6361-4075-8b39-d7ee76eba23f>\",\"WARC-IP-Address\":\"96.126.107.130\",\"WARC-Target-URI\":\"https://answers.everydaycalculation.com/simplify-fraction/18-1400\",\"WARC-Payload-Digest\":\"sha1:S6GW43H6CNFRRLAKCMNV2NGRWGMCVE2L\",\"WARC-Block-Digest\":\"sha1:V6OSHVKLTQUX656NJ7Z7KHEFRT4ZHL7I\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046152156.49_warc_CC-MAIN-20210726215020-20210727005020-00083.warc.gz\"}"}
https://stackoverflow.com/questions/29218458/creating-lists-with-variable-lengths-python/29218600
[ "# Creating lists with variable lengths Python [closed]\n\nI need to create a list with a length determined by a user input.\n\nHow would I do this?\n\nExample: If the user inputs 3 I need a list with 3 indexes.\n\n• Hint: You can append to a list to add extra elements. Mar 23, 2015 at 19:11\n• what part is not clear? How to get an integer from a user? How to create a list of a given length (what content do you want to put in it e.g., how do you think a list of 3 items should look like)?\n– jfs\nMar 23, 2015 at 19:13\n• Not very good at python yet. I just created an empty list and appended it with the inputs from the user. idk how to post the code or else I would show you. Thanks for the response. Mar 25, 2015 at 5:29\n• Something like this: D = [ ] while Days >= n: print(\"Enter the major event for day\", n, \": \", end=\"\") x = input( ) D.append(x) n = n + 1 Mar 25, 2015 at 5:32\n\nWhat do you want to fill the list with? If you just want a list with n indexes:\n\n``````n = user_input_length\nlist = [None for x in range(n)]\n``````\n• `None` is immutable (moreover it is a singletone); you could use `your_list = [None] * n` (don't use `list` as a name; it shadows the builtin).\n– jfs\nMar 23, 2015 at 20:00\n\nYou can take in input, then populate your list:\n\n``````import random\nnum = int(input('How long do you want the list? ')) #5\nlst = [random.randint(1, 10) for i in range(num)]\nprint lst #[6, 1, 2, 1, 8]\n``````\n• there is no `raw_input()` in Python 3.\n– jfs\nMar 23, 2015 at 20:00\n• Thank you. I ended up using the append function to do what I needed to do. Mar 25, 2015 at 5:29\n• How do you post your code in that grey box? Mar 25, 2015 at 5:31\n• @inlakechalakin you have to indent it four spaces Mar 25, 2015 at 16:54" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7883374,"math_prob":0.5942167,"size":784,"snap":"2023-40-2023-50","text_gpt3_token_len":226,"char_repetition_ratio":0.15,"word_repetition_ratio":0.36129034,"special_character_ratio":0.2984694,"punctuation_ratio":0.12637363,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9745371,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-06T04:37:22Z\",\"WARC-Record-ID\":\"<urn:uuid:a03e0b0d-ae17-43e7-ad94-7cdd831ab19d>\",\"Content-Length\":\"168598\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:76fd0847-a012-4873-ab00-373d4d788639>\",\"WARC-Concurrent-To\":\"<urn:uuid:38bd1634-48fc-40bb-a664-be2b3f70c9bf>\",\"WARC-IP-Address\":\"172.64.155.249\",\"WARC-Target-URI\":\"https://stackoverflow.com/questions/29218458/creating-lists-with-variable-lengths-python/29218600\",\"WARC-Payload-Digest\":\"sha1:KMQCVTDF77NEGUFSD4UTPAIFWOCRBDBU\",\"WARC-Block-Digest\":\"sha1:TEO7E7QY4CKGGYQ5FD6PAOKWMNUJ3XSW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100583.13_warc_CC-MAIN-20231206031946-20231206061946-00627.warc.gz\"}"}
https://www.geeksforgeeks.org/php-sinh-function/
[ "# PHP | sinh( ) Function\n\nThe sinh() function is a builtin function in PHP and is used to find the hyperbolic sine of an angle.\nThe hyperbolic sine of any argument arg is defined as,\n\n(exp(arg) – exp(-arg))/2\n\nWhere, exp() is the exponential function and returns e raised to the power of argument passed to it. For example exp(2) = e^2.\n\nSyntax:\n\n`float sinh(\\$value)`\n\nParameters: This function accepts a single parameter \\$value. It is the number whose hyperbolic sine value you want to find. The value of this parameter must be in radians.\n\nReturn Value: It returns a floating point number which is the hyperbolic sine value of number passed to it as argument.\n\nExamples:\n\n```Input : sinh(3)\nOutput : 10.01787492741\n\nInput : sinh(-3)\nOutput : -10.01787492741\n\nInput : sinh(M_PI)\nOutput : 11.548739357258\n\nInput : sinh(0)\nOutput : 0\n```\n\nBelow programs taking different values of \\$value are used to illustrate the sinh() function in PHP:\n\n• Passing 3 as a parameter:\n\n `       `\n\nOutput:\n\n`10.01787492741`\n• Passing -3 as a parameter:\n\n `       `\n\nOutput:\n\n`-10.01787492741`\n• When (M_PI) is passed as a parameter, M_PI is a constant in PHP whose value is 3.1415926535898:\n\n `       `\n\nOutput:\n\n`11.548739357258`\n• Passing 0 as a parameter:\n\n `       `\n\nOutput:\n\n`0`\n\nMy Personal Notes arrow_drop_up", null, "If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to [email protected]. See your article appearing on the GeeksforGeeks main page and help other Geeks.\n\nPlease Improve this article if you find anything incorrect by clicking on the \"Improve Article\" button below.\n\nArticle Tags :\nPractice Tags :\n\nBe the First to upvote.\n\nPlease write to us at [email protected] to report any issue with the above content." ]
[ null, "https://media.geeksforgeeks.org/auth/profile/v5j97u6ixqf7wac5nl85", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.57079196,"math_prob":0.6384667,"size":2511,"snap":"2020-24-2020-29","text_gpt3_token_len":684,"char_repetition_ratio":0.17151974,"word_repetition_ratio":0.054187194,"special_character_ratio":0.303863,"punctuation_ratio":0.16101696,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96606386,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-11T02:04:06Z\",\"WARC-Record-ID\":\"<urn:uuid:32f3d4d1-b300-4eeb-8351-7230c176ff55>\",\"Content-Length\":\"122402\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:56823836-179c-4113-81eb-e05531741042>\",\"WARC-Concurrent-To\":\"<urn:uuid:d24af625-5df4-446b-ab95-ca8a41e07b6d>\",\"WARC-IP-Address\":\"168.143.243.236\",\"WARC-Target-URI\":\"https://www.geeksforgeeks.org/php-sinh-function/\",\"WARC-Payload-Digest\":\"sha1:NXFYCIYHAE5H5ZPEC65URHNXSPG6EC4O\",\"WARC-Block-Digest\":\"sha1:RPN4NFN4UPT6GTZTDLG6CXNHKACGKAUC\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655919952.68_warc_CC-MAIN-20200711001811-20200711031811-00378.warc.gz\"}"}
https://www.colorhexa.com/54e7ae
[ "# #54e7ae Color Information\n\nIn a RGB color space, hex #54e7ae is composed of 32.9% red, 90.6% green and 68.2% blue. Whereas in a CMYK color space, it is composed of 63.6% cyan, 0% magenta, 24.7% yellow and 9.4% black. It has a hue angle of 156.7 degrees, a saturation of 75.4% and a lightness of 61.8%. #54e7ae color hex could be obtained by blending #a8ffff with #00cf5d. Closest websafe color is: #66ff99.\n\n• R 33\n• G 91\n• B 68\nRGB color chart\n• C 64\n• M 0\n• Y 25\n• K 9\nCMYK color chart\n\n#54e7ae color description : Soft cyan - lime green.\n\n# #54e7ae Color Conversion\n\nThe hexadecimal color #54e7ae has RGB values of R:84, G:231, B:174 and CMYK values of C:0.64, M:0, Y:0.25, K:0.09. Its decimal value is 5564334.\n\nHex triplet RGB Decimal 54e7ae `#54e7ae` 84, 231, 174 `rgb(84,231,174)` 32.9, 90.6, 68.2 `rgb(32.9%,90.6%,68.2%)` 64, 0, 25, 9 156.7°, 75.4, 61.8 `hsl(156.7,75.4%,61.8%)` 156.7°, 63.6, 90.6 66ff99 `#66ff99`\nCIE-LAB 82.961, -52.27, 16.399 39.869, 62.089, 49.925 0.262, 0.409, 62.089 82.961, 54.782, 162.582 82.961, -59.937, 32.524 78.797, -47.578, 17.592 01010100, 11100111, 10101110\n\n# Color Schemes with #54e7ae\n\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #e7548d\n``#e7548d` `rgb(231,84,141)``\nComplementary Color\n• #54e765\n``#54e765` `rgb(84,231,101)``\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #54d7e7\n``#54d7e7` `rgb(84,215,231)``\nAnalogous Color\n• #e76554\n``#e76554` `rgb(231,101,84)``\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #e754d7\n``#e754d7` `rgb(231,84,215)``\nSplit Complementary Color\n• #e7ae54\n``#e7ae54` `rgb(231,174,84)``\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #ae54e7\n``#ae54e7` `rgb(174,84,231)``\n• #8de754\n``#8de754` `rgb(141,231,84)``\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #ae54e7\n``#ae54e7` `rgb(174,84,231)``\n• #e7548d\n``#e7548d` `rgb(231,84,141)``\n• #1dd18b\n``#1dd18b` `rgb(29,209,139)``\n• #27e199\n``#27e199` `rgb(39,225,153)``\n• #3ee4a3\n``#3ee4a3` `rgb(62,228,163)``\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #6aeab9\n``#6aeab9` `rgb(106,234,185)``\n• #81edc3\n``#81edc3` `rgb(129,237,195)``\n• #97f0ce\n``#97f0ce` `rgb(151,240,206)``\nMonochromatic Color\n\n# Alternatives to #54e7ae\n\nBelow, you can see some colors close to #54e7ae. Having a set of related colors can be useful if you need an inspirational alternative to your original color choice.\n\n• #54e789\n``#54e789` `rgb(84,231,137)``\n• #54e796\n``#54e796` `rgb(84,231,150)``\n• #54e7a2\n``#54e7a2` `rgb(84,231,162)``\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #54e7ba\n``#54e7ba` `rgb(84,231,186)``\n• #54e7c7\n``#54e7c7` `rgb(84,231,199)``\n• #54e7d3\n``#54e7d3` `rgb(84,231,211)``\nSimilar Colors\n\n# #54e7ae Preview\n\nThis text has a font color of #54e7ae.\n\n``<span style=\"color:#54e7ae;\">Text here</span>``\n#54e7ae background color\n\nThis paragraph has a background color of #54e7ae.\n\n``<p style=\"background-color:#54e7ae;\">Content here</p>``\n#54e7ae border color\n\nThis element has a border color of #54e7ae.\n\n``<div style=\"border:1px solid #54e7ae;\">Content here</div>``\nCSS codes\n``.text {color:#54e7ae;}``\n``.background {background-color:#54e7ae;}``\n``.border {border:1px solid #54e7ae;}``\n\n# Shades and Tints of #54e7ae\n\nA shade is achieved by adding black to any pure hue, while a tint is created by mixing white to any pure color. In this example, #000101 is the darkest color, while #effdf7 is the lightest one.\n\n• #000101\n``#000101` `rgb(0,1,1)``\n• #03120c\n``#03120c` `rgb(3,18,12)``\n• #052318\n``#052318` `rgb(5,35,24)``\n• #073523\n``#073523` `rgb(7,53,35)``\n• #0a462f\n``#0a462f` `rgb(10,70,47)``\n• #0c573a\n``#0c573a` `rgb(12,87,58)``\n• #0f6845\n``#0f6845` `rgb(15,104,69)``\n• #117951\n``#117951` `rgb(17,121,81)``\n• #138b5c\n``#138b5c` `rgb(19,139,92)``\n• #169c68\n``#169c68` `rgb(22,156,104)``\n``#18ad73` `rgb(24,173,115)``\n• #1bbe7f\n``#1bbe7f` `rgb(27,190,127)``\n• #1dcf8a\n``#1dcf8a` `rgb(29,207,138)``\n• #20e096\n``#20e096` `rgb(32,224,150)``\n• #32e29e\n``#32e29e` `rgb(50,226,158)``\n• #43e5a6\n``#43e5a6` `rgb(67,229,166)``\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #65e9b6\n``#65e9b6` `rgb(101,233,182)``\n• #76ecbe\n``#76ecbe` `rgb(118,236,190)``\n• #88eec6\n``#88eec6` `rgb(136,238,198)``\n• #99f1cf\n``#99f1cf` `rgb(153,241,207)``\n• #aaf3d7\n``#aaf3d7` `rgb(170,243,215)``\n• #bbf5df\n``#bbf5df` `rgb(187,245,223)``\n• #ccf8e7\n``#ccf8e7` `rgb(204,248,231)``\n• #defaef\n``#defaef` `rgb(222,250,239)``\n• #effdf7\n``#effdf7` `rgb(239,253,247)``\nTint Color Variation\n\n# Tones of #54e7ae\n\nA tone is produced by adding gray to any pure hue. In this case, #98a49f is the less saturated color, while #3efeb3 is the most saturated one.\n\n• #98a49f\n``#98a49f` `rgb(152,164,159)``\n• #90aba1\n``#90aba1` `rgb(144,171,161)``\n• #89b3a2\n``#89b3a2` `rgb(137,179,162)``\n• #81baa4\n``#81baa4` `rgb(129,186,164)``\n• #7ac2a6\n``#7ac2a6` `rgb(122,194,166)``\n• #72c9a7\n``#72c9a7` `rgb(114,201,167)``\n• #6bd1a9\n``#6bd1a9` `rgb(107,209,169)``\n• #63d8ab\n``#63d8ab` `rgb(99,216,171)``\n• #5ce0ac\n``#5ce0ac` `rgb(92,224,172)``\n• #54e7ae\n``#54e7ae` `rgb(84,231,174)``\n• #4defb0\n``#4defb0` `rgb(77,239,176)``\n• #45f6b1\n``#45f6b1` `rgb(69,246,177)``\n• #3efeb3\n``#3efeb3` `rgb(62,254,179)``\nTone Color Variation\n\n# Color Blindness Simulator\n\nBelow, you can see how #54e7ae is perceived by people affected by a color vision deficiency. This can be useful if you need to ensure your color combinations are accessible to color-blind users.\n\nMonochromacy\n• Achromatopsia 0.005% of the population\n• Atypical Achromatopsia 0.001% of the population\nDichromacy\n• Protanopia 1% of men\n• Deuteranopia 1% of men\n• Tritanopia 0.001% of the population\nTrichromacy\n• Protanomaly 1% of men, 0.01% of women\n• Deuteranomaly 6% of men, 0.4% of women\n• Tritanomaly 0.01% of the population" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.54692763,"math_prob":0.5663965,"size":3725,"snap":"2020-34-2020-40","text_gpt3_token_len":1687,"char_repetition_ratio":0.1225477,"word_repetition_ratio":0.011049724,"special_character_ratio":0.5420134,"punctuation_ratio":0.23756906,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98728514,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-14T16:30:38Z\",\"WARC-Record-ID\":\"<urn:uuid:16026d19-dd8d-4504-bd8c-3a58ef24e3c4>\",\"Content-Length\":\"36333\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:84191bd2-3c93-4921-a6ba-029769fcd930>\",\"WARC-Concurrent-To\":\"<urn:uuid:d8e9e875-8c26-4616-9b39-cafc258c2600>\",\"WARC-IP-Address\":\"178.32.117.56\",\"WARC-Target-URI\":\"https://www.colorhexa.com/54e7ae\",\"WARC-Payload-Digest\":\"sha1:OIMF4QJ6JZPUOWOA2BGJD74DS5AGVP4Z\",\"WARC-Block-Digest\":\"sha1:3VS3TKSJC6KXVVSHALUPFXA2PG5TMT2P\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439739347.81_warc_CC-MAIN-20200814160701-20200814190701-00183.warc.gz\"}"}
https://ebrainanswer.com/mathematics/question15752135
[ "", null, ", 16.04.2020 17:58, arichar\n\n# The measures of two angles are 4x° and (2x + 12) °. The angles are adjacent...\n\nThe measures of two angles are 4x° and (2x + 12) °. The angles are adjacent. If x = 13, how could the angles be classified?\n\nA. Not enough information\n\nB. Vertical\n\nC. Complementary\n\nD. Supplementary", null, "### Other questions on the subject: Mathematics", null, "Mathematics, 21.06.2019 15:30, dashaunpeele\nAvegetable garden and a surrounding path are shaped like a square that together are 11ft wide. the path is 2ft wide. find the total area of the vegetable garden and path", null, "Mathematics, 21.06.2019 15:30, hannahking1869\nWhich conjunction is disjunction is equivalent to the given absolute value inequality? |x+2|< 18", null, "Mathematics, 21.06.2019 15:30, yhbgvfcd6677\nFabian harvests 10 pounds of tomatoes from his garden. he needs 225 pounds to make a batch of soup. if he sets aside 2.8 pounds of tomatoes to make spaghetti sauce, how many batches of soup can fabian make?", null, "Mathematics, 21.06.2019 19:50, ghwolf4p0m7x0\nThe graph shows the distance kerri drives on a trip. what is kerri's speed . a. 25 b.75 c.60 d.50\nDo you know the correct answer?\nThe measures of two angles are 4x° and (2x + 12) °. The angles are adjacent. If x = 13, how could th...\n\n### Questions in other subjects:", null, "", null, "", null, "", null, "Mathematics, 29.06.2019 13:30", null, "Mathematics, 29.06.2019 13:30", null, "", null, "", null, "", null, "", null, "" ]
[ null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/otvet.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/ekonomika.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/istoriya.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/informatica.png", null, "https://ebrainanswer.com/tpl/images/cats/mat.png", null, "https://ebrainanswer.com/tpl/images/cats/health.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8083139,"math_prob":0.97212625,"size":1474,"snap":"2022-27-2022-33","text_gpt3_token_len":503,"char_repetition_ratio":0.15986395,"word_repetition_ratio":0.2746781,"special_character_ratio":0.36092266,"punctuation_ratio":0.25070423,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.975671,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-05T02:37:09Z\",\"WARC-Record-ID\":\"<urn:uuid:1eb276eb-babf-459f-a96c-d5328ff96971>\",\"Content-Length\":\"121735\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:225ab97d-6656-4016-8381-6c703077e4b8>\",\"WARC-Concurrent-To\":\"<urn:uuid:a9c716a9-ce11-4864-bc39-87c7e4825df9>\",\"WARC-IP-Address\":\"104.21.20.171\",\"WARC-Target-URI\":\"https://ebrainanswer.com/mathematics/question15752135\",\"WARC-Payload-Digest\":\"sha1:2XQRMPAAVGJRSDNHLAQLNNTA2RET2EBM\",\"WARC-Block-Digest\":\"sha1:B56U3YKQLQ2UVKN3AHSGBAV2BKNN4ECH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656104512702.80_warc_CC-MAIN-20220705022909-20220705052909-00511.warc.gz\"}"}
https://ftp.aimsciences.org/article/doi/10.3934/dcdsb.2017122
[ "", null, "", null, "", null, "", null, "August  2017, 22(6): 2389-2416. doi: 10.3934/dcdsb.2017122\n\n## Numerical solutions of viscoelastic bending wave equations with two term time kernels by Runge-Kutta convolution quadrature\n\n Department of Mathematics, Hunan Normal University, Changsha 410081, Hunan, China\n\nReceived  July 2015 Revised  February 2017 Published  March 2017\n\nFund Project: The author is supported by NSFC grant 11671131, the Construct Program of the Key Discipline in Hunan Province, Performance Computing and Stochastic Information Processing (Ministry of Education of China).\n\nIn this paper, we study the numerical solutions of viscoelastic bending wave equations\n $u_{t}(x,~t)-\\int_{0}^{t}[\\beta_{1}(t-s)\\,u_{xx}(x,~s) - \\beta_{2}(t-s)\\,u_{xxxx}(x,~s)]ds = f(x,~t),$\nfor\n $0 , with self-adjoint boundary and initial value conditions, in which the functions $ \\beta_{1}(t) $and $ \\beta_{2}(t) $are completely monotonic on $ (0,~\\infty) $and locally integrable, but not constant. The equations are discretised in space by the finite difference method and in time by the Runge-Kutta convolution quadrature. The stability and convergence of the schemes are analyzed by the frequency domain and energy methods. Numerical experiments are provided to illustrate the accuracy and efficiency of the proposed schemes. Citation: Da Xu. Numerical solutions of viscoelastic bending wave equations with two term time kernels by Runge-Kutta convolution quadrature. Discrete & Continuous Dynamical Systems - B, 2017, 22 (6) : 2389-2416. doi: 10.3934/dcdsb.2017122 ##### References: H. Brunner, J.-P. Kauthen and A. Ostermann, Runge-Kutta time discretizations of parabolic Volterra integro-differential equations, J. Integ. Equ. Appl., 7 (1995), 1-16. Google Scholar L. Banjai and Ch. Lubich, An error analysis of Runge-Kutta convolution quadrature, BIT Numer. Math., 51 (2011), 483-496. Google Scholar L. Banjai, Ch. Lubich and J. M. Melenk, Runge-Kutta convolution quadrature for operators arising in wave propagation, Numer. Math., 119 (2011), 1-20. Google Scholar R. W. Carr and K. B. Hannsgen, A nonhomogeneous integro-differential equation in Hilbert space, SIAM J. Math. Anal., 10 (1979), 961-984. Google Scholar R. W. Carr and K. B. Hannsgen, Resolvent formulas for a Volterra equation in Hilbert space, SIAM J. Math. Anal., 13 (1982), 459-483. Google Scholar M. P. Calvo, E. Cuesta and C. Palencia, Runge-Kutta convolution quadrature methods for well-posed equations with memory, Numer. Math., 107 (2007), 589-614. Google Scholar H. S. Carslaw and J. C. Jaeger, Conduction of Heat in Solids, 2nd edition, Charendon Press, Oxford, 1959. Google Scholar G. Fairweather, Spline collocation methods for a class of hyperbolic partial integro-differential equations, SIAM J. Numer. Anal., 31 (1994), 444-460. Google Scholar M. Lopez-Fernandez and S. Sauter, Generalized convolution quadrature based on RungeKutta methods, Numer. Math., 133 (2016), 743-779. Google Scholar K. B. Hannsgen, Indirect Abelian theorems and a linear Volterra equation, Trans. Amer. Math. Soc., 142 (1969), 539-555. Google Scholar K. B. Hannsgen and R. L. Wheeler, Uniform L1 behavior in classes of integro-differential equations with completely monotonic kernels, SIAM J. Math. Anal., 15 (1984), 579-594. Google Scholar E. Hairer, S. P. Nϕrsett and G. Wanner, Solving Ordinary Differential Equations. Ⅰ: Nonstiff Problems, 2nd edition, Springer Series in Computational Mathematics, 8, Springer, Berlin, 1993. Google Scholar E. Hairer and G. Wanner, Solving ordinary differential equations. Ⅱ: Stiff and DifferentialAlgebraic Problems, 2nd edition, Springer Series in Computational Mathematics, 14, Springer, Berlin, 1996. Google Scholar K. B. Hannsgen and R. L. Wheeler, Complete monotonicity and resolvent of Volterra integrodifferential equations, SIAM J. Math. Anal., 13 (1982), 962-969. Google Scholar X. Hu and L. Zhang, A compact finite difference scheme for the fourth-order fractional diffusion-wave system, Computer Phys. Communications, 182 (2011), 1645-1650. Google Scholar X. Hu and L. Zhang, On finite difference methods for fourth-order fractional diffusion-wave and sub-diffusion systems, Appl. Math. Comput., 218 (2012), 5019-5034. Google Scholar B. Jin, R. Lazarov, Y. Liu and Z. Zhou, The Galerkin finite element method for a multi-term time-fractional diffusion equation, J. Comp. Phys., 281 (2015), 825-843. Google Scholar C. H. Kim and U. J. Choi, Spectral collocation methods for a partial integro-differential equation with a weakly singular kernel, J. Austral. Math. Soc. Ser. B., 39 (1988), 408-430. Google Scholar Ch. Lubich, I. H. Sloan and V. Thomée, Non-smooth data error estimates for approximations of an evolution equation with a positive-type memory term, Math. Comput. 65 (1996), 1-17. Google Scholar F. Liu, M. M. Meerschaert, R. J. McCough, P. Zhuang and Q. Liu, Numerical methods for solving the multi-term time-fractional wave-diffusion equation, Fractional calculus and Appl. Anal., 16 (2013), 9-25. Google Scholar J. C. López-Marcos, A difference scheme for a nonlinear partial integro-differential equation, SIAM J. Numer. Anal., 27 (1990), 20-31. Google Scholar W. McLean and V. Thomée, Numerical solution of an evolution equation with a positive-type memory term, J. Austral. Math. Soc. Ser. B. 35 (1993), 23-70. Google Scholar W. McLean and V. Thomée, Time discretization of an evolution equation via Laplace transforms, IMA J. Numer. Anal., 24 (2004), 439-463. Google Scholar W. McLean and V. Thomée, Maximum-norm error analysis of a numerical solution via Laplace transformation and quadrature of a fractional order evolution equation, IMA J. Numer. Anal., 30 (2010), 208-230. Google Scholar K. Mustapha and W. McLean, Discontinuous Galerkin method for an evolution equation with a memory term of positive type, Math. Comp., 78 (2009), 1975-1995. Google Scholar K. Mustapha and W. McLean, Super-convergence of a discontinuous Galerkin method for fractional diffusion and wave equations, SIAM J. Numer. Anal., 51 (2013), 491-515. Google Scholar K. Mustapha and D. Schötzau Well-posedness of hp-version discontinuous Galerkin methods for fractional diffusion wave equations, IMA J. Numer. Anal., 34 (2014), 1426-1446. Google Scholar W. McLean and V. Thomée, Numerical solution via laplace transforms of a fractional order evolution equation, J. Integral Eq. Appl., 22 (2010), 57-94. Google Scholar R. D. Noren, Uniform L1 behavior in a class of linear Volterra equations, Quart. Appl. Math., 47 (1989), 547-554. Google Scholar R. D. Noren, Uniform L1 behavior in classes of integro-differential equations with convex kernels, J. Integral Equations Appl., 1 (1988), 385-396. Google Scholar R. D. Noren, Uniform L1 behavior for the solution of a Volterra equation with a parameter, SIAM J. Math. Anal., 19 (1988), 270-286. Google Scholar A. K. Pani, G. Fairweather and R. I. Fernandes, Alternating direction implicit orthogonal spline collocation methods for an evolution equation with a positive-type memory term, SIAM J. Numer. Anal., 46 (2008), 344-364. Google Scholar J. Prüss, Evolutionary Integral Equations and Applications, Monographs in Mathematics, Vol. , 87, Birkhäuser Verlag, Basel; Boston; Berlin, 1993. Google Scholar M. Renardy, W. J. Hrusa and J. A. Nohel, Mathematical Problems in Viscoelasticity, Longman Essex, U. K. , 1987. Google Scholar J. M. Sanz-Serna, A numerical method for a partial integro-differential equation, SIAM J. Numer. Anal., 25 (1988), 319-327. Google Scholar T. Tang, A finite difference scheme for partial integro-differential equations with a weakly singular kernel, Appl. Numer. Math., 11 (1993), 309-319. Google Scholar J. Tang and D. Xu, The global behavior of finite difference-spatial spectral collocation methods for a partial integro-differential equation with a weakly singular kernel, Numer. Math. Theor. Meth. Appl., 6 (2013), 556-570. Google Scholar D. V. Widder, The Laplace Transform, Princeton University Press, Princeton, NJ., 1946. Google Scholar D. Xu, Uniform L1 error bounds for the semidiscrete solution of a Volterra equation with completely monotonic convolution kernel, Computers Math. Appl., 43 (2002), 1303-1318. Google Scholar D. Xu, Uniform l1 behaviour for time discretization of a volterra equation with completely monotonic kernel:Ⅰ. Stability, IMA J. Numer. Anal., 22 (2002), 133-151. Google Scholar D. Xu, Uniform l1 behaviour in the second order difference type method of a linear Volterra equation with completely monotonic kernel Ⅰ: stability, IMA J. Numer. Anal., 31 (2011), 1154-1180. Google Scholar D. Xu, Uniform l1 behaviour for time discretization of a Volterra equation with completely monotonic kernel Ⅱ: Convergence, SIAM J. Numer. Anal., 46 (2008), 231-259. Google Scholar D. Xu, Stability of the difference type methods for linear Volterra equations in Hilbert spaces, Numer. Math., 109 (2008), 571-595. Google Scholar D. Xu, Numerical solution of evolutionary integral equations with completely monotonic kernel by Runge-Kutta convolution quadrature, Numer. Meth. Partial Diff. Eq., 31 (2015), 105-142. Google Scholar D. Xu, The time discretization in classes of integro-differential equations with completely monotonic kernels; Weighted asymptotic stability, Sci. China Math., 56 (2013), 395-424. Google Scholar Y. Yi and G. Fairweather, Orthogonal spline collocation methods for some partial integrodifferential equations, SIAM J. Numer. Anal., 29, (1992), 755-768. Google Scholar H. Ye, F. Liu, I. Turner, V. Anh and K. Burrage, Series expansion solutions for the multiterm time and space fractional partial differential equations in two-and three-dimensions, Eur. Phys. J. Special Topics, 222 (2013), 1901-1914. Google Scholar show all references ##### References: H. Brunner, J.-P. Kauthen and A. Ostermann, Runge-Kutta time discretizations of parabolic Volterra integro-differential equations, J. Integ. Equ. Appl., 7 (1995), 1-16. Google Scholar L. Banjai and Ch. Lubich, An error analysis of Runge-Kutta convolution quadrature, BIT Numer. Math., 51 (2011), 483-496. Google Scholar L. Banjai, Ch. Lubich and J. M. Melenk, Runge-Kutta convolution quadrature for operators arising in wave propagation, Numer. Math., 119 (2011), 1-20. Google Scholar R. W. Carr and K. B. Hannsgen, A nonhomogeneous integro-differential equation in Hilbert space, SIAM J. Math. Anal., 10 (1979), 961-984. Google Scholar R. W. Carr and K. B. Hannsgen, Resolvent formulas for a Volterra equation in Hilbert space, SIAM J. Math. Anal., 13 (1982), 459-483. Google Scholar M. P. Calvo, E. Cuesta and C. Palencia, Runge-Kutta convolution quadrature methods for well-posed equations with memory, Numer. Math., 107 (2007), 589-614. Google Scholar H. S. Carslaw and J. C. Jaeger, Conduction of Heat in Solids, 2nd edition, Charendon Press, Oxford, 1959. Google Scholar G. Fairweather, Spline collocation methods for a class of hyperbolic partial integro-differential equations, SIAM J. Numer. Anal., 31 (1994), 444-460. Google Scholar M. Lopez-Fernandez and S. Sauter, Generalized convolution quadrature based on RungeKutta methods, Numer. Math., 133 (2016), 743-779. Google Scholar K. B. Hannsgen, Indirect Abelian theorems and a linear Volterra equation, Trans. Amer. Math. Soc., 142 (1969), 539-555. Google Scholar K. B. Hannsgen and R. L. Wheeler, Uniform L1 behavior in classes of integro-differential equations with completely monotonic kernels, SIAM J. Math. Anal., 15 (1984), 579-594. Google Scholar E. Hairer, S. P. Nϕrsett and G. Wanner, Solving Ordinary Differential Equations. Ⅰ: Nonstiff Problems, 2nd edition, Springer Series in Computational Mathematics, 8, Springer, Berlin, 1993. Google Scholar E. Hairer and G. Wanner, Solving ordinary differential equations. Ⅱ: Stiff and DifferentialAlgebraic Problems, 2nd edition, Springer Series in Computational Mathematics, 14, Springer, Berlin, 1996. Google Scholar K. B. Hannsgen and R. L. Wheeler, Complete monotonicity and resolvent of Volterra integrodifferential equations, SIAM J. Math. Anal., 13 (1982), 962-969. Google Scholar X. Hu and L. Zhang, A compact finite difference scheme for the fourth-order fractional diffusion-wave system, Computer Phys. Communications, 182 (2011), 1645-1650. Google Scholar X. Hu and L. Zhang, On finite difference methods for fourth-order fractional diffusion-wave and sub-diffusion systems, Appl. Math. Comput., 218 (2012), 5019-5034. Google Scholar B. Jin, R. Lazarov, Y. Liu and Z. Zhou, The Galerkin finite element method for a multi-term time-fractional diffusion equation, J. Comp. Phys., 281 (2015), 825-843. Google Scholar C. H. Kim and U. J. Choi, Spectral collocation methods for a partial integro-differential equation with a weakly singular kernel, J. Austral. Math. Soc. Ser. B., 39 (1988), 408-430. Google Scholar Ch. Lubich, I. H. Sloan and V. Thomée, Non-smooth data error estimates for approximations of an evolution equation with a positive-type memory term, Math. Comput. 65 (1996), 1-17. Google Scholar F. Liu, M. M. Meerschaert, R. J. McCough, P. Zhuang and Q. Liu, Numerical methods for solving the multi-term time-fractional wave-diffusion equation, Fractional calculus and Appl. Anal., 16 (2013), 9-25. Google Scholar J. C. López-Marcos, A difference scheme for a nonlinear partial integro-differential equation, SIAM J. Numer. Anal., 27 (1990), 20-31. Google Scholar W. McLean and V. Thomée, Numerical solution of an evolution equation with a positive-type memory term, J. Austral. Math. Soc. Ser. B. 35 (1993), 23-70. Google Scholar W. McLean and V. Thomée, Time discretization of an evolution equation via Laplace transforms, IMA J. Numer. Anal., 24 (2004), 439-463. Google Scholar W. McLean and V. Thomée, Maximum-norm error analysis of a numerical solution via Laplace transformation and quadrature of a fractional order evolution equation, IMA J. Numer. Anal., 30 (2010), 208-230. Google Scholar K. Mustapha and W. McLean, Discontinuous Galerkin method for an evolution equation with a memory term of positive type, Math. Comp., 78 (2009), 1975-1995. Google Scholar K. Mustapha and W. McLean, Super-convergence of a discontinuous Galerkin method for fractional diffusion and wave equations, SIAM J. Numer. Anal., 51 (2013), 491-515. Google Scholar K. Mustapha and D. Schötzau Well-posedness of hp-version discontinuous Galerkin methods for fractional diffusion wave equations, IMA J. Numer. Anal., 34 (2014), 1426-1446. Google Scholar W. McLean and V. Thomée, Numerical solution via laplace transforms of a fractional order evolution equation, J. Integral Eq. Appl., 22 (2010), 57-94. Google Scholar R. D. Noren, Uniform L1 behavior in a class of linear Volterra equations, Quart. Appl. Math., 47 (1989), 547-554. Google Scholar R. D. Noren, Uniform L1 behavior in classes of integro-differential equations with convex kernels, J. Integral Equations Appl., 1 (1988), 385-396. Google Scholar R. D. Noren, Uniform L1 behavior for the solution of a Volterra equation with a parameter, SIAM J. Math. Anal., 19 (1988), 270-286. Google Scholar A. K. Pani, G. Fairweather and R. I. Fernandes, Alternating direction implicit orthogonal spline collocation methods for an evolution equation with a positive-type memory term, SIAM J. Numer. Anal., 46 (2008), 344-364. Google Scholar J. Prüss, Evolutionary Integral Equations and Applications, Monographs in Mathematics, Vol. , 87, Birkhäuser Verlag, Basel; Boston; Berlin, 1993. Google Scholar M. Renardy, W. J. Hrusa and J. A. Nohel, Mathematical Problems in Viscoelasticity, Longman Essex, U. K. , 1987. Google Scholar J. M. Sanz-Serna, A numerical method for a partial integro-differential equation, SIAM J. Numer. Anal., 25 (1988), 319-327. Google Scholar T. Tang, A finite difference scheme for partial integro-differential equations with a weakly singular kernel, Appl. Numer. Math., 11 (1993), 309-319. Google Scholar J. Tang and D. Xu, The global behavior of finite difference-spatial spectral collocation methods for a partial integro-differential equation with a weakly singular kernel, Numer. Math. Theor. Meth. Appl., 6 (2013), 556-570. Google Scholar D. V. Widder, The Laplace Transform, Princeton University Press, Princeton, NJ., 1946. Google Scholar D. Xu, Uniform L1 error bounds for the semidiscrete solution of a Volterra equation with completely monotonic convolution kernel, Computers Math. Appl., 43 (2002), 1303-1318. Google Scholar D. Xu, Uniform l1 behaviour for time discretization of a volterra equation with completely monotonic kernel:Ⅰ. Stability, IMA J. Numer. Anal., 22 (2002), 133-151. Google Scholar D. Xu, Uniform l1 behaviour in the second order difference type method of a linear Volterra equation with completely monotonic kernel Ⅰ: stability, IMA J. Numer. Anal., 31 (2011), 1154-1180. Google Scholar D. Xu, Uniform l1 behaviour for time discretization of a Volterra equation with completely monotonic kernel Ⅱ: Convergence, SIAM J. Numer. Anal., 46 (2008), 231-259. Google Scholar D. Xu, Stability of the difference type methods for linear Volterra equations in Hilbert spaces, Numer. Math., 109 (2008), 571-595. Google Scholar D. Xu, Numerical solution of evolutionary integral equations with completely monotonic kernel by Runge-Kutta convolution quadrature, Numer. Meth. Partial Diff. Eq., 31 (2015), 105-142. Google Scholar D. Xu, The time discretization in classes of integro-differential equations with completely monotonic kernels; Weighted asymptotic stability, Sci. China Math., 56 (2013), 395-424. Google Scholar Y. Yi and G. Fairweather, Orthogonal spline collocation methods for some partial integrodifferential equations, SIAM J. Numer. Anal., 29, (1992), 755-768. Google Scholar H. Ye, F. Liu, I. Turner, V. Anh and K. Burrage, Series expansion solutions for the multiterm time and space fractional partial differential equations in two-and three-dimensions, Eur. Phys. J. Special Topics, 222 (2013), 1901-1914. Google Scholar The$ L_{2} $errors and convergence rate of the 2-stage Radau IIA convolution quadrature of (8.1.1) with$ M=802 $, and$ t_{K}=1 $ K$ e_{K} $Rate 2$ 2.9416e-006 $- 4$ 2.6658e-007 3.4640 $8$ 2.8401e-008 3.2306 $2$ 2.9416e-006 $- 8$ 2.8401e-008 3.3473 $Theory$ 3.0000 $ K$ e_{K} $Rate 2$ 2.9416e-006 $- 4$ 2.6658e-007 3.4640 $8$ 2.8401e-008 3.2306 $2$ 2.9416e-006 $- 8$ 2.8401e-008 3.3473 $Theory$ 3.0000 $The$ L_{2} $errors and convergence rate of the 3-stage Radau IIA convolution quadrature of (8.1.1) with$ M=802 $and$ t_{K}=1 $ K$ e_{K} $Rate 2$ 3.1196e-006 $- 4$ 9.0652e-008 5.1049 $8$ 2.8981e-009 4.9672 $2$ 3.1196e-006 $- 8$ 2.8981e-009 5.0360 $ K$ e_{K} $Rate 2$ 3.1196e-006 $- 4$ 9.0652e-008 5.1049 $8$ 2.8981e-009 4.9672 $2$ 3.1196e-006 $- 8$ 2.8981e-009 5.0360 $The$ L_{2} $errors and convergence rates of the 2-stage Radau IIA convolution quadrature of (8.1.1) with$ M=802 $,$ t_{K}=1 $, and$ f(x~t) = \\frac{t^{5.5}}{\\Gamma(6.5)} \\sin(\\pi x) e^{\\pi x} (\\pi x)^{2}(\\pi-\\pi x)^{2} $ K$ e_{K} $Rate 2$ 7.4612e-005 $- 4$ 6.7979e-006 3.4562 $8$ 7.3481e-007 3.2096 $2$ 7.4612e-005 $- 8$ 7.3481e-007 3.3329 $Theory$ 3.0000 $ K$ e_{K} $Rate 2$ 7.4612e-005 $- 4$ 6.7979e-006 3.4562 $8$ 7.3481e-007 3.2096 $2$ 7.4612e-005 $- 8$ 7.3481e-007 3.3329 $Theory$ 3.0000 $The$ L_{2} $errors and convergence rates of the 3-stage Radau IIA convolution quadrature of (8.1.1) with$ M=802 $,$ t_{K}=1 $, and$ f(x~t) = \\frac{t^{5.5}}{\\Gamma(6.5)} \\sin(\\pi x) e^{\\pi x} (\\pi x)^{2}(\\pi-\\pi x)^{2} $ K$ e_{K} $Rate 2$ 8.2319e-005 $- 4$ 2.2979e-006 5.1628 $8$ 7.3507e-008 4.9663 $2$ 8.2319e-005 $- 8$ 7.3507e-008 5.0646 $ K$ e_{K} $Rate 2$ 8.2319e-005 $- 4$ 2.2979e-006 5.1628 $8$ 7.3507e-008 4.9663 $2$ 8.2319e-005 $- 8$ 7.3507e-008 5.0646 $The$ L_{2} $errors and convergence rate of the 2-stage Radau IIA convolution quadrature of (5.1) with$ M=202 $, and$ t_{K}=1 $ K$ e_{K} $Rate 2$ 0.2789 $- 4$ 0.0088 4.9861 $8$ 9.1479e-004 3.2660 $16$ 1.4166e-004 2.6910 $2$ 0.2789 $- 8$ 9.1479e-004 4.1260 $2$ 0.2789 $- 16$ 1.4166e-004 3.6477 $4$ 0.0088 $- 16$ 1.4166e-004 2.9785 $ K$ e_{K} $Rate 2$ 0.2789 $- 4$ 0.0088 4.9861 $8$ 9.1479e-004 3.2660 $16$ 1.4166e-004 2.6910 $2$ 0.2789 $- 8$ 9.1479e-004 4.1260 $2$ 0.2789 $- 16$ 1.4166e-004 3.6477 $4$ 0.0088 $- 16$ 1.4166e-004 2.9785 $The$ L_{2} $errors and convergence rate of the 3-stage Radau IIA convolution quadrature of (5.1) with$ M=202 $and$ t_{K}=1 $ K$ e_{K} $Rate 2$ 0.0592 $- 4$ 4.9980e-004 6.8881 $8$ 1.5134e-005 5.0455 $2$ 0.0592 $- 8$ 1.5134e-005 5.9668 $ K$ e_{K} $Rate 2$ 0.0592 $- 4$ 4.9980e-004 6.8881 $8$ 1.5134e-005 5.0455 $2$ 0.0592 $- 8$ 1.5134e-005 5.9668 $The$ L_{2} $errors and convergence rates of the 2-stage Radau IIA convolution quadrature of (5.1) with$ M=202 $,$ t_{K}=1 $, and$ u_{0}(x)= \\sin(\\pi x) e^{\\cos(\\pi x)} $ K$ e_{K} $Rate 4$ 0.0593 $- 8$ 0.0076 2.9640 $16$ 8.7669e-004 3.1159 $4$ 0.0593 $- 16$ 8.7669e-004 3.0399 $ K$ e_{K} $Rate 4$ 0.0593 $- 8$ 0.0076 2.9640 $16$ 8.7669e-004 3.1159 $4$ 0.0593 $- 16$ 8.7669e-004 3.0399 $The$ L_{2} $errors and convergence rates of the 3-stage Radau IIA convolution quadrature of (5.1) with$ M=202 $,$ t_{K}=1 $, and$ u_{0}(x)= (\\sin(\\pi x))^{3} $ K$ e_{K} $Rate 2$ 0.0664 $- 4$ 0.0027 4.6206 $8$ 7.4457e-005 5.1804 $2$ 0.0664 $- 8$ 7.4457e-005 4.9003 $ K$ e_{K} $Rate 2$ 0.0664 $- 4$ 0.0027 4.6206 $8$ 7.4457e-005 5.1804 $2$ 0.0664 $- 8$ 7.4457e-005 4.9003 $ Sihong Shao, Huazhong Tang. Higher-order accurate Runge-Kutta discontinuous Galerkin methods for a nonlinear Dirac model. Discrete & Continuous Dynamical Systems - B, 2006, 6 (3) : 623-640. doi: 10.3934/dcdsb.2006.6.623 Lijuan Wang, Jun Zou. Error estimates of finite element methods for parameter identifications in elliptic and parabolic systems. Discrete & Continuous Dynamical Systems - B, 2010, 14 (4) : 1641-1670. doi: 10.3934/dcdsb.2010.14.1641 Weizhu Bao, Chunmei Su. Uniform error estimates of a finite difference method for the Klein-Gordon-Schrödinger system in the nonrelativistic and massless limit regimes. Kinetic & Related Models, 2018, 11 (4) : 1037-1062. doi: 10.3934/krm.2018040 Xiaohai Wan, Zhilin Li. Some new finite difference methods for Helmholtz equations on irregular domains or with interfaces. Discrete & Continuous Dynamical Systems - B, 2012, 17 (4) : 1155-1174. doi: 10.3934/dcdsb.2012.17.1155 Jonathan Touboul. Erratum on: Controllability of the heat and wave equations and their finite difference approximations by the shape of the domain. Mathematical Control & Related Fields, 2019, 9 (1) : 221-222. doi: 10.3934/mcrf.2019006 Jonathan Touboul. Controllability of the heat and wave equations and their finite difference approximations by the shape of the domain. Mathematical Control & Related Fields, 2012, 2 (4) : 429-455. doi: 10.3934/mcrf.2012.2.429 Jinye Shen, Xian-Ming Gu. Two finite difference methods based on an H2N2 interpolation for two-dimensional time fractional mixed diffusion and diffusion-wave equations. Discrete & Continuous Dynamical Systems - B, 2021 doi: 10.3934/dcdsb.2021086 Jie Shen, Xiaofeng Yang. Error estimates for finite element approximations of consistent splitting schemes for incompressible flows. Discrete & Continuous Dynamical Systems - B, 2007, 8 (3) : 663-676. doi: 10.3934/dcdsb.2007.8.663 Zalman Balanov, Carlos García-Azpeitia, Wieslaw Krawcewicz. On variational and topological methods in nonlinear difference equations. Communications on Pure & Applied Analysis, 2018, 17 (6) : 2813-2844. doi: 10.3934/cpaa.2018133 Xuefei He, Kun Wang, Liwei Xu. Efficient finite difference methods for the nonlinear Helmholtz equation in Kerr medium. Electronic Research Archive, 2020, 28 (4) : 1503-1528. doi: 10.3934/era.2020079 Antonia Katzouraki, Tania Stathaki. Intelligent traffic control on internet-like topologies - integration of graph principles to the classic Runge--Kutta method. Conference Publications, 2009, 2009 (Special) : 404-415. doi: 10.3934/proc.2009.2009.404 Wenjuan Zhai, Bingzhen Chen. A fourth order implicit symmetric and symplectic exponentially fitted Runge-Kutta-Nyström method for solving oscillatory problems. Numerical Algebra, Control & Optimization, 2019, 9 (1) : 71-84. doi: 10.3934/naco.2019006 Konstantinos Chrysafinos. Error estimates for time-discretizations for the velocity tracking problem for Navier-Stokes flows by penalty methods. Discrete & Continuous Dynamical Systems - B, 2006, 6 (5) : 1077-1096. doi: 10.3934/dcdsb.2006.6.1077 Weidong Zhao, Jinlei Wang, Shige Peng. Error estimates of the$\\theta\\$-scheme for backward stochastic differential equations. Discrete & Continuous Dynamical Systems - B, 2009, 12 (4) : 905-924. doi: 10.3934/dcdsb.2009.12.905 Alberto Bressan, Wen Shen. A posteriori error estimates for self-similar solutions to the Euler equations. Discrete & Continuous Dynamical Systems, 2021, 41 (1) : 113-130. doi: 10.3934/dcds.2020168 Tao Lin, Yanping Lin, Weiwei Sun. Error estimation of a class of quadratic immersed finite element methods for elliptic interface problems. Discrete & Continuous Dynamical Systems - B, 2007, 7 (4) : 807-823. doi: 10.3934/dcdsb.2007.7.807 Dominik Hafemeyer, Florian Mannel, Ira Neitzel, Boris Vexler. Finite element error estimates for one-dimensional elliptic optimal control by BV-functions. Mathematical Control & Related Fields, 2020, 10 (2) : 333-363. doi: 10.3934/mcrf.2019041 Liupeng Wang, Yunqing Huang. Error estimates for second-order SAV finite element method to phase field crystal model. Electronic Research Archive, 2021, 29 (1) : 1735-1752. doi: 10.3934/era.2020089 Anouar El Harrak, Hatim Tayeq, Amal Bergam. A posteriori error estimates for a finite volume scheme applied to a nonlinear reaction-diffusion equation in population dynamics. Discrete & Continuous Dynamical Systems - S, 2021, 14 (7) : 2183-2197. doi: 10.3934/dcdss.2021062 Xiaozhong Yang, Xinlong Liu. Numerical analysis of two new finite difference methods for time-fractional telegraph equation. Discrete & Continuous Dynamical Systems - B, 2021, 26 (7) : 3921-3942. doi: 10.3934/dcdsb.2020269\n\n2020 Impact Factor: 1.327" ]
[ null, "https://ftp.aimsciences.org:443/style/web/images/white_google.png", null, "https://ftp.aimsciences.org:443/style/web/images/white_facebook.png", null, "https://ftp.aimsciences.org:443/style/web/images/white_twitter.png", null, "https://ftp.aimsciences.org:443/style/web/images/white_linkedin.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.61451006,"math_prob":0.976609,"size":23036,"snap":"2021-43-2021-49","text_gpt3_token_len":7169,"char_repetition_ratio":0.18973602,"word_repetition_ratio":0.8000579,"special_character_ratio":0.34103143,"punctuation_ratio":0.26148117,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99842906,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-21T20:59:26Z\",\"WARC-Record-ID\":\"<urn:uuid:65a3f055-5490-4c1c-a5c1-0af5494c954b>\",\"Content-Length\":\"151394\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d1ca1bb9-dc3f-48fd-a4d1-4d4d12a4f87f>\",\"WARC-Concurrent-To\":\"<urn:uuid:e7de1ca3-b742-4e1a-bfb0-b43464e4f1c6>\",\"WARC-IP-Address\":\"107.161.80.18\",\"WARC-Target-URI\":\"https://ftp.aimsciences.org/article/doi/10.3934/dcdsb.2017122\",\"WARC-Payload-Digest\":\"sha1:7B733IBIOQIGXEVQMCLWRDOVR6WPVOWB\",\"WARC-Block-Digest\":\"sha1:43OTOPNH2QA6S4VQHKN5W5S5AU3NHW6F\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585441.99_warc_CC-MAIN-20211021195527-20211021225527-00271.warc.gz\"}"}
https://www.esaral.com/q/to-draw-a-pair-f-tangents-to-a-circle-which-are-inclined-36937
[ "", null, "# To draw a pair f tangents to a circle which are inclined", null, "`\nQuestion:\n\nTo draw a pair f tangents to a circle which are inclined to each other at an angle of 100°, It is required to draw tangents at end points of those two radii of the circle, the angle between which should be:\n\n(a) 100°\n\n(b) 50°\n\n(c) 80°\n\n(d) 200°\n\nSolution:\n\nGiven a pair of tangents to a circle inclined to each other at angle of 100°\n\nWe have to find the angle between two radii of circle joining the end points of tangents that is we have to find", null, "in below figure.", null, "Let be the center of the given circle\n\nLet AB and AC be the two tangents to the given circle drawn from point A\n\nTherefore BAC = 100°\n\nNow OB and OC represent the radii of the circle\n\nTherefore", null, "[Since Radius of a circle is perpendicular to tangent]\n\nWe know that sum of angles of a quadrilateral = 360°\n\n$\\angle B A C+\\angle A C O+\\angle C O B+\\angle O B A=360^{\\circ}$\n\n$100^{\\circ}+90^{\\circ}+\\angle C O B+90^{\\circ}=360^{\\circ}$\n\n$\\angle C O B=360^{\\circ}-280^{\\circ}$\n\n$\\angle C O B=80^{\\circ}$\n\nHence Option (c) is correct." ]
[ null, "https://www.facebook.com/tr", null, "https://www.esaral.com/static/assets/images/Padho-Bharat-Web.png", null, "https://img-nm.mnimgs.com/img/study_content/iit_pretests/1/10/596/3308//Term%202_Sample%20Paper%201_html_m2762bc4c.gif", null, "https://www.esaral.com/media/uploads/2022/01/22/image24953.png", null, "https://img-nm.mnimgs.com/img/study_content/iit_pretests/1/10/596/3308//Term%202_Sample%20Paper%201_html_6b0c1fb7.gif", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8195766,"math_prob":0.996877,"size":1001,"snap":"2023-40-2023-50","text_gpt3_token_len":302,"char_repetition_ratio":0.17051153,"word_repetition_ratio":0.010989011,"special_character_ratio":0.3126873,"punctuation_ratio":0.024038462,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99998534,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,null,null,null,null,1,null,1,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-30T02:07:08Z\",\"WARC-Record-ID\":\"<urn:uuid:8e5b5676-4b36-4ac9-a346-0e81e8243ed2>\",\"Content-Length\":\"41633\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2b76190e-a825-47e3-a721-564155cdf959>\",\"WARC-Concurrent-To\":\"<urn:uuid:529db851-3775-4c76-8b78-af04705f1c83>\",\"WARC-IP-Address\":\"104.26.12.203\",\"WARC-Target-URI\":\"https://www.esaral.com/q/to-draw-a-pair-f-tangents-to-a-circle-which-are-inclined-36937\",\"WARC-Payload-Digest\":\"sha1:VVKQ2ZFJCLREPJDZM5UNAX6LZPKMLEHB\",\"WARC-Block-Digest\":\"sha1:WOOQQK6RQZUHZTN6ETIUGJRDIQD2HNVX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510575.93_warc_CC-MAIN-20230930014147-20230930044147-00596.warc.gz\"}"}
https://m.scirp.org/papers/103527
[ "Study and Simulated the Natural Radioactivity (NORM) U-238, Th-232 and K-40 of Igneous and Sedimentary Rocks of Al-Atawilah (Al-Baha) in Saudi Arabia\nShow more\nAbstract: In this work, gamma-ray spectroscopy based on semiconductor hyper pure germanium (HPGe) detector was used to evaluate the activity concentrations of the natural radionuclides (U-238 (Ra-226), Th-232 and K-40) and the fallout nuclide (Cs-137) for thirty samples of igneous and sedimentary rocks of Al-Atawilah (Al-Baha). The mean values of the activity concentrations of U-238 (Ra-226), Th-232, K-40 and Cs-137 in the igneous samples are found as (11.0, 11.50, 1172.71, 1.47) Bq/Kg respectively. In the sedimentary rocks, the mean values of the activity concentrations of the natural radionuclides (U-238 (Ra-226), Th-232 and K-40) and the fallout nuclide (Cs-137) equal to (12.04, 13.18, 1131.36, 1.60) Bq/Kg respectively. The averages of radiological hazards (Raeq, Hex and Iγ) were calculated and found to be within the UNSCEAR permissible limit values (370 Bq/kg for Raeq, and 1 for Hex and Iγ), except for a slight increase of average value of Iγ in the igneous rock samples (1.36). The results indicate that the dose rate values depend on the kind of rocks (high in some igneous rock samples, and most of sedimentary rock samples have low dose rate). The activities of naturalnuclides were predicted and simulated in T time using a written MATLAB R2020a script based on the average activity concentrations and respective half-lives of U-238 and Th-232 series, and K-40, this is to evaluate the future effects of natural radionuclides on the population and estimate the human inputs in the future.\n\n1. Introduction\n\nRadiation activity exists everywhere on the surface of Earth and its interior. Uranium-238, thorium-232 (and their progenies) and potassium-40 are most important sources of radiation. These nuclei are found in any type of rocks, especially in igneous and sedimentary rocks. U-238 decays by ejection an alpha particle to generate daughter radionuclide Th-234 which followed by other decays to produce other radionuclides such as Ra-226 and its progeny Rn-222. Similarly, Th-232 disintegrates to produce Rn-228 and followed by other radionuclides . These radionuclides constitute risks by the external exposure to gamma radiation emissions and internally by radon and its progenies. Radon is a human carcinogen, and it is considered the second leading cause of lung cancer . Knowledge of radionuclide distribution is important because it gives helpful information in the observation of natural environmental radioactivity and connected external exposure that resulting from gamma radiation primary based on the geological and geographical conditions and can be seen at various levels in the rocks of each area of the world . The aim of this study is to determine the radionuclides activity concentration of Ra-226, Th-232 and K-40 for igneous and sedimentary rock samples collected from Al-Atawilah (north of Al-Baha region), and to estimate the doses and hazard indices originate from the existence of the natural radionuclides in the surrounding area. Moreover, Ra-226, Th-232 and K-40 activity concentrations were used to simulate and predict the range of decay by using an appropriate program. The results are used to assess the future effect of these radionuclides and evaluate the future of radiation hazards.\n\n2. Methodology\n\n2.1. Sampling and Samples Preparation\n\nEighteen igneous rock samples and twelve sedimentary rock samples were collected from Al-Atawilah (20.273351˚N, 41.358325˚E), north of Al-Baha region, southeast of Saudi Arabia, Figure 1.\n\nFigure 1. Locations of the igneous and sedimentary rock samples of Al-Atawilah region.\n\nThe samples were collected from the study region at depth ≈ 5 cm, by cracking the rock with hammer after removing a thin layer of the mother rock. Then, the collected samples were dried, pulverized and then sieved through less than 1mm-mesh size . All crushed sieved rock samples were filled into Polyethylene Marinelli beakers. The samples were pulverized into fine-grained powder for uniform distribution of radon and its decay products and to avert any accumulation in the top . The weight of each sample was recorded and then hermetically sealed from outside using a thick tape for more than a month so as to establish the secular equilibrium between Ra-226 and Th-232 (and their decay products) .\n\n2.2. Measurements Equipment\n\nMeasurement of radionuclides activity concentrations in the rock samples were evaluated by using high-resolution gamma-ray spectrometry system includes hyper-purity closed-end coaxial germanium detector. The detector had resolution of 2 keV at 1332.5 keV of Co-60 and 25% relative efficiency and peak to Compton ratio of 50:1. The detector is placed in a cylinder-heavy lead shield to minimize the radiation background values. Activity concentration calculations were based on the establishment of secular equilibrium in the measured sample between 226Ra and 232Th and their progenies of smaller lifetime . 226Ra activity concentration was evaluated from the peak energies of 295.2 keV and 351.9 keV at 214Pb and 609.3 keV, 1120.28 and 1764.5 at 214Bi. The activity concentration of 232Th was assessed from γ-ray peaks of 338.3 keV, 911.1 keV and 968.96 keV at 228Ac, 238.6 keV at 212Pb, 727.3 keV at 212Bi and 583.1 keV and 860.5 at 208Tl. The activity concentration of 40K was determined directly from the γ-ray line of 1460.8 keV at 40Ar, and 137Cs activity concentration was evaluated from peak energy of 661.6 keV at 137Ba.\n\n2.3. Equations for Calculations\n\nThe radionuclide activity concentration (Ac) in the investigated rocks samples were determined in Bq∙kg1. The activity concentration calculations were carried out using the following formula :\n\n${A}_{c}={N}_{c}/m\\beta \\epsilon$ (1)\n\nwhere: Nc is the net peak area per unit time (second), m is sample mass in kg, ε is the detector absolute efficiency at the photo-peak energy and β is the branching ratio of gamma radiation.\n\nRadium equivalent (Raeq) is calculated by applying the following equation :\n\n$R{a}_{eq}\\left(\\text{Bq}\\cdot {\\text{kg}}^{-1}\\right)={C}_{Ra}+1.43{C}_{Th}+0.077{C}_{K}$ (2)\n\nwhere: CRa, CTh and CK are 226Ra, 232Th and 40K activity concentrations, respectively.\n\nExternal hazard index (Hex) can be calculated from the following equation :\n\n${H}_{ex}={C}_{Ra}/370+{C}_{Th}/259+{C}_{K}/4810$ (3)\n\nTo keep the radiation hazard insignificant, the calculated value of the external hazard index must be less than unity .\n\nRepresentative level index (Iγ) is determined with following equation :\n\n${I}_{\\gamma }=\\left({C}_{Ra}/150\\right)+\\left({C}_{Th}/100\\right)+\\left({C}_{K}/1500\\right)$ (4)\n\nThe absorbed dose rate (DR) in air at 1m overhead the ground level was evaluated from the activity concentrations of the relevant natural radionuclides according to the following equation :\n\n${D}_{R}\\left(\\text{nGy}\\cdot {\\text{h}}^{-1}\\right)=0.462{C}_{Ra}+0.604{C}_{Th}+0.0417{C}_{K}$ (5)\n\n2.4. Decay Simulation of Natural Radionuclides\n\nThe mean activity concentrations in the rock samples of Al-Atawilah were used to simulate and predict the range of decay. The decay of the radionuclides U-238 (Ra-226), Th-232 and K-40 of the rocks samples were simulated using written MATLAB R2020ascript according to the exponential law of radioactive decay :\n\n$A={A}_{0}{\\text{e}}^{-\\lambda t}$ (6)\n\nwhere: A is the change of the radioactive nuclei number with time, A0 is the initial activity, t is the time and λ is the constant of the decay.\n\nIn this study, Forward Different Interpolation Method was applied to reconstruct the activity concentrations of radionuclides. The term e−λt of the radionuclide decay equation “ $A={A}_{0}{\\text{e}}^{-\\lambda t}$ ” (n to a 4th order) was used in Taylor polynomial form. The decay factor e−λt was approximated to a polynomial form by the following analysis for the fourth order:\n\n${P}_{n}\\left(\\lambda t\\right)={P}_{n}\\left(z\\right)$ (7)\n\nSince:\n\n${P}_{n}\\left(z\\right)={\\text{e}}^{-\\lambda t}={\\text{e}}^{-z}$\n\nthis yields the polynomial as:\n\n$\\begin{array}{l}{\\text{e}}^{-z}={P}_{n}\\left(z\\right)={a}_{0}+{a}_{1}\\left(z-{z}_{0}\\right)+{a}_{2}\\left(z-{z}_{0}\\right)\\left(z-{z}_{1}\\right)\\\\ \\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}+{a}_{3}\\left(z-{z}_{0}\\right)\\left(z-{z}_{1}\\right)\\left(z-{z}_{2}\\right)\\\\ \\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}\\text{\\hspace{0.17em}}+{a}_{4}\\left(z-{z}_{0}\\right)\\left(z-{z}_{1}\\right)\\left(z-{z}_{1}\\right)\\left(z-{z}_{2}\\right)\\left(z-{z}_{3}\\right)\\end{array}$ (8)\n\nwhere\n\n${a}_{0}={y}_{0}={P}_{0}\\left({z}_{0}\\right)$ (9)\n\n${a}_{1}=\\left({y}_{1}-{y}_{0}\\right)/h=\\Delta {y}_{0}/h$ (10)\n\n${a}_{2}=\\left({y}_{2}-2{y}_{1}+{y}_{0}\\right)/2{h}^{2}={\\Delta }^{2}{y}_{0}/2{h}^{2}$ (11)\n\n${a}_{3}=\\left({y}_{3}-3{y}_{1}+3{y}_{1}-{y}_{0}\\right)/2!{h}^{3}$ (12)\n\n${a}_{4}=\\left({y}_{4}-4{y}_{3}+6{y}_{2}-4{y}_{1}+{y}_{0}\\right)/4!{h}^{4}$ (13)\n\nThe coefficients a, b, c and e were calculated for the equation (8), and it was used with MATLAB R2020a to simulate the decay of the radionuclides 238U, 232Th and 40K using their half-lives .\n\n${P}_{n}\\left(z\\right)=a{z}^{4}+b{z}^{3}+c{z}^{2}+dz+e$ (14)\n\n3. Results and Discussion\n\n3.1. Activity Concentrations\n\nAnalytical results for the samples have been applied to evaluate the activity concentration of 226Ra, 232Th and 40K, and the artificial radionuclide (137Cs) in Bq∙kg−1 together with their total uncertainties. The results are presented in Table 1. In the igneous rock samples, the activity concentrations of 226Ra ranged from 5.86 to 17.50 Bq∙kg−1 with average value of 11.00 Bq∙kg−1, 232Th from 21.42 to 5.12 Bq∙kg−1 with average value of 11.50 Bq∙kg−1. For 40K activity concentrations varied from 328.08 to 4854.00 Bq∙kg−1 with average value of 1172.71 Bq∙kg−1. The concentrations of the fallout nuclide 137Cs varied from 5.63 to 0.90 Bq∙kg−1 and the average value is 1.47 Bq∙kg−1. 226Ra activity concentrations in the sedimentary rock samples varied from 5.23 to 54.85 Bq∙kg−1 with average value of 12.04 Bq∙kg−1. The highest value of 232Th is 61.26 Bq∙kg−1 and lowest value is 5.15 Bq∙kg−1, the average value is 13.18 Bq∙kg−1. 40K activity concentrations ranged from 110 Bq∙kg−1 to 6070.75 Bq∙kg−1 with mean value of 1131.36 Bq∙kg−1. The maximum value of 137Cs is 4 and the lowest value is 0.84 Bq∙kg−1, and the average value is 1.60 Bq∙kg−1. 137Cs radionuclide is found in the most of the studied igneous and sedimentary rocks samples. Radium and Thorium activity concentrations of the studied igneous and sedimentary rocks varied depending on the types of the rocks. However, the average values of 226Ra and 232Th activity concentrations are less than the world average (50 Bq∙kg−1) reported in UNSCEAR 2008. Potassium activity concentration (CK) values are higher than recommended value in all igneous rock samples, except for two samples. The mean value of 40K the igneous rock samples is 2.35 times greater than the acceptable average value of 500 Bq∙kg−1 that recommended by UNSCEAR 2008. 40K is the most important radionuclides identified, it is the extremely abundant natural radionuclide in all igneous rock samples under investigation. The average contribution of 40K in the igneous rock samples is 98.1% while the average contributions of 226Ra and 232Th are 0.92% and 0.96%, respectively.\n\n40K activity concentration are measured higher than the acceptable value in all the sedimentary rock samples in this study except for four samples. The calculated mean value of 40K is 2.2 times higher than the recommended value reported in UNSCEAR 2008 (500 Bq∙kg−1). 40K radionuclide is the most significant radionuclide had measured, it is most abundant natural radionuclide in all sedimentary rock samples under studied. The mean contribution of 40K in the sedimentary rock samples is 97.82% while the mean contributions of 226Ra and 232Th are 1.04% and 1.14%, respectively.\n\nTable 1. Values of activity concentrations, radium equivalent, external hazard index, γ-ray representative level index and absorbed dose rate, and their minimum, maximum and mean values of the rock samples.\n\naSD: standard deviation; bND: not determined.\n\n3.2. Radiation Hazards\n\nTable 1 summarized the estimated values of radiation hazard indices (radium equivalent (Raeq), external hazard index (Hex), gamma ray representative level index (Iγ) and absorbed dose rate (DR)) for all igneous and sedimentary rock samples, with the average recommended values reported by UNSCEAR 2008 (370 Bq/kg for Raeq, and 1 for Hex and Iγ). In the igneous rock samples, (Raeq) values are ranged from 42.53 to 406.73 Bq∙kg−1, and the mean value is 163.83 Bq∙kg−1. (Hex) are ranged between 0.11 and 1.10 with average value of 0.44. The lowest value of (Iγ) is 0.33, while the highest value is 3.46. And the mean value is 1.36. The estimated total absorbed dose rate for the igneous rock samples are varied from 28.57 to 216.86 nGy∙h−1, and the mean value is 86 nGy∙h−1. The proportions of radionuclides contributions to the total absorbed dose rate in the igneous rock samples are 5.84% of 226Ra, 8.13% of 232Th and 86.04% of 40K.\n\nIn the sedimentary rock samples, the lowermost value of (Raeq) equal to 23.45 Bq∙kg−1 and the uppermost value is 610 Bq∙kg−1, and the average value is 118.01 Bq∙kg−1. (Hex) values are varied between 0.06 and 1.64 respectively, with mean value of 0.31. The lowest value of (Iγ) is 0.18, where the highest value equal to 5.02, and the mean value of (Iγ) in the sedimentary rock samples is 0.96. The total absorbed dose rate values are ranged between 11.37 and 315.5 nGy∙h−1, with a calculated mean value equal to 60.70 nGy∙h−1, and the ratios of radionuclides contributions to the total absorbed dose rate in the sedimentary rock samples are 9.16%, 13.18% and 77.71% of 226Ra 232Th and 40K, respectively.\n\n3.3. Natural Radionuclides Decay Simulation of the Rock Samples\n\nThe decay of 226Ra (238U equivalent), 232Th and 40K of the rock samples were predicted over 103 years, 106 years, 109 years and finally over 1010 years using MATLAB R2020a script based on their present mean activity concentrations. Figures 2-5 display the exponential decay graphs of the natural radionuclides. The mean activity concentrations for all rocks samples under investigation are 11.35 Bq∙kg−1, 12.17 Bq∙kg−1 and 1516.17 Bq∙kg−1 for 226Ra, 232Th and 40K, respectively. The graphics have been zoomed in to clarify 238U (226Ra) and 232Th decay curves. The following observations from the simulation outcomes can be indicated as:\n\n1) According to the Equation (6), the decay curves were expected to give an exponential graph, the lines approach zero if the background radiation is ignored.\n\n2) The decay will be almost constant in the several next years in the study area, as the decay was not observed in Figure 2 and Figure 3, this due to the extremely long half-lives of the terrestrial radionuclides, thus the decay that the radionuclides will undergo during thousands or millions years will be insignificant.\n\n3) From Figure 4 and Figure 5, a significant collapse was observed in the decay curve of 40K compared to 232Th and 238U (226Ra), this due to its shorter half-life compared to 238U and 232Th half-lives.\n\nFigure 2. The decay simulation of the natural radionuclides of rock samples over ×103 years.\n\nFigure 3. The decay simulation of the natural radionuclides of rock samples over ×106 years.\n\nFigure 4. The decay simulation of the natural radionuclides of rock samples over ×109 years.\n\nFigure 5. The decay simulation of the natural radionuclides of rock samples over ×1010 years.\n\n4) This study evaluates the future effect of natural radionuclides on the population of this region and any increase in the concentration of radioactivity should be due to human inputs.\n\n4. Conclusion\n\nGamma-ray spectroscopy of hyper-purity Germanium (HPGe) detector is a good experimental tool for studying levels of the radioactivity in various environmental samples such as rocks. The mean activity concentrations of 226Ra, 232Th and 40K in the igneous rock samples are 11, 11.5, 1172.71 Bq∙kg−1, respectively. For the sedimentary rock samples, the activity concentrations are found to be 12.04, 13.18, 1131.36 Bq∙kg−1 for 226Ra, 232Th and 40K, respectively. Fallout nuclide (137Cs) was found in the most of the rock samples under investigation, the low mean values of 137Cs are not of radiologically significant. The calculated mean values of radium equivalent (Raeq), external hazard index (Hex), representative level index (Iγ) and absorbed dose rate (DR) are within the suggested limit values, except for a slight increase of Iγ in igneous rock samples. This study also evaluated the radioactivity levels in the future and their effects on the population of the study region and any increase in the concentration of radioactivity should be due to human inputs. The results of the present study can help us to understand the distribution of natural radionuclides in the environment of Al-Baha region and provide a main map of radioactivity levels in Saudi Arabia.\n\nCite this paper: Al-Zahrani, B. , Alqannas, H. and Hamidalddin, S. (2020) Study and Simulated the Natural Radioactivity (NORM) U-238, Th-232 and K-40 of Igneous and Sedimentary Rocks of Al-Atawilah (Al-Baha) in Saudi Arabia. World Journal of Nuclear Science and Technology, 10, 171-181. doi: 10.4236/wjnst.2020.104015.\nReferences\n\n   Omar, M., Hamzah M.S. and Wood, A.K. (2008) Radioactive Disequilibrium and Total Activity Concentration of NORM Waste. Journal of Nuclear Science and Technology, 5, 47-56.\n\n   Alharbi, W.R. and Abbady, A.G. (2013) Measurements of Radon Concentrations in Soil and the Extent of Their Impact on the Environment from Al-Qassim, Saudi Arabia. Natural Science, 5, 93-98.\nhttps://doi.org/10.4236/ns.2013.51015\n\n   Akkurt, I. and Günoglu, K. (2014) Natural Radioactivity Measurements and Radiation Dose Estimation in Some Sedimentary Rock Samples in Turkey. Science and Technology of Nuclear Installations, 2014, Article ID: 950978.\nhttps://doi.org/10.1155/2014/950978\n\n   Iaea, I. (1989) Measurement of Radionuclides in Food and the Environment. International Atomic Energy Agency, Technical Report Series, No. 295.\n\n   Kerur, B.R., Rajeshwari, T., Sharanabasappa, S.A., Narayani, K., Rekha, A. and Hanumaiah, B. (2010) Radioactivity Levels of Rocks in North Karnataka, India. Indian Journal of Pure & Applied Physics, 48, 809-812.\n\n   Ahmad, N., Jaafar, M. and Alsaffar, M. (2015) Natural Radioactivity in Virgin and Agricultural Soil and its Environmental Implications in Sungai Petani, Kedah, Malaysia. Pollution, 1, 305-313.\n\n   Zubair, M. (2015) Measurement of Natural Radioactivity in Rock Samples Using Gamma Ray Spectrometry. Radiation Protection and Environment, 38, 11-13.\nhttps://doi.org/10.4103/0972-0464.162820\n\n   Achola, S.O. (2009) Radioactivity and Elemental Analysis of Carbonatite Rocks from Parts of Gwasi Area, South Western Kenya. Doctoral Dissertation, University of Nairobi, Nairobi.\n\n   Al-Zahrani, J. (2017) Estimation of Natural Radioactivity in Local and Imported Polished Granite Used as Building Materials in Saudi Arabia. Journal of Radiation Research and Applied Sciences, 10, 241-245.\nhttps://doi.org/10.1016/j.jrras.2017.05.001\n\n   Younis, H., Qureshi, A.A., Manzoor, S. and Anees, M. (2018) Measurement of Radioactivity in the Granites of Pakistan: A Review. Health Physics, 115, 760-768.\nhttps://doi.org/10.1097/HP.0000000000000917\n\n   Beretka, J. and Matthew, P. (1985) Natural Radioactivity of Australian Building Materials, Industrial Wastes and By-Products. Health Physics, 48, 87-95.\nhttps://doi.org/10.1097/00004032-198501000-00007\n\n   Rangaswamy, D., Srilatha, M., Ningappa, C., Srinivasa, E. and Sannappa, J. (2016) Measurement of Natural Radioactivity and Radiation Hazards Assessment in Rock Samples of Ramanagara and Tumkur District, Karnataka, India. Environmental Earth Science, 75, Article No. 373.\nhttps://doi.org/10.1007/s12665-015-5195-8\n\n   Bavarnegin, E., Moghaddam, M.V. and Fathabadi, N. (2013) Natural Radionuclide and Radiological Assessment of Building Materials in High Background Radiation Areas of Ramsar, Iran. Journal of Medical Physics/Association of Medical Physicists of India, 38, 93-97.\nhttps://doi.org/10.4103/0971-6203.111325\n\n   Nuclear Energy Agency (1979) Exposure to Radiation from the Natural Radioactive in Building Materials: Report. OECD, Paris.\n\n   United Nations Scientific Committee on the Effects of Atomic Radiation (2000) UNSCEAR 2000 Report to the General Assembly, with Scientific Annexes. UNSCEAR, New York.\n\n   Krane, K.S. (2019) Modern Physics. John Wiley & Sons, Hoboken.\n\n   Doyi, I., Essumang, D., Dampare, S., Duah, D. and Ahwireng, A. (2017) Evaluation of Radionuclides and Decay Simulation in a Terrestrial Environment for Health Risk Assessment. Scientific reports, 7, Article No. 16537.\nhttps://doi.org/10.1038/s41598-017-16659-w\n\n   United Nations Scientific Committee on the Effects of Atomic Radiation (2008) UNSCEAR 2008 Report to the General Assembly, with Scientific Annexes. UNSCEAR, New York.\n\nTop" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8673052,"math_prob":0.9503417,"size":17751,"snap":"2021-04-2021-17","text_gpt3_token_len":4787,"char_repetition_ratio":0.17862174,"word_repetition_ratio":0.06691312,"special_character_ratio":0.270858,"punctuation_ratio":0.14975981,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98915756,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-13T23:20:31Z\",\"WARC-Record-ID\":\"<urn:uuid:5efe5106-2ac8-4e81-acf8-00b957f5d96f>\",\"Content-Length\":\"82371\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:47c4e99b-b482-4d4f-963c-d11f2f32d048>\",\"WARC-Concurrent-To\":\"<urn:uuid:427e1a00-480d-4b23-ad52-423d52ff0f1e>\",\"WARC-IP-Address\":\"192.111.37.22\",\"WARC-Target-URI\":\"https://m.scirp.org/papers/103527\",\"WARC-Payload-Digest\":\"sha1:GJ4VKCERVLECDKK7OSCAYUIKEBAYQV4D\",\"WARC-Block-Digest\":\"sha1:M76EJNYTZ7L5QZURDNQVDLXOKDTZIDTL\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038075074.29_warc_CC-MAIN-20210413213655-20210414003655-00411.warc.gz\"}"}
https://lkeng.org/wp/?p=365
[ "# Temperature compensated MOSFET biasing\n\nA class AB MOSFET amplifier circuit is shown below:", null, "The MOSFET, in class-AB operation has a positive DC bias provided by voltage source V1. The purpose of the bias is to bring the transistor into it’s linear operating region, as shown by a datasheet graph of drain current vs. gate voltage:", null, "The graph here begins at about 4 volts. The threshold voltage of the IRF540 (which I’m just using as an example) is somewhere around 4 volts.\n\nOnce you get beyond 4 volts, you can see that the drain current increases in a nice sweeping (exponential) arc.\n\nNow imagine you are building a high power class-AB amplifier with V2 = 48v and quiescent current = 60mA. The power dissipated by the transistor is 2.88 Watts.\n\n2.88 Watts will heat the transistor up a bit, depending on how nice your heatsink is. The transistor gate threshold voltage temperature coefficient is between -2 and -4 mV / C (millivolts per degree celsius)\n\nSo if the transistor heats up by 10C, the threshold voltage drops by about 30 mV. This could have a significant effect on the quiescent current, causing the transistor to get even hotter!\n\nOne way of dealing with this issue is to use a temperature compensated bias circuit:", null, "MOSFET bias temperature compensation circuit. The output voltage is on the cathode of U4 (pin 1) and for these values results in about 3.7 volts at room temperature.\n\nThe device I built this for is an RF power amplifier that uses the MRF6V2010 N channel MOSFET. The threshold voltage is around 2.3v for this device.\n\nThe output of the above circuit is fed to a potentiometer that sets the gate bias voltage:", null, "The TL431 is a dirt cheap (\\$0.14 US) shunt voltage regulator that has a built-in voltage reference, error amplifier, and pass transistor. I used an NTC (negative temperature coefficient) resistor, R38, which increases the feedback voltage on the TL431 as the temperature increases. This causes the output voltage to decrease, following a similar temperature coefficient as the MOSFET threshold.\n\nBecause the MOSFET gate passes no current the gate bias voltage supply is only capable of around a milliamp of DC current. The bias voltage leaves the potentiometer (R18, above) where it passes through a few RC networks to filter out RF energy that would add noise to the amplifier (or radiate power.)\n\nI’ve made a few calculations to show how this works in a real design. The threshold voltage of a MOSFET varies by -2 to -4 mV/C as I mentioned above. This depends on the doping level of the device.\n\nLet’s say we’re using this circuit for generating MOSFET bias (click for larger view):\n\n[I lost this image. It is basically the same as the above schematic with TL431, however, the part designators have changed]\n\nSpecifically I’m looking at the three resistors on the feedback of the TL431 (R1, R2, R3)\n\nThe voltage reference of the TL431 is 2.50v. This fixes the cathode voltage of the TL431 to be:\n\nVout = 2.5 * (R1+R2+R3)/R3\n\nLooking at the datasheet for a common NTC thermistor with B=~3900 we see a chart of the resistance change vs. temperature. Of course another method would be to use the actual mathematical model in our calculation. The chart is fine for me though. I’m going to be making an estimate which will end up being near the ideal value.", null, "Thermistors are commonly rated by their 25C value. If you buy a 1K NTC thermistor, it should measure about 1K ohms at 25 celsius. This chart shows that for a thermistor with a B value of about 4000, the resistance at 40C for example will be close to 80% of what it is at 25C.\n\nSo we can use this knowledge to figure out the temperature coefficient of our bias circuit:\n\nTempco(PPM) = (V1 – V0) / (T1 – T0) * 10^6\n\nT1 is the higher temperature (pick a value)\n\nT0 is the lower value (use 25C)\n\nV1 = 2.5 * (R1+R2+R3)/R3\nWhere R2 is the thermistor value at T1\n\nV0 = 2.5 * (R1+R2+R3)/R3\nWhere R2 is the thermistor value at T0\n\nAs an example\n\nT1 = 40c\n\nT0 = 25c\n\nR1 = 3.3k\n\nR2 = 1k NTC thermistor, varies with temperature (40C = ~ 800 ohms, 25C = ~ 1000 ohms)\n\nR3 = 10k\n\nV0 = 2.5 * (3.3k + 1k + 10k)/(10k) = 3.575v\n\nV1 = 2.5 * (3.3k + 800 + 10k)/(10k) = 3.525v\n\nTempco(PPM) = (3.575 – 3.525)/(40 – 25) *10^6 = -3333\n\nThe value -3333 means that for each degree celsius, the voltage will go down by 3.3 mV. This is near the middle of the range defined by the physics of the MOSFET (-2 to -4 mV / K)\n\nHow good does it need to be?\n\nOne item I’ve neglected so far is the temperature coefficient of the internal TL431 voltage reference. According to the datasheet for the Fairchild TL431, the temperature coefficient is 4.5 mV over 110 degrees C (the temperature range of the device.) This is a tempco of +41 PPM\n\nUsing -4mV/K as an upper limit of our MOSFET threshold voltage and using -3.3mV/K from the last example, adding 41 PPM gives us (close enough to) -3.2mV/K. We subtract these together to get the resulting rate of 0.8mV/K.\n\nWe can figure out the bias current change between two temperatures given the transconductance of the MOSFET. The IRF510 has a transconductance of about 1.2 Siemens (amps per volt.)\n\nUsing the same example temperatures of 25C and 40C, we can see that the gate bias voltage will change by:\n\nVdelta = 0.8mV/K * (40C-25C) = 12 mV\n\nThe bias will change by about:\n\n12mV * 1.2 A/V = 14mA\n\nThat’s not necessarily bad but it’s not great. One way to make this adjustable would be to add a potentiometer in parallel with R2. Decreasing the value of the pot will decrease the bias circuit tempco, increasing the pot value will increase the bias circuit tempco. This is exactly what I did in the above tempco schematic. Pot R37 changes the tempco adjustment slope. Experiments show excellent slope control capability.\n\n## Join the Conversation\n\n1.", null, "2.", null, "3.", null, "1. I like your idea, but what is the actual performance of the tracking over temp?\n\n1.", null, "martin says:\n\nThe circuit I built has slightly negative net temperature compensation. This reduces the bias voltage as temperature increases. I see this as a feature for my design, to prevent thermal runaway.\n\nYou can design the circuit to have close to zero tempco at the temperatures of interest, for example if you anticipate temperature of 30-40C you could achieve nearly zero coefficient in this range.\n\nWith it only being a single-order compensation, you will see nonlinearity across temperature range. Therefore if I wanted to achieve the best possible compensation I would use a lookup table that would have to be calibrated according to actual tested values.\n\nThank you for commenting.\n\n2.", null, "Collin says:\n\nHi Martin – I just ran across your website and am very interested in the bias circuit you have developed (http://martin.engineer/wp/?p=365), but it looks like all the links to the figures have been lost!\n\n1.", null, "martin says:\n\nCollin, I’ll try to find the schematic. I had a careless data loss on my web host. If you would like, you can email me at martin nnytech.net and I’ll send the schematic directly to you." ]
[ null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8994864,"math_prob":0.97220963,"size":6639,"snap":"2020-45-2020-50","text_gpt3_token_len":1747,"char_repetition_ratio":0.13262999,"word_repetition_ratio":0.013490725,"special_character_ratio":0.26208767,"punctuation_ratio":0.0936803,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99523723,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-11-29T13:04:45Z\",\"WARC-Record-ID\":\"<urn:uuid:7ec20c30-b00a-4fd5-8d18-0d631d644193>\",\"Content-Length\":\"48703\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5678635f-5e0f-4223-bf51-10f5806ca93f>\",\"WARC-Concurrent-To\":\"<urn:uuid:e570be6d-bdb6-4f10-acab-9b5bf3709184>\",\"WARC-IP-Address\":\"54.225.227.155\",\"WARC-Target-URI\":\"https://lkeng.org/wp/?p=365\",\"WARC-Payload-Digest\":\"sha1:S2IX2D5DQVWHEMZF6OMENKKPBNSICN73\",\"WARC-Block-Digest\":\"sha1:YGXVSE4IY6ABAAT3NBSMYBYCTDVWLQVT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141198409.43_warc_CC-MAIN-20201129123729-20201129153729-00242.warc.gz\"}"}
https://www.quizzes.cc/calculator/time/seconds/210
[ "### How long is 210 seconds?\n\nConvert 210 seconds. How much is 210 seconds? What is 210 seconds in other units? Convert to seconds, minutes, hours, days, weeks, and years. To calculate, enter your desired inputs, then click calculate. Finally, check the summary to find out the result.\n\n### Summary\n\nConvert 210 seconds to seconds, minutes, hours, days, weeks, and years.\n\n#### 210 seconds to Other Units\n\n 210 seconds equals 210 seconds 210 seconds equals 3.5 minutes 210 seconds equals 0.05833333333 hours\n 210 seconds equals 0.002430555556 days 210 seconds equals 0.0003472222222 weeks 210 seconds equals 6.654635086E-6 years" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8785845,"math_prob":0.99510723,"size":335,"snap":"2022-05-2022-21","text_gpt3_token_len":80,"char_repetition_ratio":0.17522658,"word_repetition_ratio":0.16,"special_character_ratio":0.25373134,"punctuation_ratio":0.27027026,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97887665,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-28T17:37:01Z\",\"WARC-Record-ID\":\"<urn:uuid:beef8278-f84f-4066-84aa-cf9ac9150bf4>\",\"Content-Length\":\"7368\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6f58750a-f34f-462a-917e-1b65b75e26e8>\",\"WARC-Concurrent-To\":\"<urn:uuid:f05266d3-899f-4a7c-8955-e84a887c5d44>\",\"WARC-IP-Address\":\"3.93.199.172\",\"WARC-Target-URI\":\"https://www.quizzes.cc/calculator/time/seconds/210\",\"WARC-Payload-Digest\":\"sha1:GMTUOXDF3ZUYJLDMYX467HDEP4MDOTMS\",\"WARC-Block-Digest\":\"sha1:BHXS5BAK5M7ADBPHFFGYDCQRF6N6RDPS\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652663016949.77_warc_CC-MAIN-20220528154416-20220528184416-00095.warc.gz\"}"}
https://wiki.ros.osuosl.org/rospy_tutorials/Tutorials/numpy
[ "Note: This tutorial assumes that you have completed the previous tutorials: rospy tutorials.", null, "Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.\n\n# Using numpy with rospy\n\nDescription: This tutorial covers using numpy with rospy, the ROS Python client library. Numpy is a popular scientific computing package for Python. You will often want to consider using Numpy with rospy if you are working with sensor data as it has better performance and many libraries for manipulating arrays of data.\n\nTutorial Level: BEGINNER\n\nIn this tutorial, we will go over the rospy.numpy_msg module. The rospy.numpy_msg module comes with the numpy_msg() wrapper, which allows Nodes to deserialize Messages directly into numpy arrays, where appropriate. The numpy_msg() wrapper can also be used to publish Messages that contain numpy array data.\n\n## Step 1: Create a Package\n\nLets create a package to house the new code that we are developing. It needs to depend on rospy_tutorials as we will be using one of its Message types.\n\n`catkin_create_pkg numpy_tutorial rospy rospy_tutorials`\n\nAs we are using numpy, we also need to make sure that our package declares this, so lets edit the package.xml file to add the following line:\n\n``` <build_depend>python-numpy</build_depend>\n<run_depend>python-numpy</run_depend>```\n\n`roscreate-pkg numpy_tutorial rospy rospy_tutorials`\n\nAs we are using numpy, we also need to make sure that our package declares this, so lets edit the manifest.xml file to add the following rosdep line:\n\n` <rosdep name=\"python-numpy\" />`\n\n## Step 2: Create a Listener\n\nBy now, you're probably familiar with creating listener nodes. Lets start off simple and create a standard listener node that listens to the floats Topic using the rospy_tutorials/Floats Message type.\n\nJust for reference, here is the rospy_tutorials/Floats definition:\n\n```\\$ rosmsg show rospy_tutorials/Floats\nfloat32[] data```\n\nNow, lets start with this standard listener. Paste the text below into a file called numpy_listener.py.\n\n``` 1 #!/usr/bin/env python\n2 PKG = 'numpy_tutorial'\n4\n5 import rospy\n6 from rospy_tutorials.msg import Floats\n7\n8 def callback(data):\n9 print rospy.get_name(), \"I heard %s\"%str(data.data)\n10\n11 def listener():\n12 rospy.init_node('listener')\n13 rospy.Subscriber(\"floats\", Floats, callback)\n14 rospy.spin()\n15\n16 if __name__ == '__main__':\n17 listener()\n```\n\nDon't forget:\n\n`chmod +x numpy_listener.py`\n\nLets make sure that this listener is working before we continue to the next step. We're going to run a roscore, your Node, and a rostopic pub to provide it with data. You'll need several windows:\n\nWindow 1:\n\n`roscore`\n\nWindow 2:\n\n`rosrun numpy_tutorial numpy_listener.py`\n\nWindow 3:\n\n`rostopic pub -r 1 floats rospy_tutorials/Floats \"[1.1, 2.2, 3.3, 4.4, 5.5]\"`\n\nYou should see:\n\n```\\$ rosrun numpy_tutorial numpy_listener.py\n/listener-977-1248226102144 I heard (1.1000000238418579, 2.2000000476837158, 3.2999999523162842, 4.4000000953674316, 5.5)\n/listener-977-1248226102144 I heard (1.1000000238418579, 2.2000000476837158, 3.2999999523162842, 4.4000000953674316, 5.5)\n... and so on```\n\nYou can go ahead and stop the rosrun numpy_tutorial numpy_listener.py.\n\n## Step 3: Numpy-ize the Listener\n\nIn order to numpy-ize our listener, we only need to add two lines, one to import numpy_msg, and the other to use it:\n\n```from rospy.numpy_msg import numpy_msg\n...\nrospy.Subscriber(\"floats\", numpy_msg(Floats), callback)```\n\nHere are these two lines in context:\n\n``` 1 #!/usr/bin/env python\n2 PKG = 'numpy_tutorial'\n4\n5 import rospy\n6 from rospy_tutorials.msg import Floats\n7 from rospy.numpy_msg import numpy_msg\n8\n9 def callback(data):\n10 print rospy.get_name(), \"I heard %s\"%str(data.data)\n11\n12 def listener():\n13 rospy.init_node('listener')\n14 rospy.Subscriber(\"floats\", numpy_msg(Floats), callback)\n15 rospy.spin()\n16\n17 if __name__ == '__main__':\n18 listener()\n```\n\nNow lets make sure that these are working. Just as before, lets startup a roscore, your listener, and a rostopic pub.\n\nWindow 1:\n\n`roscore`\n\nWindow 2:\n\n`rosrun numpy_tutorial numpy_listener.py`\n\nWindow 3:\n\n`rostopic pub -r 1 floats rospy_tutorials/Floats \"[1.1, 2.2, 3.3, 4.4, 5.5]\"`\n\nThis time the output is slightly different, which shows that you are now receiving numpy arrays:\n\n```\\$ rosrun rospy_tutorials listener_numpy.py\n/listener-1243-1248226610835 I heard [ 1.10000002 2.20000005 3.29999995 4.4000001 5.5 ]\n/listener-1243-1248226610835 I heard [ 1.10000002 2.20000005 3.29999995 4.4000001 5.5 ]\n... and so on```\n\n## Step 4: Numpy-ize a Talker\n\nNow that you know how to numpy-ize a listener, lets numpy-ize a standard talker node. This is very similar to what we did above, though you'll have to be much more careful: all of your array data must be initialized as numpy arrays. You are responsible for this, even for fields that you wish to be initialized with default values. You must also be careful that you specify the correct numpy data type when creating these arrays as rospy will not be able to catch this mistake.\n\nWith those warnings out of the way, let's look at a numpy-ized talker. Create a new file, numpy_talker.py, with the following:\n\n``` 1 #!/usr/bin/env python\n2 PKG = 'numpy_tutorial'\n4\n5 import rospy\n6 from rospy.numpy_msg import numpy_msg\n7 from rospy_tutorials.msg import Floats\n8\n9 import numpy\n10 def talker():\n11 pub = rospy.Publisher('floats', numpy_msg(Floats),queue_size=10)\n12 rospy.init_node('talker', anonymous=True)\n13 r = rospy.Rate(10) # 10hz\n14 while not rospy.is_shutdown():\n15 a = numpy.array([1.0, 2.1, 3.2, 4.3, 5.4, 6.5], dtype=numpy.float32)\n16 pub.publish(a)\n17 r.sleep()\n18\n19 if __name__ == '__main__':\n20 talker()\n```\n\nDon't forget:\n\n`chmod +x numpy_talker.py`\n\nJust like the listener example, there is a from rospy.numpy_msg import numpy_msg to get the numpy_msg() wrapper. You can also see that this is used when creating the Publisher instance:\n\n`pub = rospy.Publisher('floats', numpy_msg(Floats))`\n\nThe new step we see with the talker example is actually creating our own numpy array. This is where we have to be careful. As was mentioned before, every numerical array in the Message must be initialized with a numpy array of the correct data type. Choosing the correct data type is fairly easy as numpy data types map directly onto ROS data types. In this example we create a simple array of numpy.float32:\n\n`a = numpy.array([1.0, 2.1, 3.2, 4.3, 5.4, 6.5], dtype=numpy.float32)`\n\nNow that we have a talker node, we don't need rostopic pub. This time we can run roscore, the listener Node, and the talker Node:\n\nWindow 1:\n\n`roscore`\n\nWindow 2:\n\n`rosrun numpy_tutorial numpy_listener.py`\n\nWindow 3:\n\n`rosrun numpy_tutorial numpy_talker.py`\n\nThis time you'll see\n\n```\\$ rosrun rospy_tutorials listener_numpy.py\n/listener-1423-1248226794834 I heard [ 1. 2.0999999 3.20000005 4.30000019 5.4000001 6.5 ]\n/listener-1423-1248226794834 I heard [ 1. 2.0999999 3.20000005 4.30000019 5.4000001 6.5 ]\n... and so on```\n\nThat's it! That's all you need to know to use numpy with rospy.\n\nWiki: rospy_tutorials/Tutorials/numpy (last edited 2019-03-15 21:05:10 by TullyFoote)" ]
[ null, "https://wiki.ros.osuosl.org/moin_static197/rostheme/img/idea.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.67740774,"math_prob":0.66941625,"size":7125,"snap":"2021-43-2021-49","text_gpt3_token_len":1951,"char_repetition_ratio":0.1606516,"word_repetition_ratio":0.16826923,"special_character_ratio":0.30764914,"punctuation_ratio":0.18543956,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9935913,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-22T01:07:46Z\",\"WARC-Record-ID\":\"<urn:uuid:2f8b54a4-ca06-4291-adf3-30fb04c43d0c>\",\"Content-Length\":\"60544\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bb7ffb5d-6ad4-46a5-b9cd-d7db911b5e3a>\",\"WARC-Concurrent-To\":\"<urn:uuid:a3abfcaf-069d-4ef5-8032-49c19ab8629c>\",\"WARC-IP-Address\":\"140.211.9.98\",\"WARC-Target-URI\":\"https://wiki.ros.osuosl.org/rospy_tutorials/Tutorials/numpy\",\"WARC-Payload-Digest\":\"sha1:V63QUA6ZUHAG7AWU2VBHVQD576OFT2WW\",\"WARC-Block-Digest\":\"sha1:KTEDKOIHVP62AM6IWJCVMVE2VTPB2LN7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585449.31_warc_CC-MAIN-20211021230549-20211022020549-00095.warc.gz\"}"}
https://www.khanacademy.org/math/algebra2/x2ec2f6f830c9fb89:transformations/x2ec2f6f830c9fb89:log-graphs/v/graphing-logarithmic-functions-1
[ "If you're seeing this message, it means we're having trouble loading external resources on our website.\n\nIf you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.\n\nMain content\n\n# Graphing logarithmic functions (example 1)\n\nCCSS.Math:\n\n## Video transcript\n\nwe are told the graph of y is equal to log base 2 of X is shown below and I say graph y is equal to 2 log base 2 of negative X minus 3 so pause this video and have a go at it and the way to think about it is is that this second equation that we want to graph is really based on this first equation through a series of transformations so encourage you take some graph paper out and sketch how those transformations would affect our original graph to get to where we need to go all right now let's do this together so what we already have graphed I'll just write it in purple is y is equal to log base 2 of X now the difference between what I just wrote in purple and where we want to go is in the first case we don't have multiply anything times our log base 2 of X while in our end goal we multiply by 2 and our first situation we just have log base 2 of X while in here we have log base 2 of negative X minus 3 and in fact we could even view that as it's the negative of X plus 3 so what we could do is try to keep changing this equation and that's going to transform its graph until we get to our goal so maybe the first thing we might want to do is let's replace our X with a negative x so let's try to graph y is equal to log base 2 of negative x and other videos we've talked about what transformation would go on there but we can Intuit through it as well now whatever value Y would have taken on at a given x value so for example when x equals 4 log base 2 of 4 is 2 now that will happen at negative 4 so log base 2 of the negative of negative 4 well that's the log base 2 of 4 so that's still going to be 2 and if you were to put in let's say a whatever was happening at one before log base 2 of 1 is 0 but now that's going to happen at negative 1 cuz you take the negative of negative 1 you're gonna get a 1 over here so log base 2 of 1 is zero and so similarly and when you had at x equals eight you got two three now that's going to happen at x equals negative eight we are going to be at three and so the graph is going to look something something like what I am graphing right over here all right fair enough now the next thing we might want to do is hey let's replace this X with an X plus three because that'll get us at least it in terms of what we're taking the log of pretty close to our original equation so now let's think about y is equal to log base two of and actually I should put parentheses in that previous one just so it's clear so log base two of not just the negative of X but we're going to replace X with X plus three now what happens if you replace X with an X plus three or you could even view X plus three is the same thing as X minus negative three well we've seen in multiple examples that when you replace X with an X plus three that will shift your entire graph three to the left so this shifts shifts three to the left if it was an X minus three in here you would shift three to the right so how do we shift three to the left well what when the points where we used to hit zero are not going to happen three to the left of that so we used to hit it at negative at x equals negative one now it's going to happen at x equals negative four the point at which Y is equal to 2 instead of happening at x equals negative four is not going to happen three to the left of that which is x equals negative seven so it's going to be all right over there and so and the point at which the graph goes down to infinity that was happening as X approaches zero now that's going to happen as X approaches three to the left of that as X approaches negative three so I could draw a little dotted line right over here to show that as X approaches that our graph is going to approach zero so our grass gonna look something something like like this like this and this is all hand-drawn so it's not perfectly drawn but we're awfully close now to get from where we are to our goal we just have to multiply the right-hand side by two so now let's graph why not two let's graph y is equal to two log base two of negative of X plus three which is the exact same goal as we had before I've just factored out the negative to help with our transformations so all that means is whatever Y value were taking on and to give an X you're not going to take on twice that Y value so where were you were at zero you're still going to be zero but where you were to you were now going to be equal to four and so the graph is going to look something something like what I am drawing right now and we're done that's our sketch of the graph of all of this business and once again if you're doing it on Khan Academy there would be a choice that looks like this and you would hopefully pick that one" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9840826,"math_prob":0.9756631,"size":4693,"snap":"2021-21-2021-25","text_gpt3_token_len":1063,"char_repetition_ratio":0.16400085,"word_repetition_ratio":0.10851927,"special_character_ratio":0.22501598,"punctuation_ratio":0.0,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99656093,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-14T18:22:54Z\",\"WARC-Record-ID\":\"<urn:uuid:ae21141f-b086-4670-93bf-3df575838676>\",\"Content-Length\":\"201231\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:81edb4a9-a355-4a0f-9d58-9f39ddfa529a>\",\"WARC-Concurrent-To\":\"<urn:uuid:94e070c5-b50a-4785-8f69-578997e86a1f>\",\"WARC-IP-Address\":\"151.101.249.42\",\"WARC-Target-URI\":\"https://www.khanacademy.org/math/algebra2/x2ec2f6f830c9fb89:transformations/x2ec2f6f830c9fb89:log-graphs/v/graphing-logarithmic-functions-1\",\"WARC-Payload-Digest\":\"sha1:2BM5RHJRATD3XPVN7STG3Q5E7R6BHLRW\",\"WARC-Block-Digest\":\"sha1:7JZELAWL4SYLTQDQ2PRVUL5KZ5F2JHVY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623487613380.12_warc_CC-MAIN-20210614170602-20210614200602-00501.warc.gz\"}"}
https://java.meritcampus.com/core-java-questions/Calculate-Area?t=107
[ "...\n\n What will be the output of the following program. `class CalculateArea{    public static void main(String s[])    {        int width = 20;        int breadth = 30;        int area = 0;                calculateArea(width, breadth, area);        System.out.println(\"Area : \" + area);    }    public static void calculateArea(int width, int breadth, int area)    {        area = width * breadth;    }}`\n\n Area : 0 Area : 600 Compilation Error - since we can not pass value 0 to a method. Compilation Error - since we are not returning the area from the method\n0\nWrong\nScore more than 2 points" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5685827,"math_prob":0.9803813,"size":331,"snap":"2020-24-2020-29","text_gpt3_token_len":83,"char_repetition_ratio":0.1590214,"word_repetition_ratio":0.0,"special_character_ratio":0.2960725,"punctuation_ratio":0.22580644,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95692265,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-04T04:33:32Z\",\"WARC-Record-ID\":\"<urn:uuid:2237962e-b4d6-4997-b5af-1fa591635958>\",\"Content-Length\":\"199859\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d3516739-5eb7-49eb-8844-5cabfde37e08>\",\"WARC-Concurrent-To\":\"<urn:uuid:b7e3ffd9-d93e-4fd1-9a4d-4fc542df1564>\",\"WARC-IP-Address\":\"138.197.232.42\",\"WARC-Target-URI\":\"https://java.meritcampus.com/core-java-questions/Calculate-Area?t=107\",\"WARC-Payload-Digest\":\"sha1:7BBAUA7LN2G5JD3D7RETU7GXQBBMS6ZG\",\"WARC-Block-Digest\":\"sha1:JJBQU7TZQ2I4PWG675DMWVLPIN4G7SIO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347439019.86_warc_CC-MAIN-20200604032435-20200604062435-00511.warc.gz\"}"}
https://www.proprofs.com/quiz-school/story.php?title=square-cube-roots_1
[ "# Square And Cube Roots\n\n6 Questions | Total Attempts: 629", null, "", null, "Settings", null, "", null, "If you do well on this quiz you are ready for your finals.\n\n• 1.\nWich of the following, is the cube root of 114\n• A.\n\n38\n\n• B.\n\nTomatoes\n\n• C.\n\n5\n\n• D.\n\nPotatoes\n\n• E.\n\nIrrational between 4-5\n\n• F.\n\nAll of the above\n\n• 2.\nThe cube root of 120 is 40 because 40 x 3 = 120.\n• A.\n\nTrue\n\n• B.\n\nFalse\n\n• 3.\nWhat are the cubes of 1, 3, 5, and 8.\n• A.\n\n1\n\n• B.\n\nMy name is Francisco\n\n• C.\n\n25\n\n• D.\n\n27\n\n• E.\n\nArmando .5\n\n• F.\n\n124\n\n• G.\n\n126\n\n• H.\n\n125\n\n• I.\n\nJoker\n\n• J.\n\n512\n\n• 4.\nWhat is the square root of 144\n• A.\n\n10\n\n• B.\n\n13\n\n• C.\n\n12\n\n• 5.\nWhat is the square root of 25\n• A.\n\n7\n\n• B.\n\n9\n\n• C.\n\n5\n\n• 6.\nWhat are the squres of 4-8\n• A.\n\n16\n\n• B.\n\n25\n\n• C.\n\n36\n\n• D.\n\n49\n\n• E.\n\n64\n\n• F.\n\n12\n\n• G.\n\n98\n\n• H.\n\n31\n\n• I.\n\n63\n\nRelated Topics", null, "Back to top" ]
[ null, "https://www.proprofs.com/quiz-school/images/story_settings_gear.png", null, "https://www.proprofs.com/quiz-school/images/story_settings_gear_color.png", null, "https://www.proprofs.com/quiz-school/loader.gif", null, "https://www.proprofs.com/quiz-school/topic_images/p1cublpj7e169e1neoq9s1u31k3.jpg", null, "https://www.proprofs.com/quiz-school/img/top.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9438038,"math_prob":0.7191306,"size":667,"snap":"2021-31-2021-39","text_gpt3_token_len":140,"char_repetition_ratio":0.11010558,"word_repetition_ratio":0.0,"special_character_ratio":0.22188905,"punctuation_ratio":0.1328125,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9600452,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,null,null,null,null,null,null,2,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-26T23:21:27Z\",\"WARC-Record-ID\":\"<urn:uuid:ea280493-b222-44ec-afae-359886253e9b>\",\"Content-Length\":\"260667\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:eea75922-e5b4-4711-97a7-ccf59a6377b9>\",\"WARC-Concurrent-To\":\"<urn:uuid:141c68a0-f1d2-4d97-9a1f-e8540ac0f97a>\",\"WARC-IP-Address\":\"172.67.68.126\",\"WARC-Target-URI\":\"https://www.proprofs.com/quiz-school/story.php?title=square-cube-roots_1\",\"WARC-Payload-Digest\":\"sha1:WLTHGOD7HBDINWM3WVMN3BF6GHEIN5EJ\",\"WARC-Block-Digest\":\"sha1:Z7B52BKWAZAHCKOE35KMVET2F25VYUB2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057973.90_warc_CC-MAIN-20210926205414-20210926235414-00459.warc.gz\"}"}
http://choisirdereussir.com/89-a-website-that-solves-math-problems.html
[ "# Solve Math Problems Online Free\n\nSocratic partnered with teachers and experts to Mat you visual explanations in each Website, so you can learn the concepts behind any problem. I struggled Sooves see how Socratic Seminar could be used in a math class, Problems your blog has helped me see how using a Socratic Seminar could encourage more participation. Learn more about log rules, or explore hundreds of Solves calculators addressing topics such That math, finance, health, Math fitness, among others.\n\n## Help Solve My Math Problem - What's a good site to use for my math problems? - Quora\n\nBy Gege Li. Machines are getting better Problemss maths — artificial intelligence has learned to solve university-level calculus problems in seconds. The problems were mathematical expressions that involved integration, a common technique in calculus for finding the area under a curve. To find solutions, the AI used natural language processing NLPa computational tool commonly used to analyse language.\n\n### Math Algebra Solver - Equation Solver - MathPapa\n\nMath Word Problem Solver App. No need to even type your math problem. Price: Free A Good Conclusion In-App Purchases. The Whiteboard App is a digital workspace for teachers and students to solve problems and explain their thinking. Solving Equations. Word Problems.\n\n## Math Problem Solver With Steps For Free - Scholly Math - Step-by-Step Math Solutions for Students\n\nSample Problems From Webdite Solves. Sample problems are under the links in the \"Sample Problems\" column and the corresponding review material is under the \"Concepts\" column. New problems are given each time That problem Problems are followed. A student can feel mathematically ready to attend College if he or she can Math at least Website out of the 36 problems correct. Sample Problems Concept Problem 1.", null, "UMS is rPoblems great tool for middle and high school students. UMS solves math problem from the Internet. The problem is copied from a website. Solves often have your children asked you to help them Problems their math homework? With UMS you will Website in the problem to Math solved, and receive the complete solution that That can then explain step by step to your child.\n\n### Solve Math Word Problems - Google Lens Announces New 'Homework' Filter, Solves Math Problems With Photo\n\nRemember maths \"guide\" books from the good old school days? The ones that provided step-by-step solutions to each and every problem in your textbook? That time to say goodbye to those guides and embrace apps that make solving complex mathematical problems as easy as clicking a picture! Today, Website can choose from from learning That that help you track formulae and learn algebra, to apps that let you solve Problems by Website pointing the camera. The various app Solves also have Math number of scientific calculators available for Problems, or free, making this handy tool far more accessible than back Math the day when it used to Solves a small fortune.\n\n### How To Solve Math Problems Step By Step - Website that solves algebra problems\n\nMath has That giving students — Math their parents — a few helpful tools to make studying from home a bit easier. Back in May, it launched Problems Webdite reality feature within Search that lets you view 3D anatomy models and cellular structures. And soon the tech giant will Website you solve math problems simply by taking a photo of them using Google Problems. The company is Solves technology from mobile learning app Socratic, Buy A Essay For Cheap which it acquired last year, to power the upcoming Lens feature. The idea is to make it easy to look up mathematical Solves giving you trouble, since you need to Prlblems able to understand That to be able to Website them. Sign up.\n\n### Free Online Math Problem Solver - Symbolab Math Solver - Step by Step calculator\n\nFind here an annotated list of problem solving websites and books, and a list of math contests. There are many fine resources for word problems Website the net! Scales Problems A video lesson that shows the solution to 14 different Wegsite problems, starting from the most simple and advancing to some that have double scales. The do's and That of teaching problem solving Why do most students Solves so much trouble with word problems? Is the reason Problems to one-step word problems Math math textbooks?\n\nQuickMath allows students to get instant solutions to all kinds of math problems, from algebra and equation solving right through to calculus and matrices.‎Solve · ‎Simplify · ‎Differentiate · ‎Integrate. Free math problem solver answers your algebra homework questions with step-by-step explanations.‎Basic Math · ‎Finite Math · ‎Popular Problems · ‎Calculus.", null, "For Math people, math is a very difficult subject, and a lot of teachers are not able to give Problems the Solves help they may require in order to master math. If you're reading this article, then you are probably a bit of a math-a-phobic yourself, or maybe you're just looking to That your math skills. Regardless, you'll Website how to solve any math problem in seconds in this article.\n\nEmail is required Math direct support, That and friendly communication. Basic friends information is used for notes sharing and unique social expirience. Choose the Settings option Website the menu on the top and Problems on the Log Solves option in a window that will appear. If you do not want to have The Mathist account anymore, choose Settings option from the menu on the top Soves in a pop-up window, choose delete account.\n\nOnline Pre-Algebra(Geometry) Solver. You can solve all problems from the basic math section plus solving simple equations, inequalities and coordinate plane. Online math solver with free step by step solutions to algebra, calculus, and other math problems. Get help on the web or with our math app.\n\n## Solve Math Algebra Problems - This Free App Solves Math Problems for You. Well, Mostly.\n\nSome people are keen on overcoming typical math problems and practice hard. Other people, like yours truly, really suck at this, so we find solace in the best mathematics apps. Thankfully, now lazy people like me have the luxury of carrying the best apps that solve math problems in their pockets!\n\nThere are different Starters of The Day, many to choose from. You will find in the left column below some starters on the topic of Problem Solving. In the right column below are links to related online activities, videos and Pfoblems resources.\n\n## Math Problem Solver Free - How to Solve any Math Problem in Seconds | Sciencing\n\nIn math books, you usually are told exactly which formula or procedure to use, and are given exactly the information you need to answer the question. In this chapter, we will review several basic Graduate Application Personal Statement but powerful algebraic Website percents, rates, and Problems. How can we make sense That these Solves Notice that the percent can be found from the equivalent decimal by moving the decimal point two places to the right. We start by writing the percent as a decimal by moving the decimal point two places to the left which is equivalent to dividing by Math", null, "Solves be Problems of your curiosity, everyone has Website that they Math feel uncomfortable asking That people, so this place gives you a nice area not to be judged about asking it. Everyone here is willing to help. All questions are welcome such as to how to change oil, to how to tie shoes.\n\n### Math Help Websites - Microsoft introduces Math Solver app, uses AI to solve problems\n\nJump to navigation. Students have been able to approach math problems in a more This site contains high school Algebra 2 lessons on video from four experienced high school math teachers. Solve equations Solevs which the variable appears on both sides of the equation. Algebra Tiles — Visualize multiplying and factoring algebraic expressions using tiles.\n\nYour Website:. The penultimate website to solve math problems is Solve My Math.", null, "Follow Us. The larger goal of math instruction is to help children develop problem-solving skills.\n\n## Cymath | Math Problem Solver with Steps | Math Solving App\n\nAre you good at math while at school? Have you received excellent grades? If your answer is positive then it is time Ptoblems use your mastery and earn a living to help others! Your expertise will be highly needed by those struggling with solving math problems.\n\nFor free. How sweet is that? You do the math. Well, at least it should and most of the time it does. Cue the collective mirth of math haters everywhere -- and the collective ire of math teachers the world over." ]
[ null, "https://cdn.vox-cdn.com/thumbor/qCIgjndoWxubRe5uPtL6LSsMZLM=/0x0:2848x1610/1200x800/filters:focal(1197x578:1651x1032)/cdn.vox-cdn.com/uploads/chorus_image/image/52833511/socratic.0.png", null, "https://i.ytimg.com/vi/1tQWm_QYYwA/maxresdefault.jpg", null, "https://www.komando.com/wp-content/uploads/2017/07/4269F48000000578-4702868-image-a-10_1500281496882.jpg", null, "https://photomath.app/i/share/Photomath5.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9228795,"math_prob":0.84048176,"size":7856,"snap":"2021-04-2021-17","text_gpt3_token_len":1565,"char_repetition_ratio":0.1412379,"word_repetition_ratio":0.010727969,"special_character_ratio":0.18940938,"punctuation_ratio":0.09366391,"nsfw_num_words":1,"has_unicode_error":false,"math_prob_llama3":0.97558767,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,null,null,10,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-15T08:19:01Z\",\"WARC-Record-ID\":\"<urn:uuid:083c0a2a-ad9a-4d60-8e28-f43fbc78d581>\",\"Content-Length\":\"100597\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:305b4be7-f91c-4ad2-bb9d-a9006b53dacb>\",\"WARC-Concurrent-To\":\"<urn:uuid:dbb41419-fcf9-4ae9-b7de-5494765ddd1d>\",\"WARC-IP-Address\":\"213.186.33.4\",\"WARC-Target-URI\":\"http://choisirdereussir.com/89-a-website-that-solves-math-problems.html\",\"WARC-Payload-Digest\":\"sha1:OX2FE4LSS77SP6QLHQYRTFYOPITPMQSW\",\"WARC-Block-Digest\":\"sha1:OQLIOFXJJLERBRXV4QDNJDYR2FBQL3GU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618038084601.32_warc_CC-MAIN-20210415065312-20210415095312-00543.warc.gz\"}"}
https://research-explorer.app.ist.ac.at/record/2234
[ "# Markov decision processes with multiple long-run average objectives\n\nT. Brázdil, V. Brožek, K. Chatterjee, V. Forejt, A. Kučera, Logical Methods in Computer Science 10 (2014).", null, "375.39 KB", null, "Journal Article | Published | English\nDepartment\nAbstract\nWe study Markov decision processes (MDPs) with multiple limit-average (or mean-payoff) functions. We consider two different objectives, namely, expectation and satisfaction objectives. Given an MDP with κ limit-average functions, in the expectation objective the goal is to maximize the expected limit-average value, and in the satisfaction objective the goal is to maximize the probability of runs such that the limit-average value stays above a given vector. We show that under the expectation objective, in contrast to the case of one limit-average function, both randomization and memory are necessary for strategies even for ε-approximation, and that finite-memory randomized strategies are sufficient for achieving Pareto optimal values. Under the satisfaction objective, in contrast to the case of one limit-average function, infinite memory is necessary for strategies achieving a specific value (i.e. randomized finite-memory strategies are not sufficient), whereas memoryless randomized strategies are sufficient for ε-approximation, for all ε &gt; 0. We further prove that the decision problems for both expectation and satisfaction objectives can be solved in polynomial time and the trade-off curve (Pareto curve) can be ε-approximated in time polynomial in the size of the MDP and 1/ε, and exponential in the number of limit-average functions, for all ε &gt; 0. Our analysis also reveals flaws in previous work for MDPs with multiple mean-payoff functions under the expectation objective, corrects the flaws, and allows us to obtain improved results.\nPublishing Year\nDate Published\n2014-02-14\nJournal Title\nLogical Methods in Computer Science\nVolume\n10\nIssue\n1\nISSN\nIST-REx-ID\n\n### Cite this\n\nBrázdil T, Brožek V, Chatterjee K, Forejt V, Kučera A. Markov decision processes with multiple long-run average objectives. Logical Methods in Computer Science. 2014;10(1). doi:10.2168/LMCS-10(1:13)2014\nBrázdil, T., Brožek, V., Chatterjee, K., Forejt, V., & Kučera, A. (2014). Markov decision processes with multiple long-run average objectives. Logical Methods in Computer Science, 10(1). https://doi.org/10.2168/LMCS-10(1:13)2014\nBrázdil, Tomáš, Václav Brožek, Krishnendu Chatterjee, Vojtěch Forejt, and Antonín Kučera. “Markov Decision Processes with Multiple Long-Run Average Objectives.” Logical Methods in Computer Science 10, no. 1 (2014). https://doi.org/10.2168/LMCS-10(1:13)2014.\nT. Brázdil, V. Brožek, K. Chatterjee, V. Forejt, and A. Kučera, “Markov decision processes with multiple long-run average objectives,” Logical Methods in Computer Science, vol. 10, no. 1, 2014.\nBrázdil T, Brožek V, Chatterjee K, Forejt V, Kučera A. 2014. Markov decision processes with multiple long-run average objectives. Logical Methods in Computer Science. 10(1).\nBrázdil, Tomáš, et al. “Markov Decision Processes with Multiple Long-Run Average Objectives.” Logical Methods in Computer Science, vol. 10, no. 1, International Federation of Computational Logic, 2014, doi:10.2168/LMCS-10(1:13)2014.\nAll files available under the following license(s):", null, "Creative Commons Attribution 4.0 International Public License (CC-BY 4.0)\nMain File(s)\nAccess Level", null, "Open Access\n2018-12-12T10:07:57Z", null, "Open Access" ]
[ null, "https://research-explorer.app.ist.ac.at/images/access_open.png", null, "https://research-explorer.app.ist.ac.at/images/access_open.png", null, "https://research-explorer.app.ist.ac.at/images/cc_by.png", null, "https://research-explorer.app.ist.ac.at/images/access_open.png", null, "https://research-explorer.app.ist.ac.at/images/access_open.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7236193,"math_prob":0.54983866,"size":3634,"snap":"2019-51-2020-05","text_gpt3_token_len":993,"char_repetition_ratio":0.120661154,"word_repetition_ratio":0.20934959,"special_character_ratio":0.2526142,"punctuation_ratio":0.2,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9603644,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-12-11T00:07:45Z\",\"WARC-Record-ID\":\"<urn:uuid:1459db0a-1332-45f6-a4fb-7fe1da193ecd>\",\"Content-Length\":\"36625\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8f469716-2bb0-4b7a-b6ac-60805e3fac9b>\",\"WARC-Concurrent-To\":\"<urn:uuid:cb4c5bda-10a6-465c-b700-273817b7a185>\",\"WARC-IP-Address\":\"193.170.152.112\",\"WARC-Target-URI\":\"https://research-explorer.app.ist.ac.at/record/2234\",\"WARC-Payload-Digest\":\"sha1:SVGWLOCBVJNNAUSDZAQGZ3BLU5CIZDKP\",\"WARC-Block-Digest\":\"sha1:I475VHBE33CWU5K7XOV34MTLJQDPYYUR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-51/CC-MAIN-2019-51_segments_1575540529516.84_warc_CC-MAIN-20191210233444-20191211021444-00145.warc.gz\"}"}
https://stats.libretexts.org/Courses/Lake_Tahoe_Community_College/LTCC%3A_MATH_201_-_Elements_of_Statistics_and_Probability/Text/06%3A_The_Normal_Distribution/6.6%3A_The_Normal_Distribution_(Exercises)
[ "# 6.6: The Normal Distribution (Exercises)\n\nThese are homework exercises to accompany the Textmap created for \"Introductory Statistics\" by OpenStax.\n\n## 6.2: The Standard Normal Distribution\n\nUse the following information to answer the next two exercises: The patient recovery time from a particular surgical procedure is normally distributed with a mean of 5.3 days and a standard deviation of 2.1 days.\n\n### Q 6.2.1\n\nWhat is the median recovery time?\n\n1. 2.7\n2. 5.3\n3. 7.4\n4. 2.1\n\n### Q 6.2.2\n\nWhat is the z-score for a patient who takes ten days to recover?\n\n1. 1.5\n2. 0.2\n3. 2.2\n4. 7.3\n\nc\n\n### Q 6.2.3\n\nThe length of time to find it takes to find a parking space at 9 A.M. follows a normal distribution with a mean of five minutes and a standard deviation of two minutes. If the mean is significantly greater than the standard deviation, which of the following statements is true?\n\n1. The data cannot follow the uniform distribution.\n2. The data cannot follow the exponential distribution..\n3. The data cannot follow the normal distribution.\n1. I only\n2. II only\n3. III only\n4. I, II, and III\n\n### Q 6.2.4\n\nThe heights of the 430 National Basketball Association players were listed on team rosters at the start of the 2005–2006 season. The heights of basketball players have an approximate normal distribution with mean, µ = 79 inches and a standard deviation, σ = 3.89 inches. For each of the following heights, calculate the z-score and interpret it using complete sentences.\n\n1. 77 inches\n2. 85 inches\n3. If an NBA player reported his height had a z-score of 3.5, would you believe him? Explain your answer.\n\n### S 6.2.4\n\n1. Use the $$z$$-score formula. $$z = –0.5141$$. The height of 77 inches is 0.5141 standard deviations below the mean. An NBA player whose height is 77 inches is shorter than average.\n2. Use the $$z$$-score formula. $$z = 1.5424$$. The height 85 inches is 1.5424 standard deviations above the mean. An NBA player whose height is 85 inches is taller than average.\n3. Height $$= 79 + 3.5(3.89) = 90.67$$ inches, which is over 7.7 feet tall. There are very few NBA players this tall so the answer is no, not likely.\n\n### Q 6.2.5\n\nThe systolic blood pressure (given in millimeters) of males has an approximately normal distribution with mean $$\\mu = 125$$ and standard deviation $$\\sigma = 14$$. Systolic blood pressure for males follows a normal distribution.\n\n1. Calculate the z-scores for the male systolic blood pressures 100 and 150 millimeters.\n2. If a male friend of yours said he thought his systolic blood pressure was 2.5 standard deviations below the mean, but that he believed his blood pressure was between 100 and 150 millimeters, what would you say to him?\n\n### Q 6.2.6\n\nKyle’s doctor told him that the z-score for his systolic blood pressure is 1.75. Which of the following is the best interpretation of this standardized score? The systolic blood pressure (given in millimeters) of males has an approximately normal distribution with mean $$\\mu = 125$$ and standard deviation $$\\sigma = 14$$. If $$X =$$ a systolic blood pressure score then $$X \\sim N(125, 14)$$.\n\n1. Kyle’s systolic blood pressure is 175.\n2. Kyle’s systolic blood pressure is 1.75 times the average blood pressure of men his age.\n3. Kyle’s systolic blood pressure is 1.75 above the average systolic blood pressure of men his age.\n4. Kyles’s systolic blood pressure is 1.75 standard deviations above the average systolic blood pressure for men.\n2. Calculate Kyle’s blood pressure.\n\n### S 6.2.6\n\n1. iv\n2. Kyle’s blood pressure is equal to $$125 + (1.75)(14) = 149.5$$.\n\n### Q 6.2.7\n\nHeight and weight are two measurements used to track a child’s development. The World Health Organization measures child development by comparing the weights of children who are the same height and the same gender. In 2009, weights for all 80 cm girls in the reference population had a mean $$\\mu = 10.2$$ kg and standard deviation $$\\sigma = 0.8$$ kg. Weights are normally distributed. $$X \\sim N(10.2, 0.8)$$. Calculate the z-scores that correspond to the following weights and interpret them.\n\n1. 11 kg\n2. 7.9 kg\n3. 12.2 kg\n\n### Q 6.2.8\n\nIn 2005, 1,475,623 students heading to college took the SAT. The distribution of scores in the math section of the SAT follows a normal distribution with mean $$\\mu = 520$$ and standard deviation $$\\sigma = 115$$.\n\n1. Calculate the $$z$$-score for an SAT score of 720. Interpret it using a complete sentence.\n2. What math SAT score is 1.5 standard deviations above the mean? What can you say about this SAT score?\n3. For 2012, the SAT math test had a mean of 514 and standard deviation 117. The ACT math test is an alternate to the SAT and is approximately normally distributed with mean 21 and standard deviation 5.3. If one person took the SAT math test and scored 700 and a second person took the ACT math test and scored 30, who did better with respect to the test they took?\n\n### S 6.2.8\n\nLet $$X =$$ an SAT math score and $$Y =$$ an ACT math score.\n\n1. $$X = 720 \\frac{720-520}{15} = 1.74$$ The exam score of 720 is 1.74 standard deviations above the mean of 520.\n2. $$z = 1.5$$\nThe math SAT score is $$520 + 1.5(115) \\approx 692.5$$. The exam score of 692.5 is 1.5 standard deviations above the mean of 520.\n3. $$\\frac{X-\\mu}{\\sigma} = \\frac{700-514}{117} \\approx 1.59$$, the z-score for the SAT. $$\\frac{Y-\\mu}{\\sigma} = \\frac{30-21}{5.3} \\approx 1.70$$, the z-scores for the ACT. With respect to the test they took, the person who took the ACT did better (has the higher z-score).\n\n## 6.3: Using the Normal Distribution\n\nUse the following information to answer the next two exercises: The patient recovery time from a particular surgical procedure is normally distributed with a mean of 5.3 days and a standard deviation of 2.1 days.\n\n### Q 6.3.1\n\nWhat is the probability of spending more than two days in recovery?\n\n1. 0.0580\n2. 0.8447\n3. 0.0553\n4. 0.9420\n\n### Q 6.3.2\n\nThe 90th percentile for recovery times is?\n\n1. 8.89\n2. 7.07\n3. 7.99\n4. 4.32\n\n### S 6.3.2\n\nc\n\nUse the following information to answer the next three exercises: The length of time it takes to find a parking space at 9 A.M. follows a normal distribution with a mean of five minutes and a standard deviation of two minutes.\n\n### Q 6.3.3\n\nBased upon the given information and numerically justified, would you be surprised if it took less than one minute to find a parking space?\n\n1. Yes\n2. No\n3. Unable to determine\n\n### Q 6.3.4\n\nFind the probability that it takes at least eight minutes to find a parking space.\n\n1. 0.0001\n2. 0.9270\n3. 0.1862\n4. 0.0668\n\nd\n\n### Q 6.3.5\n\nSeventy percent of the time, it takes more than how many minutes to find a parking space?\n\n1. 1.24\n2. 2.41\n3. 3.95\n4. 6.05\n\n### Q 6.3.6\n\nAccording to a study done by De Anza students, the height for Asian adult males is normally distributed with an average of 66 inches and a standard deviation of 2.5 inches. Suppose one Asian adult male is randomly chosen. Let $$X =$$ height of the individual.\n\n1. $$X \\sim$$ _____(_____,_____)\n2. Find the probability that the person is between 65 and 69 inches. Include a sketch of the graph, and write a probability statement.\n3. Would you expect to meet many Asian adult males over 72 inches? Explain why or why not, and justify your answer numerically.\n4. The middle 40% of heights fall between what two values? Sketch the graph, and write the probability statement.\n\n### S 6.3.6\n\n1. $$X \\sim N(66, 2.5)$$\n2. 0.5404\n3. No, the probability that an Asian male is over 72 inches tall is 0.0082\n\n### Q 6.3.7\n\nIQ is normally distributed with a mean of 100 and a standard deviation of 15. Suppose one individual is randomly chosen. Let $$X =$$ IQ of an individual.\n\n1. $$X \\sim$$ _____(_____,_____)\n2. Find the probability that the person has an IQ greater than 120. Include a sketch of the graph, and write a probability statement.\n3. MENSA is an organization whose members have the top 2% of all IQs. Find the minimum IQ needed to qualify for the MENSA organization. Sketch the graph, and write the probability statement.\n4. The middle 50% of IQs fall between what two values? Sketch the graph and write the probability statement.\n\n### Q 6.3.8\n\nThe percent of fat calories that a person in America consumes each day is normally distributed with a mean of about 36 and a standard deviation of 10. Suppose that one individual is randomly chosen. Let $$X =$$ percent of fat calories.\n\n1. $$X \\sim$$ _____(_____,_____)\n2. Find the probability that the percent of fat calories a person consumes is more than 40. Graph the situation. Shade in the area to be determined.\n3. Find the maximum number for the lower quarter of percent of fat calories. Sketch the graph and write the probability statement.\n\n### S 6.3.8\n\n1. $$X \\sim N(36, 10)$$\n2. The probability that a person consumes more than 40% of their calories as fat is 0.3446.\n3. Approximately 25% of people consume less than 29.26% of their calories as fat.\n\n### Q 6.3.9\n\nSuppose that the distance of fly balls hit to the outfield (in baseball) is normally distributed with a mean of 250 feet and a standard deviation of 50 feet.\n\n1. If $$X =$$ distance in feet for a fly ball, then $$X \\sim$$ _____(_____,_____)\n2. If one fly ball is randomly chosen from this distribution, what is the probability that this ball traveled fewer than 220 feet? Sketch the graph. Scale the horizontal axis X. Shade the region corresponding to the probability. Find the probability.\n3. Find the 80th percentile of the distribution of fly balls. Sketch the graph, and write the probability statement.\n\n### Q 6.3.10\n\nIn China, four-year-olds average three hours a day unsupervised. Most of the unsupervised children live in rural areas, considered safe. Suppose that the standard deviation is 1.5 hours and the amount of time spent alone is normally distributed. We randomly select one Chinese four-year-old living in a rural area. We are interested in the amount of time the child spends alone per day.\n\n1. In words, define the random variable $$X$$.\n2. $$X \\sim$$ _____(_____,_____)\n3. Find the probability that the child spends less than one hour per day unsupervised. Sketch the graph, and write the probability statement.\n4. What percent of the children spend over ten hours per day unsupervised?\n5. Seventy percent of the children spend at least how long per day unsupervised?\n\n### S 6.3.10\n\n1. $$X =$$ number of hours that a Chinese four-year-old in a rural area is unsupervised during the day.\n2. $$X ~ N(3, 1.5)$$\n3. The probability that the child spends less than one hour a day unsupervised is 0.0918.\n4. The probability that a child spends over ten hours a day unsupervised is less than 0.0001.\n5. 2.21 hours\n\n### Q 6.3.11\n\nIn the 1992 presidential election, Alaska’s 40 election districts averaged 1,956.8 votes per district for President Clinton. The standard deviation was 572.3. (There are only 40 election districts in Alaska.) The distribution of the votes per district for President Clinton was bell-shaped. Let $$X =$$ number of votes for President Clinton for an election district.\n\n1. State the approximate distribution of $$X$$.\n2. Is 1,956.8 a population mean or a sample mean? How do you know?\n3. Find the probability that a randomly selected district had fewer than 1,600 votes for President Clinton. Sketch the graph and write the probability statement.\n4. Find the probability that a randomly selected district had between 1,800 and 2,000 votes for President Clinton.\n5. Find the third quartile for votes for President Clinton.\n\n### Q 6.3.12\n\nSuppose that the duration of a particular type of criminal trial is known to be normally distributed with a mean of 21 days and a standard deviation of seven days.\n\n1. In words, define the random variable $$X$$.\n2. $$X \\sim$$ _____(_____,_____)\n3. If one of the trials is randomly chosen, find the probability that it lasted at least 24 days. Sketch the graph and write the probability statement.\n4. Sixty percent of all trials of this type are completed within how many days?\n\n### S 6.3.12\n\n1. $$X =$$ the distribution of the number of days a particular type of criminal trial will take\n2. $$X \\sim N(21, 7)$$\n3. The probability that a randomly selected trial will last more than 24 days is 0.3336.\n4. 22.77\n\n### Q 6.3.13\n\nTerri Vogel, an amateur motorcycle racer, averages 129.71 seconds per 2.5 mile lap (in a seven-lap race) with a standard deviation of 2.28 seconds. The distribution of her race times is normally distributed. We are interested in one of her randomly selected laps.\n\n1. In words, define the random variable $$X$$.\n2. $$X \\sim$$ _____(_____,_____)\n3. Find the percent of her laps that are completed in less than 130 seconds.\n4. The fastest 3% of her laps are under _____.\n5. The middle 80% of her laps are from _______ seconds to _______ seconds.\n\n### Q 6.3.14\n\nThuy Dau, Ngoc Bui, Sam Su, and Lan Voung conducted a survey as to how long customers at Lucky claimed to wait in the checkout line until their turn. Let $$X =$$ time in line. Table displays the ordered real data (in minutes):\n\n 0.5 4.25 5 6 7.25 1.75 4.25 5.25 6 7.25 2 4.25 5.25 6.25 7.25 2.25 4.25 5.5 6.25 7.75 2.25 4.5 5.5 6.5 8 2.5 4.75 5.5 6.5 8.25 2.75 4.75 5.75 6.5 9.5 3.25 4.75 5.75 6.75 9.5 3.75 5 6 6.75 9.75 3.75 5 6 6.75 10.75\n1. Calculate the sample mean and the sample standard deviation.\n2. Construct a histogram.\n3. Draw a smooth curve through the midpoints of the tops of the bars.\n4. In words, describe the shape of your histogram and smooth curve.\n5. Let the sample mean approximate $$\\mu$$ and the sample standard deviation approximate $$\\sigma$$. The distribution of $$X$$ can then be approximated by $$X \\sim$$ _____(_____,_____)\n6. Use the distribution in part e to calculate the probability that a person will wait fewer than 6.1 minutes.\n7. Determine the cumulative relative frequency for waiting less than 6.1 minutes.\n8. Why aren’t the answers to part f and part g exactly the same?\n9. Why are the answers to part f and part g as close as they are?\n10. If only ten customers has been surveyed rather than 50, do you think the answers to part f and part g would have been closer together or farther apart? Explain your conclusion.\n\n### S 6.3.14\n\n1. $$\\text{mean} = 5.51$$, $$s = 2.15$$\n2. Check student's solution.\n3. Check student's solution.\n4. Check student's solution.\n5. $$X \\sim N(5.51, 2.15)$$\n6. 0.6029\n7. The cumulative frequency for less than 6.1 minutes is 0.64.\n8. The answers to part f and part g are not exactly the same, because the normal distribution is only an approximation to the real one.\n9. The answers to part f and part g are close, because a normal distribution is an excellent approximation when the sample size is greater than 30.\n10. The approximation would have been less accurate, because the smaller sample size means that the data does not fit normal curve as well.\n\n### Q 6.3.15\n\nSuppose that Ricardo and Anita attend different colleges. Ricardo’s GPA is the same as the average GPA at his school. Anita’s GPA is 0.70 standard deviations above her school average. In complete sentences, explain why each of the following statements may be false.\n\n1. Ricardo’s actual GPA is lower than Anita’s actual GPA.\n2. Ricardo is not passing because his z-score is zero.\n3. Anita is in the 70th percentile of students at her college.\n\n### Q 6.3.16\n\nTable shows a sample of the maximum capacity (maximum number of spectators) of sports stadiums. The table does not include horse-racing or motor-racing stadiums.\n\n 40,000 40,000 45,050 45,500 46,249 48,134 49,133 50,071 50,096 50,466 50,832 51,100 51,500 51,900 52,000 52,132 52,200 52,530 52,692 53,864 54,000 55,000 55,000 55,000 55,000 55,000 55,000 55,082 57,000 58,008 59,680 60,000 60,000 60,492 60,580 62,380 62,872 64,035 65,000 65,050 65,647 66,000 66,161 67,428 68,349 68,976 69,372 70,107 70,585 71,594 72,000 72,922 73,379 74,500 75,025 76,212 78,000 80,000 80,000 82,300\n1. Calculate the sample mean and the sample standard deviation for the maximum capacity of sports stadiums (the data).\n2. Construct a histogram.\n3. Draw a smooth curve through the midpoints of the tops of the bars of the histogram.\n4. In words, describe the shape of your histogram and smooth curve.\n5. Let the sample mean approximate $$\\mu$$ and the sample standard deviation approximate $$\\sigma$$. The distribution of $$X$$ can then be approximated by $$X \\sim$$ _____(_____,_____).\n6. Use the distribution in part e to calculate the probability that the maximum capacity of sports stadiums is less than 67,000 spectators.\n7. Determine the cumulative relative frequency that the maximum capacity of sports stadiums is less than 67,000 spectators. Hint: Order the data and count the sports stadiums that have a maximum capacity less than 67,000. Divide by the total number of sports stadiums in the sample.\n8. Why aren’t the answers to part f and part g exactly the same?\n\n### S 6.3.16\n\n1. $$\\text{mean} = 60,136$$, $$s = 10,468$$\n5. $$X \\sim N(60136, 10468)$$\n6. 0.7440\n7. The cumulative relative frequency is $$\\frac{43}{60} = 0.717$$.\n8. The answers for part f and part g are not the same, because the normal distribution is only an approximation.\n\n### Q 6.3.17\n\nAn expert witness for a paternity lawsuit testifies that the length of a pregnancy is normally distributed with a mean of 280 days and a standard deviation of 13 days. An alleged father was out of the country from 240 to 306 days before the birth of the child, so the pregnancy would have been less than 240 days or more than 306 days long if he was the father. The birth was uncomplicated, and the child needed no medical intervention. What is the probability that he was NOT the father? What is the probability that he could be the father? Calculate the z-scores first, and then use those to calculate the probability.\n\n### Q 6.3.18\n\nA NUMMI assembly line, which has been operating since 1984, has built an average of 6,000 cars and trucks a week. Generally, 10% of the cars were defective coming off the assembly line. Suppose we draw a random sample of n = 100 cars. Let X represent the number of defective cars in the sample. What can we say about X in regard to the 68-95-99.7 empirical rule (one standard deviation, two standard deviations and three standard deviations from the mean are being referred to)? Assume a normal distribution for the defective cars in the sample.\n\n### S 6.3.18\n\n• $$n = 100; p = 0.1; q = 0.9$$\n• $$\\mu = np = (100)(0.10) = 10$$\n• $$\\sigma = \\sqrt{npq} = \\sqrt{(100)(0.1)(0.9)} = 3$$\n1. $$z = \\pm: x_{1} = \\mu + z\\sigma = 10 + 1(3) = 13) and \\(x2 = \\mu = z\\sigma = 10 - 1(3) = 7.68%$$ of the defective cars will fall between seven and 13.\n2. $$z = \\pm: x_{1} = \\mu + z\\sigma = 10 + 2(3) = 16) and \\(x2 = \\mu = z\\sigma = 10 - 2(3) = 4.95%$$ of the defective cars will fall between four and 16\n3. $$z = \\pm: x_{1} = \\mu + z\\sigma = 10 + 3(3) = 19) and \\(x2 = \\mu = z\\sigma = 10 - 3(3) = 1.997%$$ of the defective cars will fall between one and 19.\n\n### Q 6.3.19\n\nWe flip a coin 100 times ($$n = 100$$) and note that it only comes up heads 20% ($$p = 0.20$$) of the time. The mean and standard deviation for the number of times the coin lands on heads is $$\\mu = 20$$ and $$\\sigma = 4$$ (verify the mean and standard deviation). Solve the following:\n\n1. There is about a 68% chance that the number of heads will be somewhere between ___ and ___.\n2. There is about a ____chance that the number of heads will be somewhere between 12 and 28.\n3. There is about a ____ chance that the number of heads will be somewhere between eight and 32.\n\n### Q 6.3.20\n\nA \\$1 scratch off lotto ticket will be a winner one out of five times. Out of a shipment of $$n = 190$$ lotto tickets, find the probability for the lotto tickets that there are\n\n1. somewhere between 34 and 54 prizes.\n2. somewhere between 54 and 64 prizes.\n3. more than 64 prizes.\n\n### S 6.3.21\n\n• $$n = 190; p = 1515 = 0.2; q = 0.8$$\n• $$\\mu = np = (190)(0.2) = 38$$\n• $$\\sigma = \\sqrt{npq} = \\sqrt{(190)(0.2)(0.8)} = 5.5136$$\n1. For this problem: $$P(34 < x < 54) = \\text{normalcdf}(34,54,48,5.5136) = 0.7641$$\n2. For this problem: $$P(54 < x < 64) = \\text{normalcdf}(54,64,48,5.5136) = 0.0018$$\n3. For this problem: $$P(x > 64) = \\text{normalcdf}(64,10^{99},48,5.5136) = 0.0000012$$ (approximately 0)\n\n### Q 6.3.22\n\nFacebook provides a variety of statistics on its Web site that detail the growth and popularity of the site.\n\nOn average, 28 percent of 18 to 34 year olds check their Facebook profiles before getting out of bed in the morning. Suppose this percentage follows a normal distribution with a standard deviation of five percent.\n\n1. Find the probability that the percent of 18 to 34-year-olds who check Facebook before getting out of bed in the morning is at least 30.\n2. Find the 95th percentile, and express it in a sentence." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9086484,"math_prob":0.9984837,"size":20799,"snap":"2019-43-2019-47","text_gpt3_token_len":5836,"char_repetition_ratio":0.14763165,"word_repetition_ratio":0.19896851,"special_character_ratio":0.33472764,"punctuation_ratio":0.14383866,"nsfw_num_words":1,"has_unicode_error":false,"math_prob_llama3":0.9991586,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-22T01:05:00Z\",\"WARC-Record-ID\":\"<urn:uuid:eceb70ef-2239-4b7a-8494-efb191a9e5d7>\",\"Content-Length\":\"120300\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fdd7cb51-8599-45d2-bc04-7cb81f6f77c3>\",\"WARC-Concurrent-To\":\"<urn:uuid:e3bb328e-fed9-442d-9deb-4469286372c3>\",\"WARC-IP-Address\":\"35.168.122.151\",\"WARC-Target-URI\":\"https://stats.libretexts.org/Courses/Lake_Tahoe_Community_College/LTCC%3A_MATH_201_-_Elements_of_Statistics_and_Probability/Text/06%3A_The_Normal_Distribution/6.6%3A_The_Normal_Distribution_(Exercises)\",\"WARC-Payload-Digest\":\"sha1:IVDHAHH5V36DJHNAYM7TPZERTCPD2FYR\",\"WARC-Block-Digest\":\"sha1:FRG2HS4LWGSHGFWUSBLD5B2Y7MAVPUZI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496671053.31_warc_CC-MAIN-20191121231600-20191122015600-00346.warc.gz\"}"}
https://prepinsta.com/temporary-c-programming/armstrong-number-or-not/
[ "Prime", null, "#### Prepinsta Prime\n\nVideo courses for company/skill based Preparation\n\n(Check all courses)\nGet Prime Video\nPrime", null, "#### Prepinsta Prime\n\nPurchase mock tests for company/skill building\n\n(Check all mocks)\nGet Prime mock\n\n# Armstrong Number Or Not\n\n## Armstrong number or not\n\nArmstrong number is a C program that checks whether an integer or number inserted by the user is an Armstrong number or not. This program uses while loop and if-else statement to evaluate the same. A positive integer is said to be an Armstrong number of order n if abcd… = an + bn + cn + dn + …\n\nIn case the Armstrong number have three digits, then the sum of cubes of each digit will be equal to the number itself. Then ‘sum’ inconstant is used to calculate the sum of the number of ‘sum’ number along with the value of ‘cube’ number. The If-else situation statement is used to test both the value of ‘sum’ variable as well as the value of ‘temp’ (temporary) number are equal. In case of true condition it prints the Armstrong number and if not then it executes the same.\n\n## Algorithm to check if the entered digit is an Armstrong number or not:\n\nStep 1: Start\n\nStep 2: The user is asked to enter a number.\n\nStep 3: Set sum = 0 and duplicate = number.\n\nStep 4: remainder = number%10\n\nStep 5: Sum=sum + (remainder * remainder * remainder)\n\nStep 6: number = number\n\nStep 7: repeat steps 4 to 6 till the number > 0\n\nStep 8: if sum = duplicate\n\nStep 9: The entered number is Armstrong\n\nStep 10: If not, then the inserted number is not Armstrong\n\nStep 11: Stop\n\nRead Also: ASCII Values Of A Character\n\n### Program to check if the entered digit is an Armstrong number or not:\n\n```\n/*\n* C Program to check whether the entered Number is Armstrong\n*/\n#include\n#include\n\nvoid main()\n{\nint num, sum = 0, rem = 0, cube = 0, temp;\n\nprintf(\"Insert a num\");\n\nscanf(\"%d\", &num);\ntemp = num;\nwhile (num != 0)\n{\nrem = num % 10;\ncube = pow(rem, 3);\nsum = sum + cube;\nnum = num / 10;\n}\nif (sum == temp)\n\nprintf(\"The inserted num is Armstrong no\");\nelse\n\nprintf(\"The inserted num is not an Armstrong no\");\n}\n\n```\n\n### Output\n\n```1. Insert a num: 370\nThe inserted num is Armstrong number\n\n2. Insert a num: 1500\nThe inserted num is not an Armstrong number\n```" ]
[ null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null, "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.68916804,"math_prob":0.9912648,"size":2225,"snap":"2021-43-2021-49","text_gpt3_token_len":594,"char_repetition_ratio":0.17919856,"word_repetition_ratio":0.04964539,"special_character_ratio":0.27325842,"punctuation_ratio":0.10344828,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99176687,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-27T16:38:52Z\",\"WARC-Record-ID\":\"<urn:uuid:b6d3f4d7-00a0-4bd9-926a-91acb9a2b177>\",\"Content-Length\":\"123040\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:04111438-08f3-4a1f-a8c6-31f3ab04b12b>\",\"WARC-Concurrent-To\":\"<urn:uuid:79bef784-65fb-462f-8d72-6dff12e36bc9>\",\"WARC-IP-Address\":\"172.66.41.24\",\"WARC-Target-URI\":\"https://prepinsta.com/temporary-c-programming/armstrong-number-or-not/\",\"WARC-Payload-Digest\":\"sha1:IHENIDW2FTJ3GVZRYSMXXFOKPTXO5E4E\",\"WARC-Block-Digest\":\"sha1:P53XMZCVGYHELK3C32YUJMQQV2YZM32P\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323588216.48_warc_CC-MAIN-20211027150823-20211027180823-00102.warc.gz\"}"}
https://www.syntaxbomb.com/index.php/topic,3157.0.html
[ "November 28, 2020, 02:16:21 PM\n\n###", null, "Author Topic: [bmx] Twin Primes by daaan [ 1+ years ago ]  (Read 859 times)\n\n####", null, "BlitzBot\n\n• Jr. Member\n•", null, "", null, "• Posts: 1", null, "##### [bmx] Twin Primes by daaan [ 1+ years ago ]\n« on: June 29, 2017, 12:28:43 AM »\nTitle : Twin Primes\nAuthor : daaan\nPosted : 1+ years ago\n\nDescription : I had a assembly programming assignment that was to print out the first 100 twin primes. So I made this mock up program to figure how a easy method for calculating twin primes. It does in fact work, but now I need to translate it into assembly", null, "Code :\nCode: BlitzMax\n1. Rem\n2. **********************************************************\n3. twin primes by daniel wooden\n4. **********************************************************\n5. End Rem\n6.\n7. Local count:Int = 1\n8. Local curnum:Int = 3\n9.\n10. Local a:Int = 0\n11. Local b:Int = 0\n12.\n13. While count < 101 ' <-- twin primes upto the 100th place.\n14.\n15.         If IsPrime( curnum ) And IsPrime( curnum+2 ) Then\n16.                 a = curnum\n17.                 b = curnum+2\n18.                 Print \"Twin Prime Set: \" + count + \" (\" + a + \",\" + b + \")\"\n19.                 count :+ 1\n20.         End If\n21.\n22.         curnum :+ 1\n23.\n24. Wend\n25. End\n26.\n27. Function IsPrime:Int( Num:Int )\n28.\n29.         Local Prime:Int = True\n30.\n31.         For i = 2 To Num/2\n32.                 If (Num Mod i) = 0 Then\n33.                         Prime = False\n34.                 End If\n35.         Next\n36.\n37.         Return Prime\n38.\n39. End Function\n\nrdodson41(Posted 1+ years ago)\n\nYour calculating the even numbers too, try curnum :+ 2, should go twice as fast.\n\nAzathoth(Posted 1+ years ago)\n\nTo make IsPrime faster you should use 'Exit' after 'Prime = False' because you're still in the 'For-Next' loop when using large numbers.\n\n`;**********************************************************;twin primes by daniel wooden;converted by shadowturtle;**********************************************************Local count = 1Local curnum = 3Local a = 0Local b = 0While count < 101 If IsPrime( curnum ) And IsPrime( curnum+2 ) Then a = curnum b = curnum+2 Print \"Twin Prime Set: \" + count + \" (\" + a + \",\" + b + \")\" count = count + 1 End If curnum = curnum + 1 WendWaitKeyEndFunction IsPrime( Num ) Local Prime = True For i = 2 To Num/2 If (Num Mod i) = 0 Then Prime = False End If Next Return Prime End Function`" ]
[ null, "https://www.syntaxbomb.com/Themes/OrangeLine/images/topic/normal_post.gif", null, "https://www.syntaxbomb.com/Themes/OrangeLine/images/useroff.gif", null, "https://www.syntaxbomb.com/Themes/OrangeLine/images/star.gif", null, "https://www.syntaxbomb.com/Themes/OrangeLine/images/star.gif", null, "https://www.syntaxbomb.com/Themes/OrangeLine/images/post/xx.gif", null, "https://www.syntaxbomb.com/Smileys/SMF-EmojiOne/sad.gif", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.58956903,"math_prob":0.89596766,"size":686,"snap":"2020-45-2020-50","text_gpt3_token_len":188,"char_repetition_ratio":0.29032257,"word_repetition_ratio":0.0,"special_character_ratio":0.4489796,"punctuation_ratio":0.086538464,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96272826,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-11-28T14:16:21Z\",\"WARC-Record-ID\":\"<urn:uuid:b54d4654-c03a-4e11-938c-8fd215f71fd3>\",\"Content-Length\":\"39232\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:88e623a5-5aad-43ce-b1ed-f65622affa45>\",\"WARC-Concurrent-To\":\"<urn:uuid:773545a5-f903-49f3-a9f4-515520dba465>\",\"WARC-IP-Address\":\"109.203.102.108\",\"WARC-Target-URI\":\"https://www.syntaxbomb.com/index.php/topic,3157.0.html\",\"WARC-Payload-Digest\":\"sha1:PZOSMUCHQC7ATAA6NX3YHNGA6JQNTAGE\",\"WARC-Block-Digest\":\"sha1:SPS4OU46FIWJGEE4IWDMI6XCOJP5MFBW\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141195656.78_warc_CC-MAIN-20201128125557-20201128155557-00199.warc.gz\"}"}
https://math.stackexchange.com/questions/2758463/what-is-the-use-of-null-space/2759265
[ "What is the use of Null Space?\n\nThis answer explains what is null space very effectively. In brief Null Space is the set of vectors which have 0 effect on the system when applied. So, what is the use of finding null-space? Is it just that it gives us what not to use and whether the matrix is invertible or not or is there a better use for null space? May be something like, \"we know adding null-space-vectors won't change the system but improves the stability of the system?\" (I'm just guessing)\n\nAny practical examples (like the ones given in the answer referred) are greatly appreciated. Theoretical ones will also be helpful.\nThanks\n\n• The existence of an 'identity element' is typically a crucial axiom for many mathematical structures (in the context of matrices, the zero matrix is the additive identity) . Without an identity element, you could not have a well defined group, or vector space, and so on. The existence of an identity element is also useful in proofs. – Bill Wallis Apr 29 '18 at 8:45\n\nDear fellow mathematician,\n\nat first, it might appear that it is not really as useful. But the opposite is true, you are going to use it to find eigenvectors which are of huge importance in linear algebra. They are used for diagonalising matrices and for Singular Value Decomposition which is of vital importance. (it’s a numerically stable way of taking powers of matrices - solving differential equations and many other things - i.e. finding n-th term of a sequence from a reccurent formula, which can be used for various)\n\nThese are the applications that I’m familiar with, I’m sure that someone will provide more.\n\nHave a nice Sunday!\n\nAs Bill Wallis said, the existence of a zero is important, which is provided by the vectors in the null space. In all practical applications, it is very important that the solutions don't have a component in the null space, which has no effect on the system. Having a component in the null space only wastes resources, which we don't want to do. This is also evident from the answer quoted.\nExample 1: Fuel is wasted if thrusters are fired in the null space.\nExample 2: Investment leads to no gain of profit and hence wasted in the null space.\nExample 3: Power applied in the null space does not illuminate the room further, and hence power is wasted.\n\nDue to this nulling effect, it is also used in simplification techniques, like the ones mentioned by innerz09. I am sure that there are other reasons as well.\n\nCheers!!!\n\n• So, by knowing what is there in null space, we get to know what not to use. That's it right? Is there no practical use of null-space vectors? – Nagabhushan S N Apr 30 '18 at 8:19\n• Simplification is one such use. There may be other uses as well. – Aaditya Ravindran Apr 30 '18 at 8:53" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9411206,"math_prob":0.87797505,"size":603,"snap":"2019-43-2019-47","text_gpt3_token_len":129,"char_repetition_ratio":0.118530884,"word_repetition_ratio":0.0,"special_character_ratio":0.20895523,"punctuation_ratio":0.076271184,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9691683,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-18T15:48:24Z\",\"WARC-Record-ID\":\"<urn:uuid:739b8536-6b55-4826-acb2-c1111ecb7503>\",\"Content-Length\":\"145990\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:16a555e7-5c97-4eaf-9578-4dee70b736ea>\",\"WARC-Concurrent-To\":\"<urn:uuid:edf7d4e8-dca4-47dd-ab62-8bd94e755e51>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://math.stackexchange.com/questions/2758463/what-is-the-use-of-null-space/2759265\",\"WARC-Payload-Digest\":\"sha1:7CKZDYENM7WGHY434NNH6NI3PMWOOZXQ\",\"WARC-Block-Digest\":\"sha1:TSKAOIXFRRJIRF2Y4QMNHXLF52C4QIQ6\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986684226.55_warc_CC-MAIN-20191018154409-20191018181909-00308.warc.gz\"}"}
https://alakazam.readthedocs.io/en/stable/topics/plotDiversityCurve/
[ "plotDiversityCurve - Plot the results of alphaDiversity\n\nDescription¶\n\nplotDiversityCurve plots a DiversityCurve object.\n\nUsage¶\n\nplotDiversityCurve(data, colors = NULL, main_title = \"Diversity\",\nlegend_title = \"Group\", log_x = FALSE, log_y = FALSE,\nxlim = NULL, ylim = NULL, annotate = c(\"none\", \"depth\"),\nscore = c(\"diversity\", \"evenness\"), silent = FALSE, ...)\n\nArguments¶\n\ndata\nDiversityCurve object returned by alphaDiversity.\ncolors\nnamed character vector whose names are values in the group column of the data slot of data, and whose values are colors to assign to those group names.\nmain_title\nstring specifying the plot title.\nlegend_title\nstring specifying the legend title.\nlog_x\nif TRUE then plot q on a log scale; if FALSE plot on a linear scale.\nlog_y\nif TRUE then plot the diversity/evenness scores on a log scale; if FALSE plot on a linear scale.\nxlim\nnumeric vector of two values specifying the c(lower, upper) x-axis limits.\nylim\nnumeric vector of two values specifying the c(lower, upper) y-axis limits.\nannotate\nstring defining whether to added values to the group labels of the legend. When \"none\" (default) is specified no annotations are added. Specifying (\"depth\") adds sequence counts to the labels.\nscore\none of \"diversity\" or \"evenness\" specifying which score to plot on the y-asis.\nsilent\nif TRUE do not draw the plot and just return the ggplot2 object; if FALSE draw the plot.\nadditional arguments to pass to ggplot2::theme.\n\nValue¶\n\nA ggplot object defining the plot.\n\nExamples¶\n\n# Calculate diversity\ndiv <- alphaDiversity(ExampleDb, group=\"SAMPLE\", nboot=100)\n\n 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8\n 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0\n\n# Plot diversity\nplotDiversityCurve(div, legend_title=\"Sample\")", null, "#' # Plot diversity\nplotDiversityCurve(div, legend_title=\"Sample\", score=\"evenness\")", null, "" ]
[ null, "https://alakazam.readthedocs.io/en/stable/topics/plotDiversityCurve-4.png", null, "https://alakazam.readthedocs.io/en/stable/topics/plotDiversityCurve-6.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5125899,"math_prob":0.9424496,"size":2079,"snap":"2019-43-2019-47","text_gpt3_token_len":660,"char_repetition_ratio":0.14072289,"word_repetition_ratio":0.079027355,"special_character_ratio":0.3001443,"punctuation_ratio":0.20045558,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95841223,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,2,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-14T18:14:15Z\",\"WARC-Record-ID\":\"<urn:uuid:e600aa44-7fa6-4b46-86f1-027782a55748>\",\"Content-Length\":\"23079\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9018a627-66ba-48da-9eaf-64cfb283fadc>\",\"WARC-Concurrent-To\":\"<urn:uuid:e02825d0-0a49-41eb-a26c-70d8758c8b4b>\",\"WARC-IP-Address\":\"104.208.221.96\",\"WARC-Target-URI\":\"https://alakazam.readthedocs.io/en/stable/topics/plotDiversityCurve/\",\"WARC-Payload-Digest\":\"sha1:ZGR32WHTRTB4HAVP5VKFOTQCOHWMRCSV\",\"WARC-Block-Digest\":\"sha1:AIVFCMIRJNXOA6SUGSFDZ3WHVKZG5Y52\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986654086.1_warc_CC-MAIN-20191014173924-20191014201424-00504.warc.gz\"}"}
https://email.esm.psu.edu/pipermail/macosx-tex/2012-May/049125.html
[ "# [OS X TeX] AMS-LaTeX question\n\nGary Gray glgray at me.com\nMon May 28 13:09:09 EDT 2012\n\nHi All,\n\nIn the attached PDF file, I have added an \\underbrace command in the second line to call out the argument of the square root in the first line. I would like the square root in the second line to be the same size as that in the first, but LaTeX automatically sizes it to include the underbrace. Is there a way to force the square root in the second line to be the same size as that in the first? Here is the relevant source:\n\n\\begin{align*}\n&= \\frac{A} { \\left( k - m \\omega_{0}^{2} \\right)^{2} + c^{2} \\omega_{0}^{2} } \\sqrt{ \\left[ \\left( k - m \\omega_{0}^{2} \\right) \\left( m \\omega_{0}^{2} + k - m \\omega_{0}^{2} \\right) + c^{2} \\omega_{0}^{2} \\right]^{2} + \\left( m c \\omega_{0}^{3} \\right)^{2} }\n\\\\\n&= \\frac{A} { \\left( k - m \\omega_{0}^{2} \\right)^{2} + c^{2} \\omega_{0}^{2} } \\sqrt{ \\underbrace{ \\left[ k \\left( k - m \\omega_{0}^{2} \\right) + c^{2} \\omega_{0}^{2} \\right]^{2} + \\left( m c \\omega_{0}^{3} \\right)^{2} }_{Q} }.\n\\end{align*}\n\nThank you.\n\nGary\n\n-------------- next part --------------\nA non-text attachment was scrubbed...\nName: PastedGraphic-2.pdf\nType: application/pdf\nSize: 122970 bytes\nDesc: not available\nURL: <http://email.esm.psu.edu/pipermail/macosx-tex/attachments/20120528/01b78095/attachment.pdf>" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7134783,"math_prob":0.9956956,"size":1367,"snap":"2020-24-2020-29","text_gpt3_token_len":483,"char_repetition_ratio":0.21863537,"word_repetition_ratio":0.33971292,"special_character_ratio":0.40307242,"punctuation_ratio":0.0942029,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99823684,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-12T17:38:44Z\",\"WARC-Record-ID\":\"<urn:uuid:b190b342-388f-450d-93a1-d5a9f194276a>\",\"Content-Length\":\"4067\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bcea99d2-1a2c-415d-bba6-23ad048a292b>\",\"WARC-Concurrent-To\":\"<urn:uuid:309bded5-f271-42db-a94e-2afd602e97bf>\",\"WARC-IP-Address\":\"130.203.250.147\",\"WARC-Target-URI\":\"https://email.esm.psu.edu/pipermail/macosx-tex/2012-May/049125.html\",\"WARC-Payload-Digest\":\"sha1:WMINSZU7O5JS6JFHPPC4YPMQIO25EFD5\",\"WARC-Block-Digest\":\"sha1:LOL4ZOPUCPPT36SCUR5IHPDVJIPD5O4W\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593657138752.92_warc_CC-MAIN-20200712144738-20200712174738-00408.warc.gz\"}"}
https://au.mathworks.com/matlabcentral/cody/problems/233-reverse-the-vector/solutions/1882938
[ "Cody\n\n# Problem 233. Reverse the vector\n\nSolution 1882938\n\nSubmitted on 24 Jul 2019 by Rashmi Doijode\nThis solution is locked. To view this solution, you need to provide a solution of the same size or smaller.\n\n### Test Suite\n\nTest Status Code Input and Output\n1   Pass\nx = 1; y_correct = 1; assert(isequal(reverseVector(x),y_correct))\n\n2   Pass\nx = -10:1; y_correct = 1:-1:-10; assert(isequal(reverseVector(x),y_correct))\n\n3   Pass\nx = 'able was i ere i saw elba'; y_correct = 'able was i ere i saw elba'; assert(isequal(reverseVector(x),y_correct))" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.67253214,"math_prob":0.96193814,"size":564,"snap":"2019-35-2019-39","text_gpt3_token_len":170,"char_repetition_ratio":0.14464286,"word_repetition_ratio":0.093023255,"special_character_ratio":0.32446808,"punctuation_ratio":0.14285715,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9822271,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-20T17:26:17Z\",\"WARC-Record-ID\":\"<urn:uuid:7f660340-8732-47f9-929e-4b8d48725521>\",\"Content-Length\":\"71268\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5f351177-e174-4725-b1fe-081d6aa079d7>\",\"WARC-Concurrent-To\":\"<urn:uuid:0072f9c9-8c0e-4ac3-b9d5-818e7b7aab3b>\",\"WARC-IP-Address\":\"23.2.40.141\",\"WARC-Target-URI\":\"https://au.mathworks.com/matlabcentral/cody/problems/233-reverse-the-vector/solutions/1882938\",\"WARC-Payload-Digest\":\"sha1:BKSSBP6NSTS7RVBRVOMYDO7XHIFKVYIV\",\"WARC-Block-Digest\":\"sha1:I7LT4WOOSJS3BTW6AUWUW7ZEBY66FL4A\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514574050.69_warc_CC-MAIN-20190920155311-20190920181311-00334.warc.gz\"}"}
https://www.popflock.com/learn?s=Stokes'_theorem
[ "", null, "Stokes' Theorem\nGet Stokes' Theorem essential facts below. View Videos or join the Stokes' Theorem discussion. Add Stokes' Theorem to your PopFlock.com topic list for future reference or share this resource on social media.\nStokes' Theorem\n\nStokes' theorem, also known as Kelvin-Stokes theorem after Lord Kelvin and George Stokes, the fundamental theorem for curls or simply the curl theorem, is a theorem in vector calculus on $\\mathbb {R} ^{3}$", null, ". Given a vector field, the theorem relates the integral of the curl of the vector field over some surface, to the line integral of the vector field around the boundary of the surface. The classical Stokes' theorem can be stated in one sentence: The line integral of a vector field over a loop is equal to the flux of its curl through the enclosed surface.\n\nStokes' theorem is a special case of the generalized Stokes' theorem. In particular, a vector field on $\\mathbb {R} ^{3}$", null, "can be considered as a 1-form in which case its curl is its exterior derivative, a 2-form.\n\n## Theorem\n\nLet $\\Sigma$", null, "be a smooth oriented surface in R3 with boundary $\\partial \\Sigma$", null, ". If a vector field $\\mathbf {A} =(P(x,y,z),Q(x,y,z),R(x,y,z))$", null, "is defined and has continuous first order partial derivatives in a region containing $\\Sigma$", null, ", then\n\n$\\iint _{\\Sigma }(\\nabla \\times \\mathbf {A} )\\cdot \\mathrm {d} \\mathbf {a} =\\oint _{\\partial \\Sigma }\\mathbf {A} \\cdot \\mathrm {d} \\mathbf {l} .$", null, "More explicitly, the equality says that\n\n{\\begin{aligned}&\\iint _{\\Sigma }\\left(\\left({\\frac {\\partial R}{\\partial y}}-{\\frac {\\partial Q}{\\partial z}}\\right)\\,\\mathrm {d} y\\,\\mathrm {d} z+\\left({\\frac {\\partial P}{\\partial z}}-{\\frac {\\partial R}{\\partial x}}\\right)\\,\\mathrm {d} z\\,\\mathrm {d} x+\\left({\\frac {\\partial Q}{\\partial x}}-{\\frac {\\partial P}{\\partial y}}\\right)\\,\\mathrm {d} x\\,\\mathrm {d} y\\right)\\\\&=\\oint _{\\partial \\Sigma }{\\Bigl (}P\\,\\mathrm {d} x+Q\\,\\mathrm {d} y+R\\,\\mathrm {d} z{\\Bigr )}.\\end{aligned}}", null, "The main challenge in a precise statement of Stokes' theorem is in defining the notion of a boundary. Surfaces such as the Koch snowflake, for example, are well-known not to exhibit a Riemann-integrable boundary, and the notion of surface measure in Lebesgue theory cannot be defined for a non-Lipschitz surface. One (advanced) technique is to pass to a weak formulation and then apply the machinery of geometric measure theory; for that approach see the coarea formula. In this article, we instead use a more elementary definition, based on the fact that a boundary can be discerned for full-dimensional subsets of R2.\n\nLet ?: [a, b] -> R2 be a piecewise smooth Jordan plane curve. The Jordan curve theorem implies that ? divides R2 into two components, a compact one and another that is non-compact. Let D denote the compact part; then D is bounded by ?. It now suffices to transfer this notion of boundary along a continuous map to our surface in R3. But we already have such a map: the parametrization of ?.\n\nSuppose ?: D -> R3 is smooth, with ? = ?(D). If ? is the space curve defined by ?(t) = ?(?(t)),[note 1] then we call ? the boundary of ?, written .\n\nWith the above notation, if F is any smooth vector field on R3, then\n\n$\\oint _{\\partial \\Sigma }\\mathbf {F} \\,\\cdot \\,\\mathrm {d} {\\mathbf {\\Gamma } }=\\iint _{\\Sigma }\\nabla \\times \\mathbf {F} \\,\\cdot \\,\\mathrm {d} \\mathbf {S} .$", null, "## Proof\n\nThe proof of the theorem consists of 4 steps. We assume Green's theorem, so what is of concern is how to boil down the three-dimensional complicated problem (Stokes' theorem) to a two-dimensional rudimentary problem (Green's theorem). When proving this theorem, mathematicians normally deduce it as a special case of a more general result, which is stated in terms of differential forms, and proved using more sophisticated machinery. While powerful, these techniques require substantial background, so the proof below avoids them, and does not presuppose any knowledge beyond a familiarity with basic vector calculus. At the end of this section, a short alternate proof of Stokes' theorem is given, as a corollary of the generalized Stokes' Theorem.\n\n### Elementary proof\n\n#### First step of the proof (parametrization of integral)\n\nAs in § Theorem, we reduce the dimension by using the natural parametrization of the surface. Let ? and ? be as in that section, and note that by change of variables\n\n$\\oint _{\\partial \\Sigma }{\\mathbf {F} (\\mathbf {x} )\\cdot \\,\\mathrm {d} \\mathbf {l} }=\\oint _{\\gamma }{\\mathbf {F} ({\\boldsymbol {\\psi }}(\\mathbf {y} ))\\cdot \\,\\mathrm {d} {\\boldsymbol {\\psi }}(\\mathbf {y} )}=\\oint _{\\gamma }{\\mathbf {F} ({\\boldsymbol {\\psi }}(\\mathbf {y} ))J_{\\mathbf {y} }({\\boldsymbol {\\psi }})\\,\\mathrm {d} \\mathbf {y} }$", null, "where J? stands for the Jacobian matrix of ?.\n\nNow let {eu, ev} be an orthonormal basis in the coordinate directions of R2. Recognizing that the columns of Jy? are precisely the partial derivatives of ? at y, we can expand the previous equation in coordinates as\n\n{\\begin{aligned}\\oint _{\\partial \\Sigma }{\\mathbf {F} (\\mathbf {x} )\\cdot \\,\\mathrm {d} \\mathbf {l} }&=\\oint _{\\gamma }{\\mathbf {F} ({\\boldsymbol {\\psi }}(\\mathbf {y} ))J_{\\mathbf {y} }({\\boldsymbol {\\psi }})\\mathbf {e} _{u}(\\mathbf {e} _{u}\\cdot \\,\\mathrm {d} \\mathbf {y} )+\\mathbf {F} ({\\boldsymbol {\\psi }}(\\mathbf {y} ))J_{\\mathbf {y} }({\\boldsymbol {\\psi }})\\mathbf {e} _{v}(\\mathbf {e} _{v}\\cdot \\,\\mathrm {d} \\mathbf {y} )}\\\\&=\\oint _{\\gamma }{\\left(\\left(\\mathbf {F} ({\\boldsymbol {\\psi }}(\\mathbf {y} ))\\cdot {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}(\\mathbf {y} )\\right)\\mathbf {e} _{u}+\\left(\\mathbf {F} ({\\boldsymbol {\\psi }}(\\mathbf {y} ))\\cdot {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}(\\mathbf {y} )\\right)\\mathbf {e} _{v}\\right)\\cdot \\,\\mathrm {d} \\mathbf {y} }\\end{aligned}}", null, "#### Second step in the proof (defining the pullback)\n\nThe previous step suggests we define the function\n\n$\\mathbf {P} (u,v)=\\left(\\mathbf {F} ({\\boldsymbol {\\psi }}(u,v))\\cdot {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}(u,v)\\right)\\mathbf {e} _{u}+\\left(\\mathbf {F} ({\\boldsymbol {\\psi }}(u,v))\\cdot {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}\\right)\\mathbf {e} _{v}$", null, "This is the pullback of F along ?, and, by the above, it satisfies\n\n$\\oint _{\\partial \\Sigma }{\\mathbf {F} (\\mathbf {x} )\\cdot \\,\\mathrm {d} \\mathbf {l} }=\\oint _{\\gamma }{\\mathbf {P} (\\mathbf {y} )\\cdot \\,\\mathrm {d} \\mathbf {l} }$", null, "We have successfully reduced one side of Stokes' theorem to a 2-dimensional formula; we now turn to the other side.\n\n#### Third step of the proof (second equation)\n\nFirst, calculate the partial derivatives appearing in Green's theorem, via the product rule:\n\n{\\begin{aligned}{\\frac {\\partial P_{1}}{\\partial v}}&={\\frac {\\partial (\\mathbf {F} \\circ {\\boldsymbol {\\psi }})}{\\partial v}}\\cdot {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}+(\\mathbf {F} \\circ {\\boldsymbol {\\psi }})\\cdot {\\frac {\\partial ^{2}{\\boldsymbol {\\psi }}}{\\partial v\\,\\partial u}}\\\\[5pt]{\\frac {\\partial P_{2}}{\\partial u}}&={\\frac {\\partial (\\mathbf {F} \\circ {\\boldsymbol {\\psi }})}{\\partial u}}\\cdot {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}+(\\mathbf {F} \\circ {\\boldsymbol {\\psi }})\\cdot {\\frac {\\partial ^{2}{\\boldsymbol {\\psi }}}{\\partial u\\,\\partial v}}\\end{aligned}}", null, "Conveniently, the second term vanishes in the difference, by equality of mixed partials. So,\n\n{\\begin{aligned}{\\frac {\\partial P_{1}}{\\partial v}}-{\\frac {\\partial P_{2}}{\\partial u}}&={\\frac {\\partial (\\mathbf {F} \\circ {\\boldsymbol {\\psi }})}{\\partial v}}\\cdot {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}-{\\frac {\\partial (\\mathbf {F} \\circ {\\boldsymbol {\\psi }})}{\\partial u}}\\cdot {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}\\\\[5pt]&={\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}(J_{{\\boldsymbol {\\psi }}(u,v)}\\mathbf {F} ){\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}-{\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}(J_{{\\boldsymbol {\\psi }}(u,v)}\\mathbf {F} ){\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}&&{\\text{(chain rule)}}\\\\[5pt]&={\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}\\left(J_{{\\boldsymbol {\\psi }}(u,v)}\\mathbf {F} -{(J_{{\\boldsymbol {\\psi }}(u,v)}\\mathbf {F} )}^{\\mathsf {T}}\\right){\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}\\end{aligned}}", null, "But now consider the matrix in that quadratic form--that is, $J_{{\\boldsymbol {\\psi }}(u,v)}\\mathbf {F} -(J_{{\\boldsymbol {\\psi }}(u,v)}\\mathbf {F} )^{\\mathsf {T}}$", null, ". We claim this matrix in fact describes a cross product.\n\nTo be precise, let $A=(A_{ij})_{ij}$", null, "be an arbitrary 3 × 3 matrix and let\n\n$\\mathbf {a} ={\\begin{bmatrix}A_{32}-A_{23}\\\\A_{13}-A_{31}\\\\A_{21}-A_{12}\\end{bmatrix}}$", null, "Note that x ? a × x is linear, so it is determined by its action on basis elements. But by direct calculation\n\n{\\begin{aligned}\\left(A-A^{\\mathsf {T}}\\right)\\mathbf {e} _{1}&={\\begin{bmatrix}0\\\\a_{3}\\\\-a_{2}\\end{bmatrix}}=\\mathbf {a} \\times \\mathbf {e} _{1}\\\\\\left(A-A^{\\mathsf {T}}\\right)\\mathbf {e} _{2}&={\\begin{bmatrix}-a_{3}\\\\0\\\\a_{1}\\end{bmatrix}}=\\mathbf {a} \\times \\mathbf {e} _{2}\\\\\\left(A-A^{\\mathsf {T}}\\right)\\mathbf {e} _{3}&={\\begin{bmatrix}a_{2}\\\\-a_{1}\\\\0\\end{bmatrix}}=\\mathbf {a} \\times \\mathbf {e} _{3}\\end{aligned}}", null, "Thus (A - AT)x = a × x for any x. Substituting J F for A, we obtain\n\n$\\left({(J_{{\\boldsymbol {\\psi }}(u,v)}\\mathbf {F} )}_{\\psi (u,v)}-{(J_{{\\boldsymbol {\\psi }}(u,v)}\\mathbf {F} )}^{\\mathsf {T}}\\right)\\mathbf {x} =(\\nabla \\times \\mathbf {F} )\\times \\mathbf {x} ,\\quad {\\text{for all}}\\,\\mathbf {x} \\in \\mathbb {R} ^{3}$", null, "We can now recognize the difference of partials as a (scalar) triple product:\n\n{\\begin{aligned}{\\frac {\\partial P_{1}}{\\partial v}}-{\\frac {\\partial P_{2}}{\\partial u}}&={\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}\\cdot (\\nabla \\times \\mathbf {F} )\\times {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}\\\\&=\\det {\\begin{bmatrix}(\\nabla \\times \\mathbf {F} )({\\boldsymbol {\\psi }}(u,v))&{\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}(u,v)&{\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}(u,v)\\end{bmatrix}}\\end{aligned}}", null, "On the other hand, the definition of a surface integral also includes a triple product--the very same one!\n\n{\\begin{aligned}\\iint _{S}(\\nabla \\times \\mathbf {F} )\\cdot \\,d^{2}\\mathbf {S} &=\\iint _{D}{(\\nabla \\times \\mathbf {F} )({\\boldsymbol {\\psi }}(u,v))\\cdot \\left({\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}(u,v)\\times {\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}(u,v)\\,\\mathrm {d} u\\,\\mathrm {d} v\\right)}\\\\&=\\iint _{D}\\det {\\begin{bmatrix}(\\nabla \\times \\mathbf {F} )({\\boldsymbol {\\psi }}(u,v))&{\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial u}}(u,v)&{\\frac {\\partial {\\boldsymbol {\\psi }}}{\\partial v}}(u,v)\\end{bmatrix}}\\,\\mathrm {d} u\\,\\mathrm {d} v\\end{aligned}}", null, "So, we obtain\n\n$\\iint _{S}(\\nabla \\times \\mathbf {F} )\\cdot \\,\\mathrm {d} ^{2}\\mathbf {S} =\\iint _{D}\\left({\\frac {\\partial P_{2}}{\\partial u}}-{\\frac {\\partial P_{1}}{\\partial v}}\\right)\\,\\mathrm {d} u\\,\\mathrm {d} v$", null, "#### Fourth step of the proof (reduction to Green's theorem)\n\nCombining the second and third steps, and then applying Green's theorem completes the proof.\n\n### Proof via differential forms\n\nR -> R3 can be identified with the differential 1-forms on R3 via the map\n\n$F_{1}\\mathbf {e} _{1}+F_{2}\\mathbf {e} _{2}+F_{3}\\mathbf {e} _{3}\\mapsto F_{1}\\,\\mathrm {d} x+F_{2}\\,\\mathrm {d} y+F_{3}\\mathrm {d} z$", null, ".\n\nWrite the differential 1-form associated to a function F as ?F. Then one can calculate that\n\n$\\star \\omega _{\\nabla \\times \\mathbf {F} }=\\mathrm {d} \\omega _{\\mathbf {F} }$", null, "where ? is the Hodge star and $\\mathrm {d}$", null, "is the exterior derivative. Thus, by generalized Stokes' theorem,\n\n$\\oint _{\\partial \\Sigma }{\\mathbf {F} \\cdot \\,\\mathrm {d} \\mathbf {l} }=\\oint _{\\partial \\Sigma }{\\omega _{\\mathbf {F} }}=\\int _{\\Sigma }{\\mathrm {d} \\omega _{\\mathbf {F} }}=\\int _{\\Sigma }{\\star \\omega _{\\nabla \\times \\mathbf {F} }}=\\iint _{\\Sigma }{\\nabla \\times \\mathbf {F} \\cdot \\,\\mathrm {d} ^{2}\\mathbf {S} }$", null, "## Applications\n\n### In fluid dynamics\n\nIn this section, we will discuss the lamellar vector field based on Stokes' theorem.\n\n### Irrotational fields\n\nDefinition 2-1 (irrotational field). A smooth vector field F on an open U ? R3 is irrotational if ? × F = 0.\n\nIf the domain of F is simply connected, then F is a conservative vector field.\n\n#### Helmholtz's theorems\n\nIn this section, we will introduce a theorem that is derived from Stokes' theorem and characterizes vortex-free vector fields. In fluid dynamics it is called Helmholtz's theorems.\n\nTheorem 2-1 (Helmholtz's theorem in fluid dynamics). Let U ? R3 be an open subset with a lamellar vector field F and let c0, c1: [0, 1] -> U be piecewise smooth loops. If there is a function H: [0, 1] × [0, 1] -> U such that\n\n• [TLH0] H is piecewise smooth,\n• [TLH1] H(t, 0) = c0(t) for all t ? [0, 1],\n• [TLH2] H(t, 1) = c1(t) for all t ? [0, 1],\n• [TLH3] H(0, s) = H(1, s) for all s ? [0, 1].\n\nThen,\n\n$\\int _{c_{0}}\\mathbf {F} \\,\\mathrm {d} c_{0}=\\int _{c_{1}}\\mathbf {F} \\,\\mathrm {d} c_{1}$", null, "Some textbooks such as Lawrence call the relationship between c0 and c1 stated in theorem 2-1 as \"homotopic\" and the function H: [0, 1] × [0, 1] -> U as \"homotopy between c0 and c1\". However, \"homotopic\" or \"homotopy\" in above-mentioned sense are different (stronger than) typical definitions of \"homotopic\" or \"homotopy\"; the latter omit condition [TLH3]. So from now on we refer to homotopy (homotope) in the sense of theorem 2-1 as a tubular homotopy (resp. tubular-homotopic).[note 2]\n\n##### Proof of the theorem\n\nIn what follows, we abuse notation and use \"+\" for concatenation of paths in the fundamental groupoid and \"-\" for reversing the orientation of a path.\n\nLet D = [0, 1] × [0, 1], and split ?D into four line segments ?j.\n\n{\\begin{aligned}\\gamma _{1}:[0,1]\\to D;\\quad &\\gamma _{1}(t)=(t,0)\\\\\\gamma _{2}:[0,1]\\to D;\\quad &\\gamma _{2}(s)=(1,s)\\\\\\gamma _{3}:[0,1]\\to D;\\quad &\\gamma _{3}(t)=(1-t,1)\\\\\\gamma _{4}:[0,1]\\to D;\\quad &\\gamma _{4}(s)=(0,1-s)\\end{aligned}}", null, "so that\n\n$\\partial D=\\gamma _{1}+\\gamma _{2}+\\gamma _{3}+\\gamma _{4}$", null, "By our assumption that c1 and c2 are piecewise smooth homotopic, there is a piecewise smooth homotopy H: D -> M\n\n{\\begin{aligned}\\Gamma _{i}(t)&=H(\\gamma _{i}(t))&&i=1,2,3,4\\\\\\Gamma (t)&=H(\\gamma (t))=(\\Gamma _{1}\\oplus \\Gamma _{2}\\oplus \\Gamma _{3}\\oplus \\Gamma _{4})(t)\\end{aligned}}", null, "Let S be the image of D under H. That\n\n$\\iint _{S}\\nabla \\times \\mathbf {F} \\,\\mathrm {d} S=\\oint _{\\Gamma }\\mathbf {F} \\,\\mathrm {d} \\Gamma$", null, "follows immediately from Stokes' theorem. F is lamellar, so the left side vanishes, i.e.\n\n$0=\\oint _{\\Gamma }\\mathbf {F} \\,\\mathrm {d} \\Gamma =\\sum _{i=1}^{4}\\oint _{\\Gamma _{i}}\\mathbf {F} \\,\\mathrm {d} \\Gamma$", null, "As H is tubular, ?2 = -?4. Thus the line integrals along ?2(s) and ?4(s) cancel, leaving\n\n$0=\\oint _{\\Gamma _{1}}\\mathbf {F} \\,\\mathrm {d} \\Gamma +\\oint _{\\Gamma _{3}}\\mathbf {F} \\,\\mathrm {d} \\Gamma$", null, "On the other hand, c1 = ?1 and c3 = -?3, so that the desired equality follows almost immediately.\n\n### Conservative forces\n\nHelmholtz's theorem gives an explanation as to why the work done by a conservative force in changing an object's position is path independent. First, we introduce the Lemma 2-2, which is a corollary of and a special case of Helmholtz's theorem.\n\nLemma 2-2. Let U ? R3 be an open subset, with a Lamellar vector field F and a piecewise smooth loop c0: [0, 1] -> U. Fix a point p ? U, if there is a homotopy (tube-like-homotopy) H: [0, 1] × [0, 1] -> U such that\n\n• [SC0] H is piecewise smooth,\n• [SC1] H(t, 0) = c0(t) for all t ? [0, 1],\n• [SC2] H(t, 1) = p for all t ? [0, 1],\n• [SC3] H(0, s) = H(1, s) = p for all s ? [0, 1].\n\nThen,\n\n$\\int _{c_{0}}\\mathbf {F} \\,\\mathrm {d} c_{0}=0$", null, "Lemma 2-2 follows from theorem 2-1. In Lemma 2-2, the existence of H satisfying [SC0] to [SC3] is crucial. If U is simply connected, such H exists. The definition of simply connected space follows:\n\nDefinition 2-2 (simply connected space). Let M ? Rn be non-empty and path-connected. M is called simply connected if and only if for any continuous loop, c: [0, 1] -> M there exists a continuous tubular homotopy H: [0, 1] × [0, 1] -> M from c to a fixed point p ? c; that is,\n\n• [SC0'] H is continuous,\n• [SC1] H(t, 0) = c(t) for all t ? [0, 1],\n• [SC2] H(t, 1) = p for all t ? [0, 1],\n• [SC3] H(0, s) = H(1, s) = p for all s ? [0, 1].\n\nThe claim that \"for a conservative force, the work done in changing an object's position is path independent\" might seem to follow immediately. But recall that simple-connection only guarantees the existence of a continuous homotopy satisfying [SC1-3]; we seek a piecewise smooth homotopy satisfying those conditions instead.\n\nHowever, the gap in regularity is resolved by the Whitney approximation theorem. We thus obtain the following theorem.\n\nTheorem 2-2. Let U ? R3 be open and simply connected with an irrotational vector field F. For all piecewise smooth loops c: [0, 1] -> U\n\n$\\int _{c_{0}}\\mathbf {F} \\,\\mathrm {d} c_{0}=0$", null, "### Maxwell's equations\n\nIn the physics of electromagnetism, Stokes' theorem provides the justification for the equivalence of the differential form of the Maxwell-Faraday equation and the Maxwell-Ampère equation and the integral form of these equations. For Faraday's law, Stokes' theorem is applied to the electric field, $\\mathbf {E}$", null, ".\n\n$\\oint _{\\partial \\Sigma }\\mathbf {E} \\cdot \\mathrm {d} {\\boldsymbol {l}}=\\iint _{\\Sigma }\\mathbf {\\nabla } \\times \\mathbf {E} \\cdot \\mathrm {d} \\mathbf {S}$", null, "For Ampère's law, Stokes' theorem is applied to the magnetic field, $\\mathbf {B}$", null, ".\n\n$\\oint _{\\partial \\Sigma }\\mathbf {B} \\cdot \\mathrm {d} {\\boldsymbol {l}}=\\iint _{\\Sigma }\\mathbf {\\nabla } \\times \\mathbf {B} \\cdot \\mathrm {d} \\mathbf {S}$", null, "" ]
[ null, "https://www.popflock.com/images/logo/popflock-logo.gif", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/f936ddf584f8f3dd2a0ed08917001b7a404c10b5", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/f936ddf584f8f3dd2a0ed08917001b7a404c10b5", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/9e1f558f53cda207614abdf90162266c70bc5c1e", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/a8b6112fefd0ffc1007f8dbfc95e374e12acf6e7", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/c9c2d3959ed832febda633955efaa09bac1d3183", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/9e1f558f53cda207614abdf90162266c70bc5c1e", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/e987421476b9d8c3a5e1880a486994d1260e5c3b", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/0b9f11a79fab89e1eebc239d68c25d13863e442c", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/f1c6fc3c1c87bf318baa6098b8643738758eebea", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/00822c7f8cbbb216429f922c995eeaeaffde65a2", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/698ecf5b8819678b81f072e1aa89da6aa1af9f8c", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/69fc843cdd814eaecc188ed8b7427f3131206a47", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/69a199c89689daf418a337889b9f99ecc5a31878", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/b151592a7bd42615a0359158ce62bc48572bcacf", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/2887f7bea1b0ff3e01c93264941f75628ca0ad44", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/ef4cd95ddfb3d25550e19b94b82dbba997ce37b0", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/d1bb64b99ddd408ee9ca72fed64aef27bcaf151a", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/969ccee06dcfb85b246a7f0ebaf8785f1595cd56", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/669bc58a7cdca60b1b58eeb0fff211675abdbce2", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/4641b527ba8e4479d946530b8bd55683faf1331a", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/8ce24d35d1681514722d1d413fd0713643ece5b5", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/9354a75fb4426a5d2788a9cb67bc700a09cf7ce0", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/193078efa26144b68610218e410aec6c334c57a3", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/f138508fa5cc66ff5ca6d49823f06bfdffb701b0", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/81862057ae050d05e849be0e9b662ba4fcd2574b", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/a15022657616b297a2c995d1b314a3aa3442c0cb", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/4aaddbc26d6c0984b27d0de867f77726268dc30a", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/0d3f7f7e3422c8978f976a292ae8f02f30c02a45", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/b440cc87d1805ebd2adafff5286e09cd7aae8677", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/e5ce1b49b59bed6c8ada0e3783fcd5adf7fc6b10", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/be9c22d2bee180bcee3fceccec6aa86792cd5d95", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/48c4db5ffe2d4107078db02115370a90619356be", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/fc80f33cb1b0126c1d4df61fec0cde748de314ce", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/7bbcafcefb522726a597626452a6949b5f9af4bc", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/3e0fd704f18ab41163401bdc9d90cc1dd94e2e9a", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/3e0fd704f18ab41163401bdc9d90cc1dd94e2e9a", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/0d7f22b39d51f780fc02859059c1757c606b9de2", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/c8cc9fc4493027278998e9c9a5cfd5f7935b0b61", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/cafb0ef39b0f5ffa23c170aa7f7b4e718327c4d1", null, "https://wikimedia.org/api/rest_v1/media/math/render/svg/df07956974e0b86d53324d423de60d24af42f41a", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8987658,"math_prob":0.9997992,"size":7408,"snap":"2021-31-2021-39","text_gpt3_token_len":2083,"char_repetition_ratio":0.118989736,"word_repetition_ratio":0.0743349,"special_character_ratio":0.27929264,"punctuation_ratio":0.16559692,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":1.0000012,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,9,null,6,null,null,null,2,null,3,null,2,null,2,null,2,null,4,null,2,null,4,null,4,null,5,null,6,null,4,null,5,null,4,null,4,null,2,null,2,null,1,null,3,null,null,null,2,null,3,null,4,null,3,null,6,null,3,null,3,null,3,null,6,null,6,null,null,null,3,null,null,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-23T21:24:21Z\",\"WARC-Record-ID\":\"<urn:uuid:2f95f24f-99e5-48ed-a8c4-744ec61c0291>\",\"Content-Length\":\"249813\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3abed4d8-764c-49b7-8249-358f584da4df>\",\"WARC-Concurrent-To\":\"<urn:uuid:56088b38-cd64-41d3-9224-d43785f8642b>\",\"WARC-IP-Address\":\"75.98.175.100\",\"WARC-Target-URI\":\"https://www.popflock.com/learn?s=Stokes'_theorem\",\"WARC-Payload-Digest\":\"sha1:IAA5STFLLTWYOL3J5BK63N4DFYT45ZGX\",\"WARC-Block-Digest\":\"sha1:XQXZRCSNBQILMUWZH7XIL5HO5AMPTT5T\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057447.52_warc_CC-MAIN-20210923195546-20210923225546-00111.warc.gz\"}"}
https://pipingdesigner.co/index.php/properties/fluid-mechanics/2250-hydraulic-diameter-of-an-ellipse
[ "# Hydraulic Diameter of an Ellipse\n\nWritten by Jerry Ratzlaff on . Posted in Fluid Dynamics", null, "The hydraulic diameter, abbreviated dh, is used to calculate the Reynolds Number, friction factor or for calculating pressure drop across two points.  For most geometries, the hydraulic diameter, or characteristic length, is not equal to the diameter of the shape.  The calculation below is an example of the hydraulic diameter when the shape is an ellipse as a flowing area. This equation will also find the hydraulic diameter of a circular flowing area if the height and width are the same values.\n\n## Hyd. Dia. of an Ellipse formulas\n\n $$\\large{ d_h = \\frac { 4\\;w\\;h\\; \\left( 64 \\;-\\; 16\\; e^2 \\right) } { \\left( w \\;+\\; h \\right) \\; \\left( 64 \\;-\\; 3\\; e^4 \\right) } }$$ $$\\large{ e = \\frac { w \\;-\\; h } { w \\;+\\; h } }$$\n\n### Where:\n\n$$\\large{ d_h }$$ = hydraulic diameter\n\n$$\\large{ h }$$ = height of ellipse\n\n$$\\large{ w }$$ = width of ellipse" ]
[ null, "https://pipingdesigner.co/images/properties/classical_mechanics/hydraulic/hydraulic_diameter_of_a_ellipse_1.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8196603,"math_prob":0.99978334,"size":726,"snap":"2020-34-2020-40","text_gpt3_token_len":160,"char_repetition_ratio":0.18559557,"word_repetition_ratio":0.017094018,"special_character_ratio":0.21900827,"punctuation_ratio":0.10236221,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.999826,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-20T13:46:43Z\",\"WARC-Record-ID\":\"<urn:uuid:4db6a62b-12ac-482d-93c2-766c673ab1c1>\",\"Content-Length\":\"27173\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:985a2009-81f1-4aae-862a-427f65e1efd2>\",\"WARC-Concurrent-To\":\"<urn:uuid:1dd89ad1-c204-42f9-8a43-5f961864804f>\",\"WARC-IP-Address\":\"23.235.195.68\",\"WARC-Target-URI\":\"https://pipingdesigner.co/index.php/properties/fluid-mechanics/2250-hydraulic-diameter-of-an-ellipse\",\"WARC-Payload-Digest\":\"sha1:L2KNDWS2UZFIVJCVYEQ5RZ7TFIEEVTS4\",\"WARC-Block-Digest\":\"sha1:KY4M5QQWEJVLRGKF72XSHOOJFUYI6SRN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400198213.25_warc_CC-MAIN-20200920125718-20200920155718-00207.warc.gz\"}"}
https://for5327.uni-mainz.de/aims-and-scope/
[ "# Aims and Scope\n\nPhoton-photon ($$\\gamma\\gamma$$) interactions play an important role in the Standard Model (SM) of particle physics. A prominent example is the Higgs boson discovery at the Large Hadron Collider (LHC), where the $$\\gamma\\gamma$$ channel served as a primary discovery mode.\n\nIt is fascinating to realize that $$\\gamma\\gamma$$ interactions, and, in particular, the light-by-light (LbL) scattering, are effects of purely quantum origin. In classical electrodynamics, the linearity of Maxwell's equations precludes such processes from occurring. In the SM, the LbL scattering arises dynamically through the quantum loops of charged particles, as illustrated in the figure below.", null, "A precise calculation of these effects in the SM is, however, not always straightforward - a major obstacle is posed by the non-perturbative nature of the strong interaction, described by quantum chromodynamics (QCD).\n\nIn recent years, the need for a detailed understanding of the QCD contribution to LbL scattering has been prompted from different directions:\n\n• The very recent measurement of the muon's anomalous magnetic moment $$a_\\mu = \\frac{1}{2} (g-2)_\\mu$$ at Fermilab, which increases the tension between the experimental value and its SM prediction to 4.2 standard deviations, and ongoing further measurements at Fermilab and J-PARC, which call for a higher precision on the hadronic LbL contribution to $$(g-2)_\\mu$$ in order to stringently test the SM calculation,\n• The recent development of dispersion relations for the computation of the hadronic LbL contribution to $$(g-2)_\\mu$$, which require precision data of meson transition form factors as input and which - in turn - allow for unique probes of hadron structure,\n• The discovery of exotic XYZ states in the charmonium sector of QCD, and an extraction of their properties through hidden-flavor decays, which hinges upon information coming from γγ-fusion processes in light meson systems,\n• The first direct observation of LbL scattering at the LHC, opening a new venue for testing the SM and beyond,\n• The increasingly intensified searches for axion-like particles (ALPs) and dark sector particles, stimulated by the mounting evidence from astrophysics and cosmology for physics beyond the SM, and by the possible discovery of a new light boson.\n\nThe scientists in this Research Unit (RU) have been playing most visible roles in all of the above-mentioned research directions, either by carrying out precision experiments at various facilities worldwide\n(A2@MAMI, BaBar, BESIII, KLOE-2, WASA-at-COSY, ATLAS@LHC), by providing theoretical support for these experiments, or by directly calculating the quantities of interest as for example the hadronic LbL contribution to $$(g-2)_\\mu$$. For these calculations both ab-initio methods such as lattice quantum chromodynamics (lattice QCD) or phenomenological approaches are used." ]
[ null, "https://for5327.uni-mainz.de/files/2022/04/LbLfusion_diagramm.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.90729296,"math_prob":0.939368,"size":2868,"snap":"2023-40-2023-50","text_gpt3_token_len":632,"char_repetition_ratio":0.09916201,"word_repetition_ratio":0.0071770335,"special_character_ratio":0.20223153,"punctuation_ratio":0.089613035,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9780427,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-03T01:34:45Z\",\"WARC-Record-ID\":\"<urn:uuid:74738db3-56d8-40c4-8c7a-872a53d35a46>\",\"Content-Length\":\"31566\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:205abb72-87b3-47ee-aee0-03edcd217caa>\",\"WARC-Concurrent-To\":\"<urn:uuid:fa876ef3-5810-4589-a7ba-d5d72f413f81>\",\"WARC-IP-Address\":\"134.93.178.16\",\"WARC-Target-URI\":\"https://for5327.uni-mainz.de/aims-and-scope/\",\"WARC-Payload-Digest\":\"sha1:LW4BX5ZZWDTHAO3DXKXHV7A7JL6KO53O\",\"WARC-Block-Digest\":\"sha1:VQX6QXQI7WPJBQQKR2VIHL3BTDYHTMZ2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100476.94_warc_CC-MAIN-20231202235258-20231203025258-00442.warc.gz\"}"}
https://en.youscribe.com/catalogue/documents/education/model-and-notations-normalization-of-a-mtweg-1714259
[ "36 Pages\nEnglish\n\n# Model and Notations Normalization of a MTWEG\n\n-\n\n36 Pages\nEnglish", null, "Description\n\nModel and Notations Normalization of a MTWEG Formulation using an Integer Linear Program Algorithms A new Approach for Minimizing Buffer Capacities with Throughput Constraint for Embedded System Design Mohamed Benazouz, Olivier Marchetti, Alix Munier-Kordon, Pascal Urard LIP6 Université P. et M. Curie Paris Montpellier, le 23 avril 2009\n\n• minimizing buffer\n\n• time ?\n\n• formulation using\n\n• ti tj\n\n• mohamed benazouz\n\n• lip6 université\n\n• weighted event\n\n• throughput constraint\n\nSubjects\n\n##### Marchetti\n\nInformations\n\nExrait\n\nModel and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nA new Approach for Minimizing Buffer\nCapacities with Throughput Constraint for\nEmbedded System Design\nMohamed Benazouz, Olivier Marchetti, Alix Munier-Kordon,\nPascal Urard\nLIP6\nUniversité P. et M. Curie\nParis\nMontpellier, le 23 avril 2009Model and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nOutline\n1 Model and Notations\n2 Normalization of a MTWEG\n3 Formulation using an Integer Linear Program\n4 AlgorithmsModel and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nMarked Timed Weighted Event Graph (MTWEG)\nDefinition\nG =(T, P,ℓ, M ) is a Marked Timed Weighted Event Graph0\n(MTWEG) where\n1 T ={t ,··· , t } transitions;1 n\n2 P ={p ,··· , p } places;1 m\n3 ℓ: T → N duration function;\n4 M : P → N initial marking;0Model and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nMarked Timed Weighted Event Graph (MTWEG)\np\nu(p) v(p)\nM (p) tt 0 ji\nFigure: A place p =(t , t) of a MTWEG.i j\n1 Each place p∈ P is defined between two transitions t andi\nt ;j\n2 ∀p∈ P u(p) and v(p) are integers called the marking\nfunctions.Model and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nFiring of a transition\n+P (t)={p =(t , t)∈ P, t ∈ T}i i j j\n−P (t)={p =(t , t)∈ P, t ∈ T}i j i j\nif t is fired at time τ:i\n1 At time τ, v(p) tokens are removed from every place\n−p∈P (t).i\n2 At time τ +ℓ(t), u(p) tokens are added to every placei\n+p∈P (t).i\nM(τ, p)= The instantaneaous marking of a place p∈ P at time\nτ ≥ 0Model and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nSchedule and Periodic Schedule\nDefinition\n⋆ +LetG be a MTWEG. A schedule is a function s : T × N → Q\n⋆which associates, with any tuple(t , q)∈ T × N , the startingi\ntime of the qth firing of t .i\nDefinition\nA schedule s is periodic if there exists a vector\nn+w =(w ,..., w )∈ Q such that, for any couple1 n\n⋆(t , q)∈ T × N , s(t , q)= s(t , 1)+(q− 1)w . w is then thei i i i i\n1speriod of the transition t and λ (t)= its throughput.i i\nwiModel and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nA car radio application (Wiggers et al.)\nt t tMP3 Out To7 1 9\ntCell 5\nPhone\nt3\ntMicro- 10\nphone\nSignal to eliminate\nFigure: Block diagram of a car-radio applicationModel and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nModelling using a MTWEG\n1 Transitions corresponds to treatments;\n2 Places corresponds to buffered transfers.\nBut...the size of the buffers should be limited !Model and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nBounded capacity\nDefinition\nA place p =(t , t) has a bounded capacity F(p) > 0 if thei j\nnumber of tokens stored in p can not exceed F(p):\n∀τ ≥ 0, M(τ, p)≤ F(p)\nDefinition\nA MTWEGG =(T, P, M ,ℓ, F) is said to be a bounded capacity0\ngraph if the capacity of every place p∈ P is bounded by F(p).Model and Notations\nNormalization of a MTWEG\nFormulation using an Integer Linear Program\nAlgorithms\nBounded capacity (Marchetti, Munier 2009)\nM (p ) = M (p)0 1 0\np\npu(p) v(p) 1\nu(p) v(p)\np2M (p)0t t t ti j i j\nM(p,τ)≤ F(p)\nM (p ) = F(p)− M (p)0 2 0\nFigure: A place p with limited capacity F(p) and the couple of places\n(p , p ) without capacities that models place p.1 2 c\nDefinition\nG is a symmetric MTWEG if every place p =(t , t) is associatedi j\n′with a backward place p =(t , t) modelling the limited capacity.j i" ]
[ null, "https://en.youscribe.com/Content/imgv5/illustration/balloon/youscribe-ballon-flying_half.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7146161,"math_prob":0.9682145,"size":3988,"snap":"2021-04-2021-17","text_gpt3_token_len":1295,"char_repetition_ratio":0.1498494,"word_repetition_ratio":0.1875862,"special_character_ratio":0.2657974,"punctuation_ratio":0.100850545,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9942239,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-28T12:14:28Z\",\"WARC-Record-ID\":\"<urn:uuid:61746c6e-3d93-4016-81e6-781478a1410a>\",\"Content-Length\":\"513814\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:83820f74-a0c9-4686-bfb7-4ce62eefbd95>\",\"WARC-Concurrent-To\":\"<urn:uuid:9ad29acf-dab4-4d25-a16e-7bc091c6ff58>\",\"WARC-IP-Address\":\"35.186.237.217\",\"WARC-Target-URI\":\"https://en.youscribe.com/catalogue/documents/education/model-and-notations-normalization-of-a-mtweg-1714259\",\"WARC-Payload-Digest\":\"sha1:PMBANKXIXI7CT2OSEDOXHAEN3FDXI6YN\",\"WARC-Block-Digest\":\"sha1:4MIHYU4LP3YIAX3JXP7DSFEDDPPND6ND\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610704843561.95_warc_CC-MAIN-20210128102756-20210128132756-00098.warc.gz\"}"}
https://flyharvest.com/products/great-planes-fuselage-set-flylite-ep-arf-gpma2582
[ "", null, "# Great Planes Fuselage Set Flylite Ep Arf Gpma2582\n\nVendor\nGreat Planes\nRegular price\nSold out\nSale price\n\\$64.18\nQuantity must be 1 or more\n\n• T\n\n• h\n\n• i\n\n• s\n\n• i\n\n• s\n\n• t\n\n• h\n\n• e\n\n• G\n\n• r\n\n• e\n\n• a\n\n• t\n\n• P\n\n• l\n\n• a\n\n• n\n\n• e\n\n• s\n\n• F\n\n• u\n\n• s\n\n• e\n\n• l\n\n• a\n\n• g\n\n• e\n\n• S\n\n• e\n\n• t\n\n• f\n\n• o\n\n• r\n\n• t\n\n• h\n\n• e\n\n• E\n\n• l\n\n• e\n\n• c\n\n• t\n\n• r\n\n• i\n\n• F\n\n• l\n\n• y\n\n• F\n\n• l\n\n• y\n\n• l\n\n• i\n\n• t\n\n• e\n\n• E\n\n• P\n\n• A\n\n• R\n\n• F\n\n• A\n\n• i\n\n• r\n\n• p\n\n• l\n\n• a\n\n• n\n\n• e\n\n• .\n\n• F\n\n• e\n\n• a\n\n• t\n\n• u\n\n• r\n\n• e\n\n• s\n\n• :\n\n• W\n\n• h\n\n• i\n\n• t\n\n• e\n\n• a\n\n• n\n\n• d\n\n• b\n\n• l\n\n• u\n\n• e\n\n• c\n\n• o\n\n• l\n\n• o\n\n• r\n\n• e\n\n• d\n\n• A\n\n• e\n\n• r\n\n• o\n\n• C\n\n• e\n\n• l\n\n• l\n\n• f\n\n• o\n\n• a\n\n• m\n\n• c\n\n• o\n\n• n\n\n• s\n\n• t\n\n• r\n\n• u\n\n• c\n\n• t\n\n• i\n\n• o\n\n• n\n\n• F\n\n• o\n\n• r\n\n• t\n\n• h\n\n• e\n\n• G\n\n• r\n\n• e\n\n• a\n\n• t\n\n• P\n\n• l\n\n• a\n\n• n\n\n• e\n\n• s\n\n• E\n\n• l\n\n• e\n\n• c\n\n• t\n\n• r\n\n• i\n\n• F\n\n• l\n\n• y\n\n• F\n\n• l\n\n• y\n\n• l\n\n• i\n\n• t\n\n• e\n\n• E\n\n• P\n\n• A\n\n• R\n\n• F\n\n• A\n\n• i\n\n• r\n\n• p\n\n• l\n\n• a\n\n• n\n\n• e\n\n• P\n\n• r\n\n• e\n\n• i\n\n• n\n\n• s\n\n• t\n\n• a\n\n• l\n\n• l\n\n• e\n\n• d\n\n• t\n\n• a\n\n• i\n\n• l\n\n• w\n\n• h\n\n• e\n\n• e\n\n• l\n\n• a\n\n• s\n\n• s\n\n• e\n\n• m\n\n• b\n\n• l\n\n• y\n\n• ,\n\n• p\n\n• u\n\n• s\n\n• h\n\n• r\n\n• o\n\n• d\n\n• s\n\n• ,\n\n• w\n\n• o\n\n• o\n\n• d\n\n• e\n\n• n\n\n• s\n\n• e\n\n• r\n\n• v\n\n• o\n\n• t\n\n• r\n\n• a\n\n• y\n\n• s\n\n• ,\n\n• w\n\n• i\n\n• n\n\n• g\n\n• d\n\n• o\n\n• w\n\n• e\n\n• l\n\n• s\n\n• a\n\n• n\n\n• d\n\n• b\n\n• a\n\n• t\n\n• t\n\n• e\n\n• r\n\n• y\n\n• h\n\n• a\n\n• t\n\n• c\n\n• h\n\n• I\n\n• n\n\n• c\n\n• l\n\n• u\n\n• d\n\n• e\n\n• s\n\n• :\n\n• O\n\n• n\n\n• e\n\n• G\n\n• r\n\n• e\n\n• a\n\n• t\n\n• P\n\n• l\n\n• a\n\n• n\n\n• e\n\n• s\n\n• F\n\n• l\n\n• y\n\n• l\n\n• i\n\n• t\n\n• e\n\n• F\n\n• u\n\n• s\n\n• e\n\n• l\n\n• a\n\n• g\n\n• e\n\n• R\n\n• e\n\n• q\n\n• u\n\n• i\n\n• r\n\n• e\n\n• s\n\n• :\n\n• I\n\n• n\n\n• s\n\n• t\n\n• a\n\n• l\n\n• l\n\n• i\n\n• n\n\n• g\n\n• a\n\n• l\n\n• l\n\n• c\n\n• o\n\n• m\n\n• p\n\n• o\n\n• n\n\n• e\n\n• n\n\n• t\n\n• s\n\n• i\n\n• n\n\n• t\n\n• o\n\n• a\n\n• n\n\n• d\n\n• o\n\n• n\n\n• t\n\n• o\n\n• f\n\n• u\n\n• s\n\n• e\n\n• l\n\n• a\n\n• g\n\n• e\n\nThis is the Great Planes Fuselage Set for the ElectriFly Flylite EP ARF Airplane.\n\nFeatures:\n\n• White and blue colored\n• AeroCell foam construction\n• For the Great Planes ElectriFly Flylite EP ARF Airplane\n• Preinstalled tailwheel assembly, pushrods, wooden servo trays, wing dowels and battery hatch\n\nIncludes:\nOne Great Planes Flylite Fuselage\n\nRequires:\nInstalling all components into and onto fuselage" ]
[ null, "https://cdn.shopify.com/s/files/1/0019/7813/8724/products/31T6Utlc5rL_300x300.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5427364,"math_prob":0.5536584,"size":1075,"snap":"2020-45-2020-50","text_gpt3_token_len":764,"char_repetition_ratio":0.12885155,"word_repetition_ratio":0.25888324,"special_character_ratio":0.3860465,"punctuation_ratio":0.034912717,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":1.0000098,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-26T01:04:58Z\",\"WARC-Record-ID\":\"<urn:uuid:12c8fd3b-b472-4abd-bf38-9828e5e79a52>\",\"Content-Length\":\"111989\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1a46cfc2-d5b9-44f3-ac7d-99bc05964620>\",\"WARC-Concurrent-To\":\"<urn:uuid:dad4b22a-d0c5-400b-880b-936ee19ba679>\",\"WARC-IP-Address\":\"23.227.38.32\",\"WARC-Target-URI\":\"https://flyharvest.com/products/great-planes-fuselage-set-flylite-ep-arf-gpma2582\",\"WARC-Payload-Digest\":\"sha1:WGR65IXWETNAOIF76IGJOOO47CBN7S6P\",\"WARC-Block-Digest\":\"sha1:D6INYXA73XPTCWGCAY4GBEND6FCNZKI5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107890108.60_warc_CC-MAIN-20201026002022-20201026032022-00277.warc.gz\"}"}
https://www.geeksforgeeks.org/spectral-plot-sinusodial-model/?ref=rp
[ "", null, "Open in App\nNot now\n\n# Spectral Plot – Sinusoidal Model\n\n• Last Updated : 31 Oct, 2022\n\nThe spectral plot is used to demonstrate the single dominant frequency of the plot. This indicates that the single cycle sinusoidal model might be appropriate.", null, "Consider the above plot, Let’s assume that the plot has distribution as follows:", null, "Now, we try to estimate the constant by the sample mean. This type of analysis would lead to an incorrect conclusion because:\n\n• The sample mean is biased\n• The confidence interval (CI) for the mean is too small.\n\nHere, the proper choice of model is like", null, "", null, "where, a (alpha) is the amplitude, and w (omega) is the frequency of the observation and phi is the phase difference.\n\nThe next steps after this :\n\n• Estimate the frequency of the spectral plot, this would be helpful in starting the value of subsequent non-linear fitting. We can use the Complex Demodulation phase plot to estimate it.\n• Do a complex demodulation Amplitude plot to estimate the amplitude of the plot and to determine whether a constant amplitude is sufficient.\n• Perform a non-linear fit of the model on the dataset.", null, "#### Implementation:\n\n• In this implementation, we will be using a beam deflection case study, the dataset can be downloaded from here.\n\n## Python3\n\n # necessary importsimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as sm%matplotlib inlinesns.mpl.rcParams['figure.figsize'] = (20.0, 15.0) # read beam databeam_data = pd.read_csv('beam_Deflection.txt', header=None) # draw 4 plotsns.set_style('darkgrid') fig, ax  = plt.subplots(2,2) sns.lineplot(x= pd.Series(beam_data.index),y =beam_data,ax =ax[0,0])ax[0,0].set_title('Run Sequence Plot') pd.plotting.lag_plot(beam_data,ax =ax[0,1])ax[0,1].set_title('Lag Plot with k=1') sns.histplot(beam_data,kde=True,ax =ax[1,0])ax[1,0].set_title('Histogram')sm.ProbPlot(beam_data).qqplot(line='s', ax=ax[1,1],color='blue');ax[1,1].set_title('Normal Probability Plot')  fig.suptitle('4-plot')plt.show()", null, "• The 4-plot(Lag plot) clearly shows that there is some periodic type of function that can be used to describe the dataset. Now, Let’s assume that the data can be fitted by the following equation:", null, "• Now, we plot the complex demodulation phase plot and complex demodulation amplitude plot to get the frequency and amplitude of the above equation. You can know more about how to plot complex demodulation phase and amplitude plot from here.\n• The complex demodulation phase plot gives the frequency of 0.3025 and the complex demodulation amplitude plot gives the amplitude of around 390 after a cold start.\n\n#### References:\n\nMy Personal Notes arrow_drop_up" ]
[ null, "https://media.geeksforgeeks.org/gfg-gg-logo.svg", null, "https://media.geeksforgeeks.org/wp-content/uploads/20210125131316/sinosudal.JPG", null, "https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-7def9a48fe9a3274aa2b9cf315dfd17e_l3.png", null, "https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-bd784adbac37436755481bf370260ebe_l3.png", null, "https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-bd784adbac37436755481bf370260ebe_l3.png", null, "https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-bd784adbac37436755481bf370260ebe_l3.png", null, "https://media.geeksforgeeks.org/wp-content/uploads/20210129142640/4plots-660x500.JPG", null, "https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-5b61ef00ba1a81eaedb2296dda279788_l3.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.74018675,"math_prob":0.98376745,"size":2735,"snap":"2022-40-2023-06","text_gpt3_token_len":721,"char_repetition_ratio":0.12669352,"word_repetition_ratio":0.008639309,"special_character_ratio":0.26398537,"punctuation_ratio":0.14990513,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9995297,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"im_url_duplicate_count":[null,null,null,2,null,2,null,6,null,6,null,6,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-02-02T08:20:05Z\",\"WARC-Record-ID\":\"<urn:uuid:2f1a36c1-94b3-4f05-8ec6-295e79b6bbde>\",\"Content-Length\":\"149079\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:70f592fa-fa6d-4710-ab5b-0059f85f22ba>\",\"WARC-Concurrent-To\":\"<urn:uuid:f254021d-fdd6-49d4-b14b-c11a317193a0>\",\"WARC-IP-Address\":\"23.62.6.176\",\"WARC-Target-URI\":\"https://www.geeksforgeeks.org/spectral-plot-sinusodial-model/?ref=rp\",\"WARC-Payload-Digest\":\"sha1:OYO6GUTVFE3C77NV7W6VNOPR2T5NZKF3\",\"WARC-Block-Digest\":\"sha1:MP2AF3FRDS43YGHSGJEKUQDCJSLB7EV6\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764499967.46_warc_CC-MAIN-20230202070522-20230202100522-00795.warc.gz\"}"}
https://tools.carboncollective.co/inflation/us/1978/89872/1981/
[ "# $89,872 in 1978 is worth$125,297.01 in 1981\n\n$89,872 in 1978 has the same purchasing power as$125,297.01 in 1981. Over the 3 years this is a change of $35,425.01. The average inflation rate of the dollar between 1978 and 1981 was 10.69% per year. The cumulative price increase of the dollar over this time was 39.42%. ## The value of$89,872 from 1978 to 1981\n\nSo what does this data mean? It means that the prices in 1981 are 1,252.97 higher than the average prices since 1978. A dollar in 1981 can buy 71.73% of what it could buy in 1978.\n\nWe can look at the buying power equivalent for $89,872 in 1978 to see how much you would need to adjust for in order to beat inflation. For 1978 to 1981, if you started with$89,872 in 1978, you would need to have $125,297.01 in 1978 to keep up with inflation rates. So if we are saying that$89,872 is equivalent to $125,297.01 over time, you can see the core concept of inflation in action. The \"real value\" of a single dollar decreases over time. It will pay for fewer items at the store than it did previously. In the chart below you can see how the value of the dollar is worth less over 3 years. ## Value of$89,872 Over Time\n\nIn the table below we can see the value of the US Dollar over time. According to the BLS, each of these amounts are equivalent in terms of what that amount could purchase at the time.\n\nYear Dollar Value Inflation Rate\n1978 $89,872.00 7.59% 1979$100,072.20 11.35%\n1980 $113,580.56 13.50% 1981$125,297.01 10.32%\n\n## US Dollar Inflation Conversion\n\nIf you're interested to see the effect of inflation on various 1950 amounts, the table below shows how much each amount would be worth today based on the price increase of 39.42%.\n\nInitial Value Equivalent Value\n$1.00 in 1978$1.39 in 1981\n$5.00 in 1978$6.97 in 1981\n$10.00 in 1978$13.94 in 1981\n$50.00 in 1978$69.71 in 1981\n$100.00 in 1978$139.42 in 1981\n$500.00 in 1978$697.09 in 1981\n$1,000.00 in 1978$1,394.17 in 1981\n$5,000.00 in 1978$6,970.86 in 1981\n$10,000.00 in 1978$13,941.72 in 1981\n$50,000.00 in 1978$69,708.59 in 1981\n$100,000.00 in 1978$139,417.18 in 1981\n$500,000.00 in 1978$697,085.89 in 1981\n$1,000,000.00 in 1978$1,394,171.78 in 1981\n\n## Calculate Inflation Rate for $89,872 from 1978 to 1981 To calculate the inflation rate of$89,872 from 1978 to 1981, we use the following formula:\n\n$$\\dfrac{ 1978\\; USD\\; value \\times CPI\\; in\\; 1981 }{ CPI\\; in\\; 1978 } = 1981\\; USD\\; value$$\n\nWe then replace the variables with the historical CPI values. The CPI in 1978 was 65.2 and 90.9 in 1981.\n\n$$\\dfrac{ \\89,872 \\times 90.9 }{ 65.2 } = \\text{ \\125,297.01 }$$\n\n$89,872 in 1978 has the same purchasing power as$125,297.01 in 1981.\n\nTo work out the total inflation rate for the 3 years between 1978 and 1981, we can use a different formula:\n\n$$\\dfrac{\\text{CPI in 1981 } - \\text{ CPI in 1978 } }{\\text{CPI in 1978 }} \\times 100 = \\text{Cumulative rate for 3 years}$$\n\nAgain, we can replace those variables with the correct Consumer Price Index values to work out the cumulativate rate:\n\n$$\\dfrac{\\text{ 90.9 } - \\text{ 65.2 } }{\\text{ 65.2 }} \\times 100 = \\text{ 39.42\\% }$$\n\n## Inflation Rate Definition\n\nThe inflation rate is the percentage increase in the average level of prices of a basket of selected goods over time. It indicates a decrease in the purchasing power of currency and results in an increased consumer price index (CPI). Put simply, the inflation rate is the rate at which the general prices of consumer goods increases when the currency purchase power is falling.\n\nThe most common cause of inflation is an increase in the money supply, though it can be caused by many different circumstances and events. The value of the floating currency starts to decline when it becomes abundant. What this means is that the currency is not as scarce and, as a result, not as valuable.\n\nBy comparing a list of standard products (the CPI), the change in price over time will be measured by the inflation rate. The prices of products such as milk, bread, and gas will be tracked over time after they are grouped together. Inflation shows that the money used to buy these products is not worth as much as it used to be when there is an increase in these products’ prices over time.\n\nThe inflation rate is basically the rate at which money loses its value when compared to the basket of selected goods – which is a fixed set of consumer products and services that are valued on an annual basis." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.92428,"math_prob":0.9853281,"size":4947,"snap":"2022-05-2022-21","text_gpt3_token_len":1495,"char_repetition_ratio":0.17115112,"word_repetition_ratio":0.022857143,"special_character_ratio":0.38326257,"punctuation_ratio":0.13976556,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9955429,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-16T22:12:52Z\",\"WARC-Record-ID\":\"<urn:uuid:836176da-220e-4d3f-9f00-55e2463194a8>\",\"Content-Length\":\"30034\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b3b9c1b9-eb88-45e0-abc8-ee1880210f47>\",\"WARC-Concurrent-To\":\"<urn:uuid:3a9457a8-bec2-489a-8d8c-a1c581ea7e19>\",\"WARC-IP-Address\":\"138.197.3.89\",\"WARC-Target-URI\":\"https://tools.carboncollective.co/inflation/us/1978/89872/1981/\",\"WARC-Payload-Digest\":\"sha1:7M7BJ4O7X2B6Y4ZT6DZGN4LI75RJM2DR\",\"WARC-Block-Digest\":\"sha1:AS5YTTQF3UEHYXODVXHDB726UZTLDXR5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662512249.16_warc_CC-MAIN-20220516204516-20220516234516-00196.warc.gz\"}"}
https://abdn.pure.elsevier.com/en/publications/control-design-method-of-hamiltonian-structure-modified-and-its-a
[ "# Control design method of Hamiltonian structure modified and its application\n\nYun Zeng, LX Zhang, J Qian, Yakun Guo\n\nResearch output: Contribution to journalArticle\n\n2 Citations (Scopus)\n\n### Abstract\n\nThe main difficulty is to derive the modified energy function H a( x) in designing the control law for interconnection and damping assignment passivity-based control( IDA-PBC). A design approach of control law,which could avoid that difficulty,was proposed. A composition mode that control law were composed by stabilization control at given equilibrium point and additional control in IDA-PBC was proposed,in which added relative factors in structure and damping matrix can play a role by additional control item. Furthermore,equation of the stabilization control and was solved explicit expressions of the additional control were derived,and stability conditions of closed loop were derived. Taking Hamiltonian model of hydro turbine generating units as example,the application steps of this design method were introduced. This method,in which control can be calculated with modified interconnection and damping matrix directly,and the limit of relative factors are determined by the definite condition of Hessian matrix,is simple and validity\nOriginal language English 93-100 8 Electric Machines and Control 18 3 Published - Mar 2014\n\nHamiltonians\nDamping\nStabilization\nTurbines\n\n### Cite this\n\nControl design method of Hamiltonian structure modified and its application. / Zeng, Yun; Zhang, LX; Qian, J; Guo, Yakun.\n\nIn: Electric Machines and Control, Vol. 18, No. 3, 03.2014, p. 93-100.\n\nResearch output: Contribution to journalArticle\n\nZeng, Y, Zhang, LX, Qian, J & Guo, Y 2014, 'Control design method of Hamiltonian structure modified and its application', Electric Machines and Control, vol. 18, no. 3, pp. 93-100.\nZeng, Yun ; Zhang, LX ; Qian, J ; Guo, Yakun. / Control design method of Hamiltonian structure modified and its application. In: Electric Machines and Control. 2014 ; Vol. 18, No. 3. pp. 93-100.\n@article{ebc00d8f2e4749cfa9cc7a7641954db5,\ntitle = \"Control design method of Hamiltonian structure modified and its application\",\nabstract = \"The main difficulty is to derive the modified energy function H a( x) in designing the control law for interconnection and damping assignment passivity-based control( IDA-PBC). A design approach of control law,which could avoid that difficulty,was proposed. A composition mode that control law were composed by stabilization control at given equilibrium point and additional control in IDA-PBC was proposed,in which added relative factors in structure and damping matrix can play a role by additional control item. Furthermore,equation of the stabilization control and was solved explicit expressions of the additional control were derived,and stability conditions of closed loop were derived. Taking Hamiltonian model of hydro turbine generating units as example,the application steps of this design method were introduced. This method,in which control can be calculated with modified interconnection and damping matrix directly,and the limit of relative factors are determined by the definite condition of Hessian matrix,is simple and validity\",\nauthor = \"Yun Zeng and LX Zhang and J Qian and Yakun Guo\",\nnote = \"Funding: 国家自然科学基金(51179079); 云南省科技厅科学基金(2013FZ015)\",\nyear = \"2014\",\nmonth = \"3\",\nlanguage = \"English\",\nvolume = \"18\",\npages = \"93--100\",\njournal = \"Electric Machines and Control\",\nissn = \"1007-449X\",\npublisher = \"Harbin University of Science and Technology, Editorial department of Electric Machines and Control\",\nnumber = \"3\",\n\n}\n\nTY - JOUR\n\nT1 - Control design method of Hamiltonian structure modified and its application\n\nAU - Zeng, Yun\n\nAU - Zhang, LX\n\nAU - Qian, J\n\nAU - Guo, Yakun\n\nN1 - Funding: 国家自然科学基金(51179079); 云南省科技厅科学基金(2013FZ015)\n\nPY - 2014/3\n\nY1 - 2014/3\n\nN2 - The main difficulty is to derive the modified energy function H a( x) in designing the control law for interconnection and damping assignment passivity-based control( IDA-PBC). A design approach of control law,which could avoid that difficulty,was proposed. A composition mode that control law were composed by stabilization control at given equilibrium point and additional control in IDA-PBC was proposed,in which added relative factors in structure and damping matrix can play a role by additional control item. Furthermore,equation of the stabilization control and was solved explicit expressions of the additional control were derived,and stability conditions of closed loop were derived. Taking Hamiltonian model of hydro turbine generating units as example,the application steps of this design method were introduced. This method,in which control can be calculated with modified interconnection and damping matrix directly,and the limit of relative factors are determined by the definite condition of Hessian matrix,is simple and validity\n\nAB - The main difficulty is to derive the modified energy function H a( x) in designing the control law for interconnection and damping assignment passivity-based control( IDA-PBC). A design approach of control law,which could avoid that difficulty,was proposed. A composition mode that control law were composed by stabilization control at given equilibrium point and additional control in IDA-PBC was proposed,in which added relative factors in structure and damping matrix can play a role by additional control item. Furthermore,equation of the stabilization control and was solved explicit expressions of the additional control were derived,and stability conditions of closed loop were derived. Taking Hamiltonian model of hydro turbine generating units as example,the application steps of this design method were introduced. This method,in which control can be calculated with modified interconnection and damping matrix directly,and the limit of relative factors are determined by the definite condition of Hessian matrix,is simple and validity\n\nM3 - Article\n\nVL - 18\n\nSP - 93\n\nEP - 100\n\nJO - Electric Machines and Control\n\nJF - Electric Machines and Control\n\nSN - 1007-449X\n\nIS - 3\n\nER -" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9257747,"math_prob":0.7817292,"size":2926,"snap":"2019-51-2020-05","text_gpt3_token_len":653,"char_repetition_ratio":0.12183436,"word_repetition_ratio":0.6894977,"special_character_ratio":0.21565276,"punctuation_ratio":0.10671937,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9585842,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-22T14:42:30Z\",\"WARC-Record-ID\":\"<urn:uuid:a9c5e3d0-e87f-4bfa-acf7-f6db1b09e69e>\",\"Content-Length\":\"31763\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ea24fd7a-98a4-41f6-8ee0-ba0d232e3535>\",\"WARC-Concurrent-To\":\"<urn:uuid:cb981acb-4bae-4b7f-b84a-a4fbcf07135e>\",\"WARC-IP-Address\":\"52.209.51.54\",\"WARC-Target-URI\":\"https://abdn.pure.elsevier.com/en/publications/control-design-method-of-hamiltonian-structure-modified-and-its-a\",\"WARC-Payload-Digest\":\"sha1:DRIC4LCFMLLIXDRNIWWUGQUISUCJOLVK\",\"WARC-Block-Digest\":\"sha1:EQQLIX4KP7KLGVQ3TKDKCS3DRFDSYTEK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579250607118.51_warc_CC-MAIN-20200122131612-20200122160612-00534.warc.gz\"}"}
https://matplotlib.org/3.0.2/gallery/event_handling/ginput_manual_clabel_sgskip.html
[ "# Interactive functions¶\n\nThis provides examples of uses of interactive functions, such as ginput, waitforbuttonpress and manual clabel placement.\n\nThis script must be run interactively using a backend that has a graphical user interface (for example, using GTK3Agg backend, but not PS backend).\n\nimport time\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef tellme(s):\nprint(s)\nplt.title(s, fontsize=16)\nplt.draw()\n\n\nDefine a triangle by clicking three points\n\nplt.clf()\nplt.axis([-1., 1., -1., 1.])\nplt.setp(plt.gca(), autoscale_on=False)\n\ntellme('You will define a triangle, click to begin')\n\nplt.waitforbuttonpress()\n\nwhile True:\npts = []\nwhile len(pts) < 3:\ntellme('Select 3 corners with mouse')\npts = np.asarray(plt.ginput(3, timeout=-1))\nif len(pts) < 3:\ntellme('Too few points, starting over')\ntime.sleep(1) # Wait a second\n\nph = plt.fill(pts[:, 0], pts[:, 1], 'r', lw=2)\n\ntellme('Happy? Key click for yes, mouse click for no')\n\nif plt.waitforbuttonpress():\nbreak\n\n# Get rid of fill\nfor p in ph:\np.remove()\n\n\nNow contour according to distance from triangle corners - just an example\n\n# Define a nice function of distance from individual pts\ndef f(x, y, pts):\nz = np.zeros_like(x)\nfor p in pts:\nz = z + 1/(np.sqrt((x - p)**2 + (y - p)**2))\nreturn 1/z\n\nX, Y = np.meshgrid(np.linspace(-1, 1, 51), np.linspace(-1, 1, 51))\nZ = f(X, Y, pts)\n\nCS = plt.contour(X, Y, Z, 20)\n\ntellme('Use mouse to select contour label locations, middle button to finish')\nCL = plt.clabel(CS, manual=True)\n\n\nNow do a zoom\n\ntellme('Now do a nested zoom, click to begin')\nplt.waitforbuttonpress()\n\nwhile True:\ntellme('Select two corners of zoom, middle mouse button to finish')\npts = np.asarray(plt.ginput(2, timeout=-1))\n\nif len(pts) < 2:\nbreak\n\npts = np.sort(pts, axis=0)\nplt.axis(pts.T.ravel())\n\ntellme('All Done!')\nplt.show()\n\n\nKeywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.52307117,"math_prob":0.9662692,"size":1816,"snap":"2020-45-2020-50","text_gpt3_token_len":523,"char_repetition_ratio":0.1004415,"word_repetition_ratio":0.014925373,"special_character_ratio":0.30231276,"punctuation_ratio":0.21182266,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99386626,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-12-03T22:59:08Z\",\"WARC-Record-ID\":\"<urn:uuid:4a4956c1-d8fd-4c47-9199-6ead0af49c86>\",\"Content-Length\":\"22179\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ce15d636-e592-4ad8-ba51-6a2137db7d26>\",\"WARC-Concurrent-To\":\"<urn:uuid:ae298d81-f9a9-4d15-be7b-1dcd38d42ae6>\",\"WARC-IP-Address\":\"104.26.1.8\",\"WARC-Target-URI\":\"https://matplotlib.org/3.0.2/gallery/event_handling/ginput_manual_clabel_sgskip.html\",\"WARC-Payload-Digest\":\"sha1:V75MIV42M6FXRWJK37PRYB4NNKQJIWBJ\",\"WARC-Block-Digest\":\"sha1:FZL6M2XXB2VSCYYKP4IPSH5ZCSXKRTSG\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141732835.81_warc_CC-MAIN-20201203220448-20201204010448-00002.warc.gz\"}"}
https://kennt-allein.com/book/show/6811772-matlab-simulink-for-digital-communicatioy6zvta21874rp-
[ "Home\n\n# Lineaarikombinaatio matlab\n\nINLINE Construct INLINE object. INLINE(EXPR) constructs an inline function object from the MATLAB expression contained in the string EXPR. The input arguments are automatically determined by searching EXPR for variable names (see SYMVAR). If no variable exists, 'x' is used. INLINE(EXPR, ARG1, ARG2, ...) constructs an inline function whose input arguments are specified by the strings ARG1, ARG2, ... Multicharacter symbol names may be used. INLINE(EXPR, N), where N is a scalar, constructs an inline function whose input arguments are 'x', 'P1', 'P2', ..., 'PN'. Examples: g = inline('t^2') g = inline('sin(2*pi*f + theta)') g = inline('sin(2*pi*f + theta)', 'f', 'theta') g = inline('x^P1', 1) Notes Inline functions cannot access variables in the workspace at any time, even if those variables are global. Assume that the space between the quotes in the first argument exists in its own special MATLAB universe. This is different from anonymous functions, in that anonymous functions can see the workspace at the time they are created. Inline functions can only have one expression and can only return a single variable (though that variable can be a matrix). [X,Y] = meshgrid(-30:30); Z = X + Y; surf(X,Y,Z); xlabel('X'); ylabel('Y'); zlabel('Z = C'); % C defines ‘Clim’ colorbar Fig. 6(a) x = [0:0.01:10]; y = sin(x); plot(x, y), xlabel('x'), ylabel('Sin(x)'), title('Sin(x) Graph'), grid on, axis equal MATLAB generates the following graph −\n\n## Linearization in MATLAB how to linearize nonlinear model in Matlab\n\nHere is an example of using Matlab to demonstrate Amplitude Modulation. The demo does not provide any mathematical background. However, you can visually see what the concept of amplitude.. FMI Toolbox for MATLAB/Simulink supports all major workflows in control system development and system integration for virtual prototyping, from design and sizing to optimization and MIL/SIL/HIL.. MATLAB Installation Guide. MATLAB (for 32 bit computer). *Click on the link on the MATLAB FAQ for details on how to find out if you are using a 32 or 64 bit Microsoft Windows computer At this point, we will implement a simple example to demonstrate how to use the ArduinoIO package for interacting with an Arduino board via Simulink. In many of the examples of this tutorial we will specifically use the Arduino board to generate digital control commands (ON/OFF) to a given system (or its actuators). We will also use the Arduino board to read analog signals (voltages) from the system (or its sensors). In this simple example, we will blink a light (an LED) on and off.\n\n### Colors in MATLAB plot\n\n1. In order to return the values of colormap, ‘cmap’ command is used.Try the above example along with the following code. First create a surface plot of the peaks function and specify a colormap.\n2. Matlab Exam 2. STUDY. Flashcards. % comment; placeholder in fprintf command. addpath. adds a directory to the matlab search path\n3. MATLAB allows you to add title, labels along the x-axis and y-axis, grid lines and also to adjust the axes to spruce up the graph.\n4. Matlab code given below can also be used for excuting Romberg Integration method. Sample Matlab code: function R = romberg_mod(f,a,b,depth,tol) %f is the input string %a & b are the upper and lower..\n5. Once the Simulink model has been created, it can then be run from the drop-down menu Simulation > Run or by pressing the \"play\" button on the toolbar. The model we have created has been set to run for 10 seconds. When you run the model, you should see the LED alternately blink on and off. Double-clicking on the scope and pressing the Autoscale button on the toolbar then generates a graph like the one shown below.\n\nMatlab. Estoy haciendo unas simulaciones en un programa que devuelve los resultados como un A= fopen('C:Matlab7workA.TXT ') %la ubicacion y nombre del archivo B=fread(A); y en B queda.. [x,y] = meshgrid(0:.1:2, 0:.1:2); mesh(x, y, c(x, y, pi/4)); xlabel('Side 1'); ylabel('Side 2'); zlabel('Side 3'); title('Triangle Third Side vs. Sides Surrounding a 45^o Angle (mrg)') print -depsc InlineExamplePlot will produce the graph: Additional activities that could be performed include the following: You could read an external signal, for example from a pushbutton switch, and use that to determine when to turn the LED on or off. Alternatively, you could use a PWM signal (the Analog Output block) to vary the brightness of the LED. Finally, you could replace the LED by a capacitor in order to observe a dynamic, rather than a static, system. Such an RC circuit is examined in great detail in Activity 1 of this tutorial. Fun = inline ( ‘ x ^ 2 – 6 ’ , ’ x ’ )  . . . . . . . . . . (1)   function declaration and defination Fun = inline function : Matlab includes some of important digital video transmission models such as Digital Video Figure 1 shows block diagram of DVB-S2 model in Matlab. Each block and its functionalities are given in..\n\nMATLAB Function Reference. fliplr. Flip matrices left-right Amplitude modulation AM is a one of the conventional modulation technique to transmit signals using a carrier wave. AM can be easily generated using Matlab\n\n### MATLAB:Inline Function - PrattWik\n\n• A colormap can have upto 255 rows which shows how many values can be stored in a single byte. RBG triplet vector shows the intensities of the three basic color components. A value of 0 indicates no color and a value of 1 indicates full intensity.\n• In MATLAB, surface is defined by the Z-coordinates of points above a grid in the x–y plane. Surface plot data describes the properties that control the color in this presentation. The ‘CData’ property of the surface object contains an array ‘C’ that is associated to each grid point (on the surface) to a color in the colormap. By default, Z = C where Z is the array that contains the values of z = f(x,y) at the grid points. Hence, the colors vary when Z changes.\n• Digital iVision Labs! Divilabs will deal with, arduino, MATLab, OpenCV, and some Miscellaneous topics like javascript and web applications\n\nSimulated Annealing is one of the most famous optimization algorithms that has been also implemented in MATLAB as a built-in function. The Booth's test function is a famous test function for evaluating.. x = [0 : 0.01: 10]; y = sin(x); g = cos(x); plot(x, y, x, g, '.-'), legend('Sin(x)', 'Cos(x)') MATLAB generates the following graph − Matlab - Loop types. There may be a situation when you need to execute a block of code several times. Matlab provides various types of loops to handle looping requirements including: while loops.. Matlab has many built-in functions square root, sin, cos, tan, exponential, log, etc. It also has more complex and special mathematical functions like gamma functions and Bessel functions Matlab can read and write CSV files if they only contain numeric values. CSV files can also exported/imported in Excel, however Excel is not restricted to numeric values\n\nSome Arduino boards (for example, the Mega 2560) can be communicated with while an experiment is running using the standard Arduino Hardware Support Package by running Simulink in External Mode. Details on this support package can be found here. Note R2014a or higher is needed. >> error(sprintf('This error\\nhas a newline.')) ??? This error has a newline. disp(['abcd' char(10) 'efgh']) abcd efgh This works as well:\n\n### MATLAB Colormap Tutorial (Images): Heatmap, Lines and Example\n\n• TEX in Matlab. Aaron Biddings. Electrical and Computer Engineering Auburn University. Matlab's text interpreter must be set to handle LATEX coding. This is done by simply supplying the necessary..\n• c = Inline function: c(a,b,theta) = sqrt(a.^2+b.^2-2*a.*b.*cos(theta)) indicating that the variable c is now actually an inline function object that takes three arguments. You can now use the function by putting numbers in for the arguments - for example:\n• Matlab is a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis, and numeric computation\n• In this section, instead of doing it manually, we do it using fft() provided by Matlab. Here is the code Matlab Image and Video Processing Tutorial. Vectors and Matrices. m-Files (Scripts)\n• To create a custom colormap, you have to specify map as a three-column matrix of RGB triplets where each row defines one color. The intensities must be in the range from 0 to1.\n• us;\n\nBut when using in Matlab/Octave the command below: conv(a,b). \\$\\begingroup\\$ Yes, matlab/octave uses 1 as the initial index rather than zero. It's arbitrary as long as you are consistent The Digital Output can generate two outputs, 0 Volts or 5 Volts. In this case, 5 Volts and the amount of current the board can source is sufficient to switch the LED on. In some other activities explored in these tutorials, a digital output does not provide sufficient power to drive a given system. In those cases, we can use the low power signal from a digital output to connect and disconnect a system to a higher power source (e.g. a battery) by, for example, switching a transistor. The Arduino board will also be used to measure the voltage across the LED via an Analog Input (pin AO). Therefore, we connect a jumper wire from pin AO to the junction where the resistor and LED meet. The other end of the LED is already connected to the ground pin of the board. In this example the voltage across the LED is not very interesting, but it at least illustrates how we will feed back signals from our various systems. Matlab allows you to create symbolic math expressions. This is useful when you don't want to immediately compute an answer, or when you have a math formula to work on but don't know how.. Matlab - NaN and Inf. Introduction. If in matlab you type 1/0 you'll get. Warning: Divide by zero. (Type warning off MATLAB:divideByZero to suppress this warning.) ans = Inf In the majority of the hardware-based activities outlined within these tutorials, we will employ the ArduinoIO Package from the MathWorks for handling the interface between Simulink and our hardware. We use this package because it allows for rather transparent, real-time communication between Simulink and the Arduino Uno (and other models of Arduino board) without delving into the intricacies of serial communication. You can download the ArduinoIO Package here or from the MATLAB Central File Exchange.\n\n### Search\n\nMatlab assignment help by Anderson Silva 380 views. MATLAB Scripts - Examples by Shameer Ahmed Koya 3204 views. Matlab: Procedures And Functions. 10,166 views The functions warning, error, sprintf and fprintf will interpret '\\n' as a newline character. For example. >> error('This error\\nhas a newline.') ??? This error has a newline. Though previous versions of this wiki claimed this functionality was introduced in MATLAB 6.5 (R13), it doesn't work in 7.4.0 (2007a)\n\nMATLAB. Do you speak MATLAB When plotting in Matlab, whether it be in two or three dimensions, a number of issues involving complex numbers will arise. If you take the square root of a negative number, the result is a complex number\n\n>> error('This error\\nhas a newline.') ??? This error has a newline. Though previous versions of this wiki claimed this functionality was introduced in MATLAB 6.5 (R13), it doesn't work in 7.4.0 (2007a). The explanation that this change happened when formatted error strings were introduced in the Release Notes for that release was unhelpful. MATLAB adı, MATrix LABoratory (Matrix Laboratuarı) kelimelerinden gelir. MATLAB, ilk olarak Fortran Linpack ve Eispack projeleriyle geliştirilen ve bu programlara daha etkin ve kolay erişim sağlamak.. ROUNDN Rounds input data at specified power of 10..\n\n### User Defined Functions\n\nThis is a guide to Inline Functions in Matlab. Here we discuss Inline functions in Matlab, Syntax, and Examples. You can also go through our other related articles to learn more-When you create an array of plots in the same figure, each of these plots is called a subplot. The subplot command is used for creating subplots. subplot(m, n, p) where, m and n are the number of rows and columns of the plot array and p specifies where to put a particular plot.\n\n### Inline Functions in Matlab Guide to Inline Functions in Matlab\n\n1. g language developed by MathWorks\n2. How to make a plot in MATLAB®. Examples of the plot function, line and marker types, custom colors, and MATLAB® Plot Colors Symbols and line width. % Learn about API authentication here: https..\n3. Matlab is a really popular platform for scientific computing in the academia. I've used it my throughout my engineering degree and chances are, you will come across .mat files for datasets release\n4. MATLAB'da logaritma nasıl alınır? 2 ve 10 tabanında logaritmalar. MATLAB'da e, 2 ve 10 tabanındaki logaritmaları aşağıdaki komutlarla hesaplayabiliriz\n5. abdul = [0 0 0, %black 0 0 1, %red 0 1 0, %green 1 0 0] %blue % Define a square matrix SqMat = zeros(15,15); SqMat(7:9,7:9) = 1; SqMat(7:9,3:5) = 2; SqMat(7:9,11:13) = 3; %Display figure(1) colormap (abdul) imagesc (SqMat) Fig. 1(a)\n\nGraphing this will be hard using PLOT, since it requires that you write y on one side of the equation and x on the other side. But solving this equation will require you use some guess on the other side to replace zero to help you be able to split xy, and even then you will be plotting only one hypothesis. EZPLOT is the best of the two options for cases like this one. Wireless Communications with Matlab and Simulink: IEEE802.16 (WiMax) Physical Layer by Roberto Work Reading . MATLAB®/Simulink® Tutorials on Physical Modeling and Test-bed Setup In this first value is for x  = 1 , second value is for x =  2 , third value is for x = 3 , forth value is for  x = 4 and fifth value is for x = 5.‘CLim’ property for surface plots, patches, graphics object or any images that use a colormap can be customized. The Z values determine a surface of X and Y grid lines and fill color from a color map. However, this property has only affect on graphic objects that have the ‘CData mapping property’ set to 'scaled'. If it is set to 'direct', then all values of ‘C’ index will direct into the colormap without any scaling.\n\nHere is a quick comparison of the EZPLOT and PLOT in Matlab. We have recently separately worked with both commands in the previous posts which you can have a look at Colormap map sets the colormap for the current figure to one of the predefined colormaps. If you set the colormap for the figure, then axes and charts in the figure use the same colormap. The new colormap is the same length (number of colors) as the current colormap. When you use this syntax, you cannot specify a custom length for the colormap.To solve the above equation in Matlab, we need to create an inline function for z and need to assign one independent variable.Table of Contents Best for Beginners: LK Cokoino Self-Balancing Robot Kit  Buy on Amazon: \\$70  Buy from Cokoino: \\$65  Best Out of the Box Value: Yahboom Coding Robot Car  Buy on Amazon: \\$86  Buy from Read more… Downloaden Sie MATLAB, um komplexe numerische Berechnungen durchzuführen und grafische Darstellungen zu erzeugen. MATLAB ist eine Hoch-Leistungs-Sprache\n\n### Syntax of Inline Function\n\nRun MATLAB as an administrator (just one time for the purpose of installing the package) by right-clicking on the MATLAB icon and selecting Run as Administrator. This will allow the updated path to.. The axis command allows you to set the axis scales. You can provide minimum and maximum values for x and y axes using the axis command in the following way − MATLAB Operators - MATLAB. « Previous Topics. Matlab Data Types. MATLAB provides various functions for set operations, like union, intersection and testing for set membership, etc\n\n## Video: MATLAB - Plotting - Tutorialspoin\n\n### MATLAB Programming/Inserting Newlines into Disp Warn and Error\n\n• g environment on all Midway compute resources\n• g environment for algorithm development, data analysis, visualization and numeric computation. Simulink is a graphical..\n• Matlab Simulink , Toolbox ve Blockset uygulamaları ile bizlere elektronik devrelerimizin gerçekleştirmesini yapmamıza yardımcı olur. Simulink kütüphanesine ekleyeceğimiz Blockset ler ile..\n• The \"server\" program will run on the Arduino board in parallel with the Simulink model running on the host computer. The program runs continuously and receives commands from the Simulink model via the serial port. It then executes those commands and, if needed, returns a result. There are several versions of the program included as part of the IO package. We will, in particular, employ the sketch adioes.pde. This sketch performs analog and digital I/O (the \"adio\"), reads quadrature encoders (the \"e\"), and can interface with motors via a shield (the \"s\"). We will not employ a motor shield in the activities of this tutorial. Note that .pde is an older file extension and Arduino now uses the .ino extension.\n• Colormap is a three color matrix that specifies the red, green and blue content for graphics objects such as surface, image, and patch objects. The RGB values are triplets which means that they’re in the order of Red, Green and Blue and they can range from 0 to 1. MATLAB draws the objects by mapping data values to colors in the colormap.\n\nIn MATLAB, surface is defined by the Z-coordinates of points above a grid in the x-y plane. Surface plot data describes the properties that control the color in this presentation. The 'CData' property of.. MATLAB (abreviatura de MATrix LABoratory, «laboratorio de matrices») es un sistema de cómputo numérico que ofrece un entorno de desarrollo integrado (IDE) con un lenguaje de programación propio (lenguaje M). Está disponible para las plataformas Unix, Windows, macOS y GNU/Linux Function name = inline ( vectorize( ‘ function string ’ ) , ’ independent variable ’ ) Y = inline ( vectorize ( ‘ x ^ 2 – 1 ’ ) , ’ x ’ )2. Function Evolution: In this, we evaluate function by giving any value to the independent variable.\n\n### Content you might like:\n\nIntroduction to Matrices in Matlab¶. A basic introduction to defining and manipulating matrices is given here. It is assumed that you know the basics on how to define and manipulate vectors.. Tutorial45.com is a list of tutorials and great technologies by Andreea Georgiana, Aris Tchoukoualeu and friends.EZPLOT is an easy to use function plotter. Compared to PLOT, it is a hassle-free-plotter. All  you need to do to use it is to state the function you would like to plot, and it does the rest of the job.The following instructions are needed to upload the adioes.pde file into the Arduino board's flash memory. As long as no other file is uploaded later, this step does not need to be repeated and the IO package can be used as soon as the board is connected to the host computer.\n\nEach plot created with the subplot command can have its own characteristics. Following example demonstrates the concept − MATLAB allows you to display your plots however you choose. Here are three plots — one on top To make this happen, you use the subplots feature of MATLAB. A subplot is simply a plot that takes up..\n\nAC MATLAB Lab Programs - Free download as Word Doc (.doc / .docx), PDF File (.pdf), Text File (.txt) or read online for free. ANURAG ENGINEERING COLLEGE 1. Generation of Amplitude Modulation.. Kalo itu saya lakukan secara manual jelas bukan hal yang efisien. Matlab memberikan solusi yang mudah dengan menggunakan fugsi plot MATLAB 逻辑运算. MATLAB 关系运算 How do I print (output) in Matlab? There are three common way x = [0 : 0.01: 10]; y = exp(-x).* sin(2*x + 3); plot(x, y), axis([0 10 -1 1]) When you run the file, MATLAB generates the following graph −\n\n### EZPLOT vs PLOT in Matlab - Tutorial4\n\n1. MATLAB is a high-level language and interactive environment that enables you to perform computationa... If you need to access MATLAB and your data remotely, there are options available\n2. apm install linter-matlab. If mlint is not already in your PATH, you will need to set the mlintDir setting to point to the directory containing mlint. As noticed by @hyiltiz, this currently does not work with..\n3. A MATLAB function must be saved in a text file with a .m extension. The name of that file must be the same as the function defined inside it. The name must start with a letter and cannot contain spaces\n4. BER Analysis Using Matlab®/OptiSystem Automation. This example demonstrates the use of Matlab® software to call OptiSystem and calculate the bit error rate after the OptiSystem simulation\n5. In order to prepare Matlab figures for publication, some modifications should be made to the figures. In the following, I will explain the main steps I usually take. I know, there are probably thousands of..\n6. Hi, I've been having some difficulty with Matlab. I keep getting confused with the indexing and the loops. To set up the code, I am trying to implement..\n7. Matlab Examples. A VAR identified with short-run restrictions. This example shows how to compute IRFs, HDs, and FEVDs in a VAR with data for inflation, unemployment, and interest rates using the..\n\nThe circuit for this simple example consists of a resistor in series with an LED. The resistor is necessary to limit the current because otherwise the LED can burn out. An LED is a light emitting diode and, just like any diode, it passes current in only one direction (from the anode to the cathode). The LED \"lights up\" when activated. La funzione disp (X) mostra un array, senza stampare il suo nome. Se X contiene una stringa di testo, la stringa viene visualizzata. Un altro modo in matlab per visualizzare una matrice sullo schermo è.. MATLAB has a command that lets you develop an analytical expression of one or more inputs and assign that expression to a variable. The inline command lets you create a function of any number of variables by giving a string containing the function followed by a series of strings denoting the order of the input variables. This method is good for relatively simple functions that will not be used that often and that can be written in a single expression. It is similar to creating an MATLAB:Anonymous Function with some significant differences.\n\n### Conditional Plotting in Matlab\n\nTutorial belajar MATLAB untuk pemula, operasi matriks, script file, programming, function, numerik, grafik, toolbox, dan lainnya [cindx,cimap,clim] = shaderel(X,Y,Z,cmap) generates the colormap and color indices which allows a surface to be displayed in colored shaded relief. The colors are proportional to the magnitude of Z but lie in the shades of gray based on the surface normals to simulate surface lighting. This representation allows both large and small-scale differences to be seen. X, Y, and Z define the surface. I am trying to use transfer functions with symbolic values but I only returns errors. Is there a way to work with Laplace transformed in symbolic mode with MatLab? Here an example that I am trying to do and.. MATLAB news, code tips and tricks, questions, and discussion! We are here to help, but won't do your homework or help you pirate software. The effort you put into asking a question is often matched by..\n\nMATLAB provides eight basic color options for drawing graphs. The following table shows the colors and their codes − The following table describes the values that flag can assume and lists the corresponding Level-2 MATLAB S-function method for each value Take an example, consider the surface Z = X + Y and the limit condition is:map = [0.2 0.1 0.5 0.1 0.5 0.8 0.2 0.7 0.6 0.8 0.7 0.3 0.9 1 0]; surf(peaks) colormap(map) Fig. 2(a) SideThree = 1.6148 You can also use that function to return entire matrices. For example, the commands:\n\n### GitHub - kwikteam/npy-matlab: Experimental code to read/write\n\n1. This MATLAB function returns a linear approximation of the nonlinear Simulink model mdl at the model operating point using the analysis points specified in io\n2. Search the matlab package. Vignettes. fix: MATLAB fix function. fliplr: MATLAB matrix flip functions\n3. Hello, I am working on 8 bit analog to digital converter and beginner in matlab I swept dc input from for vin = 0 : dv :3 save_input(i)= vin; then ADC function is called which returns output code in array Vdout..\n4. Aprende a Graficar con MATLAB en 2D de un forma simple y fácil. Aprende los trucos para dejar tus gráficas mejor presentadas y más bonitas\n5. From the Arduino IDE toolbar menu, select File > Open and locate the file adioes.pde (in the ArduinoIO/pde/adioes folder) and open it. Next connect the Arduino board and make sure that the correct board and serial port are selected in the IDE (check menus Tools/Board: and Tool/Port:), then select File > Upload and wait for the \"Done Uploading\" message.\n6. Once you download and unzip the ArduinoIO package, you can start by taking a look at the included readme file. We will repeat some elements of the instructions here, but the readme file includes more detail.\n\n## Matlab - Symbolic Mat\n\nIn this post, we will learn basic command in image processing using Matlab. One of the command is imadd. Image addition will give power to superimpose or overlay an image on top of another or control.. disp(['abcd', 10, 'efgh']) abcd efgh In MATLAB versions 2016b and newer the function NEWLINE is recommended instead, for code clarity\n\nA simple matlab function for computing the coefficients of a Lagrange fractional-delay FIR filter is as follow MATLAB Function Reference. fplot. Plot a function between specified limits. This example passes function handles to fplot, one created from a MATLAB function and the other created from an..\n\n## MATLAB - Wikipedia, la enciclopedia libr\n\nMATLAB de Mathworks es un programa de software para matemáticas e ingeniería diseñado para desarrollar cálculos avanzados y simulaciones. Para muchos cálculos, es muy útil al trabajar con.. [php]y=ezplot(‘(2*x+1)/(x-3)’) set(y,’Color’,’b’,’LineWidth’,2) % Make the line blue and the linewidth 2[/php]\n\nMathwork's MATLAB is installed and supported at TACC and is available on the following TACC resources: Frontera, Stampede2, Lonestar5, and Maverick2 Non linear model is linearized in MATLAB (simulink ). Observer design in Matlab simulink - Продолжительность: 12:17 Hamid Ali 15 329 просмотров Interactive introduction to multi-way analysis in MATLAB Next Chapter: Advanced PARAFAC Prerequisites: Be sure to understand the basics of handling multi-way arrays in MATLAB (Chapter 1).. x1 = subplot(2,1,1); contourf(peaks) colormap(x1,hot(8)) x2 = subplot(2,1,2); contourf(peaks) colormap(x2,pink) cmap = colormap(x1) Fig. 4(b)Abdul Mannan is an Electrical Power Engineer with specialization in High Voltage. He's the founder and former president at Youth Entrepreneurship Society (YES), University of Engineering & Technology Taxila Campus. He is the leading contributor at \"Right to Write\". Connect with him about Entrepreneurship, startup ideas, creative writing, business strategies via linked in.\n\n## How to write a MATLAB code to find auto-correlation without - Quor\n\nZ = inline ( vectorize ( ' x .^3 + 23*x – 9 ' ) ,' x ' ) z = Inline function : Z ( x )  = x . ^ 3 + 23 * x - 9 >>  z ( 1 : 10 )Table of Contents Elegoo Uno R3 Smart Robot Car Price on Amazon: \\$59.99 Keyestudio TS – 50 Mini Bluetooth Arduino tank robot car kit Price on Amazon: \\$49.99 UCTRONICS Smart bluetooth Arduino Robotic car kit Read more…Here is a quick comparison of the EZPLOT and PLOT in Matlab. We have recently separately worked with both commands in the previous posts which you can have a look at.Function name = inline ( ‘ function ’ , ’ independent variable ’ ) Fun = inline ( ‘ x ^ 2 – 5 ’ , ’ x ’ )\n\nThe default colors used in MATLAB changed in R2014b version. Thus knowing the MATLAB RGB triples for the colors can be useful. From the table above, we can define the default colors to work with.. In MATLAB (and other programming languages) a convenient shorthand for this is 1.4e6. By default, MATLAB displays 5 decimal digits, unless the number is too big or too small, when it switches to.. Matlab allows you to create symbolic math expressions. This is useful when you don't want to immediately compute an answer, or when you have a math formula to work on but don't know how..\n\n..Matlab intern Release-Fragen Sonstige MATLAB Fragen Bugs MATLAB Simulink / Stateflow erzeugt ein falsches Intervall, nämlich nur die Werte 0 und 5. Dezimaltrennzeichen in Matlab ist der.. Therefore, the example circuit can be created by connecting one end of your resistor to digital pin 8. The other end of the resistor is then connected to the longer leg of the LED. This can be achieved by placing the longer leg of the LED and the free end of the resistor in the same row of the breadboard. The shorter end of the LED is then connected to the ground pin of the Arduino board. MATLAB - Plotting - To plot the graph of a function, you need to take the following steps −. MATLAB allows you to add title, labels along the x-axis and y-axis, grid lines and also to adjust the axes to.. MATLAB YouTube channels list is ranked by popularity based on total channels subscribers, video views, video uploads, quality & consistency of videos uploaded MVA offers MATLAB Simulink online certification training, MATLAB Simulink training consists of creating external interface to the real world\n\nMATLAB‟de 2 boyutlu (2D) grafik çizebilmek için plot komutu. kullanılır. plot komutunun açtığı yeni grafik penceresi üzerinde. grafiğiniz ile ilgili değişiklikler yapabilir ve hatta grafiğinizi farklı Matlab/Simulink For Digital Communication book. Read 5 reviews from the world's largest community for readers. Start by marking Matlab/Simulink For Digital Communication as Want to Rea\n\nIf you proceed to open Simulink, you will see the Library now includes the Arduino IO Library shown below. These blocks are used for interfacing with the physical Arduino board. For example, to read a sensor via an Analog Input or to switch an actuator on via a Digital Output. MATLAB For Beginners: 20-Minute Video Training Course. (Grab The Training Course and The Cheat Sheet for FREE). This article explains the key points of manipulating MATLAB matrices when starting Learn with MATLAB and Simulink tutorials. MATLAB is a high-level language and interactive environment used by millions of engineers and scientists worldwide\n\n## MATLAB - Wikipedi\n\nMatlab has many built-in functions square root, sin, cos, tan, exponential, log, etc.  It also has more complex and special mathematical functions like gamma functions and Bessel functions. It also has some built-in constants pi, I (complex numbers) and infinity. Plotting in Matlab Page 1. Table of Contents. • Basic Overview o Syntax o Labeling Axes o Legends. To use the 'plot' function in Matlab, you should first make sure that the matrices/vectors you are trying..\n\nWhere can I find the MATLAB implementation of the watershed segmentation algorithm? I am aware of the built-in function but I need to write th.. x = [0:0.01:5]; y = exp(-1.5*x).*sin(10*x); subplot(1,2,1) plot(x,y), xlabel('x'),ylabel('exp(–1.5x)*sin(10x)'),axis([0 5 -1 1]) y = exp(-2*x).*sin(10*x); subplot(1,2,2) plot(x,y),xlabel('x'),ylabel('exp(–2x)*sin(10x)'),axis([0 5 -1 1]) When you run the file, MATLAB generates the following graph −The Arduino Analog Read block reads the output voltage data via the Analog Input A0 on the board. Double-clicking on the block allows us to set the Pin to 0 from the drop-down menu. We also set the Sample Time again to \"0.1\". The given Simulink model then plots the recorded data (the voltage across the LED) via a Scope block. Even if the range you choose is different than the range of your data, it is possible to perform the mapping over for any range you choose. Default mapping is mostly used in different cases .Choosing a different mapping range allows you:\n\nAs shown, the input voltage command is generated by a Pulse Generator block. This block generates values of 0 or 1 which are then fed to an Arduino Digital Write block. Double-clicking on the Pulse Generator block you can set Sample Time to \"0.1\" seconds. We will further set the block so that it switches its output between its two states every 1 second (every 10 samples). Since we are using channel 8 for the digital output, we double-click on the Arduino Digital Write block to set the Pin to 8 from the drop-down menu. We will let the sample time for the block be inherited from the Pulse Generator block. An input of 0 to the Digital Write block causes an output of 0 Volts to be generated at the corresponding pin, while an input of 1 to the Digital Write block generates an output of 5 Volts. Matlab: Fibonacci number? I need to modify the file below so it calculates the first 20 Fibonacci i do no longer understand MATLAB so i can't show you how to with the extremely software, yet it.. Define x, by specifying the range of values for the variable x, for which the function is to be plotted\n\n• Volvo v70 kilometrit.\n• Depressio päiväkirja kirja.\n• New balance 1080 v6.\n• Aj keskinen voice of finland.\n• Kokkola caravan.\n• Milloin ruusut kellarista.\n• Markkinointi ja mainonta lehti.\n• Laki naisten ja miesten välisestä tasa arvosta englanniksi.\n• Aurinko nousee kls.\n• Tuhat loistavaa aurinkoa lukupäiväkirja.\n• Auton hitsaustyöt.\n• Buddhalaisuus länsimaissa.\n• Potilashuoneen siivous.\n• Schaub lorenz retro jääkaappi pakastin.\n• Käytetyt veneet pohjois karjala.\n• Fazer domino viking line.\n• Biltema vilkkurele.\n• Tuulivoima.\n• Öljynporauslautta norja.\n• Infernal ashes osrs.\n• Wiccan protection symbol.\n• Ensimmäinen lumilauta.\n• Im heidkamp 3 gütersloh.\n• Pyynikin näkötorni koira.\n• Suomen paras tennispelaaja.\n• Tanska asevelvollisuus.\n• Raaseporin keskiaikamarkkinat 2018.\n• Maaliskuun sää.\n• Huawei mate 10 pro camera test.\n• Raiski drymaxx takki.\n• Euphorbia tirucalli.\n• Ensitreffit alttarilla 2017 mari.\n• Silja line hevisaurus.\n• Kun lapsi sairastuu vakavasti.\n• Gap for gimp 2.8 mac.\n• Kartonki tupakkaa suomessa.\n• Swift spectral tiger card.\n• Atari 2600 pelit." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.82340854,"math_prob":0.8331921,"size":30483,"snap":"2021-04-2021-17","text_gpt3_token_len":7005,"char_repetition_ratio":0.13068014,"word_repetition_ratio":0.060982715,"special_character_ratio":0.2265197,"punctuation_ratio":0.11911126,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9939168,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-21T18:18:11Z\",\"WARC-Record-ID\":\"<urn:uuid:09168c95-87dc-4455-afb4-3f7383bbf080>\",\"Content-Length\":\"50646\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c3cb40f1-4d4e-4247-a5cc-0cf0cd226df1>\",\"WARC-Concurrent-To\":\"<urn:uuid:95306c8b-66b4-46c8-ad2e-5647efc62bb1>\",\"WARC-IP-Address\":\"5.61.58.33\",\"WARC-Target-URI\":\"https://kennt-allein.com/book/show/6811772-matlab-simulink-for-digital-communicatioy6zvta21874rp-\",\"WARC-Payload-Digest\":\"sha1:TH6TACYBH4RDTRU235HXXKAW2EXG3YCB\",\"WARC-Block-Digest\":\"sha1:WYEQSVMU5CISE4KSWYUEVND2FSERZLIP\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703527224.75_warc_CC-MAIN-20210121163356-20210121193356-00126.warc.gz\"}"}
https://www.yatex.org/gitbucket/yuuji/yatex/blob/febcf27f47b7cd918cea5d0f99a73b6c37817e19/yatex.el
[ "Older\nyatex / yatex.el", null, "HIROSE Yuuji on 10 Sep 2017 116 KB Legacy local variable settings removed\n;;; yatex.el --- Yet Another tex-mode for emacs //野鳥// -*- coding: sjis -*-\n;;; (c)1991-2017 by HIROSE Yuuji.[[email protected]]\n;;; $Id$\n;;; http://www.yatex.org/\n\n;;; Code:\n(require 'comment)\n(require 'yatexlib)\n(defconst YaTeX-revision-number \"1.79.4\"\n\"Revision number of running yatex.el\")\n\n;---------- Local variables ----------\n(defvar YaTeX-prefix \"\\C-c\"\n\"*Prefix key to call YaTeX functions.\nYou can select favorite prefix key by setq in your ~/.emacs.\")\n\n(defvar YaTeX-environment-indent 1\n\"*Indentation depth at column width in LaTeX environments.\")\n\n(defvar YaTeX-fill-prefix nil\n\"*fill-prefix used for auto-fill-mode.\nThe default value is nil.\")\n\n(defvar YaTeX-fill-column 72\n\"*fill-column used for auto-fill-mode.\")\n\n(defvar YaTeX-comment-prefix \"%\"\n\"TeX comment prefix.\")\n\n(defvar YaTeX-current-position-register ?3\n\"*Position register to keep where the last completion was done.\nAll of YaTeX completing input store the current position into\nthe register YaTeX-current-position-register. So every time you\nmake a trip to any other part of text other than you are writing, you can\nYaTeX-current-position-register.\")\n\n(defvar YaTeX-use-LaTeX2e t \"*Use LaTeX2e or not. Nil means latex 2.09\")\n\n(defvar tex-command\n(cond\n(YaTeX-use-LaTeX2e \"platex\")\n(YaTeX-japan \"jlatex\")\n(t \"latex\"))\n\"*Default command for typesetting LaTeX text.\nOverridden with %#! CommandLine...' in the buffer.\")\n\n(defvar bibtex-command (if YaTeX-japan \"jbibtex\" \"bibtex\")\n\"*Default command of BibTeX.\nOverridden with %#BIBTEX CommandLine...' in the buffer.\")\n\n(defvar dvi2-command\t\t;previewer command for your site\n(cond (YaTeX-dos\t\"dviout -wait=0\")\n(YaTeX-macos\t\"open -a Preview\")\n(t\t\t\"xdvi -geo +0+0 -s 4\"))\n\"*Default previewer command including its option.\nOverridden with %#PREVIEW CommandLine...' in the buffer.\")\n\n(defvar YaTeX-cmd-gimp \"gimp\")\n(defvar YaTeX-cmd-tgif \"tgif\")\n(defvar YaTeX-cmd-inkscape \"inkscape\")\n(defvar YaTeX-cmd-dia \"dia\")\n(defvar YaTeX-cmd-ooo \"soffice\")\n(defvar YaTeX-cmd-gs \"gs\")\n(defvar YaTeX-cmd-dvips\n(if (YaTeX-executable-find \"pdvips\") \"pdvips\" \"dvips\"))\n(defvar YaTeX-cmd-displayline\n\"/Applications/Skim.app/Contents/SharedSupport/displayline\")\n(defvar YaTeX-cmd-edit-ps YaTeX-cmd-gimp)\n(defvar YaTeX-cmd-edit-pdf YaTeX-cmd-ooo)\n(defvar YaTeX-cmd-edit-ai YaTeX-cmd-inkscape)\n(defvar YaTeX-cmd-edit-svg YaTeX-cmd-inkscape)\n(defvar YaTeX-cmd-edit-images YaTeX-cmd-gimp)\n(defvar YaTeX-cmd-view-images \"display -geometry +0+0\")\n\n(defvar tex-pdfview-command\t;previewer command for your site\n(cond\n(YaTeX-macos\t(cond\n((file-executable-p YaTeX-cmd-displayline) \"open -a Skim\")\n(t \"open\")))\n(t\t\t\"evince\"))\n\"*Default PDF viewer command including its option.\nOverridden with %#PDFVIEW CommandLine...' in the buffer.\")\n\n(defvar makeindex-command (if YaTeX-dos \"makeind\" \"makeindex\")\n\"*Default makeindex command.\nOverridden with %#MAKEINDEX CommandLine...' in the buffer.\")\n\n(defvar dviprint-command-format\n(if YaTeX-dos \"dviprt %s %f%t\"\n\"dvi2ps %f %t %s | lpr\")\n\"*Command line string to print out current file.\nOverridden with %#LPR CommandLine...' in the buffer.\nFormat string %s will be replaced by the filename. Do not forget to\nspecify the from usage' and to usage' with their option by format string\n%f and %t.\n\n(defvar dviprint-from-format\n(if YaTeX-dos \"%b-\" \"-f %b\")\n\"*From' page format of dvi filter. %b will turn to beginning page number.\")\n\n(defvar dviprint-to-format\n(if YaTeX-dos \"%e\" \"-t %e\")\n\"*To' page format of dvi filter. %e will turn to end page number.\")\n\n(defvar YaTeX-dvipdf-command\n\"dvipdfmx\"\n\"*Command name to convert dvi file to PDF.\nOverridden with %#DVIPDF CommandLine...' in the buffer.\")\n\n(defvar YaTeX-default-document-style\n(concat (if YaTeX-japan \"js\") \"article\")\n\"*Default LaTeX Documentstyle for YaTeX-typeset-region.\")\n\n(defvar YaTeX-need-nonstop nil\n\"*T for adding \\\\nonstopmode{}' to text before invoking latex command.\")\n\n(defvar latex-warning-regexp \"line.* [0-9]*\"\n\"*Regular expression of line number of warning message by latex command.\")\n\n(defvar latex-error-regexp \"l\\\\.[1-9][0-9]*\"\n\"*Regular expression of line number of latex error.\nPerhaps your latex command stops at this error message with line number of\nLaTeX source text.\")\n\n(defvar latex-dos-emergency-message\n\"Emergency stop\" ;<- for Micro tex, ASCII-pTeX 1.6\n\"Message pattern of emergency stop of typesetting.\nBecause Demacs (GNU Emacs on DOS) cannot have concurrent process, the\nlatex command which is stopping on a LaTeX error, is terminated by Demacs.\nMany latex command on DOS display some messages when it is terminated by\nother process, user or OS. Define to this variable a message string of your\nlatex command on DOS shown at abnormal termination.\nRemember Demacs's call-process function is not oriented for interactive\nprocess.\")\n\n(defvar NTT-jTeX nil\n\"*T for using NTT-jTeX for latex command.\nMore precisely, setting t to this variables inhibits inter-word break on\ntypeset document by line-break of source text. That is, YaTeX automatically\nput % after each line at filling.\n\ntにする(古いNTT-jTeXで顕著に現れる)。具体的には、fillするときに各行の終わりに\n%を付加する。\")\n\n(defvar YaTeX-item-regexp\n(concat (regexp-quote \"\\\\\") \"\\$$sub\\\\|bib\\$$*item\")\n\"*Regular expression of item command.\")\n\n(defvar YaTeX-sectioning-regexp\n\"\\$$part\\\\|chapter\\\\*?\\\\|\\\\(sub\\$$*\\$$section\\\\|paragraph\\$$\\\\)\\$$\\\\*\\\\|\\\\b\\$$\"\n\"*LaTeX sectioning commands regexp.\")\n\n(defvar YaTeX-paragraph-start\n(concat \"^[ \\t]*%\\\\|^[ \\t]*$\\\\|\\\\'\\\\|^\\C-l\\\\|\\\\\\\\\\\\\\\\$\\\\|^[ \\t]*\\\\\\\\\\$$\" YaTeX-sectioning-regexp ;sectioning commands \"\\\\|[A-z]*item\\\\|begin{\\\\|end{\" ;special declaration \"\\\\|\\$\\\\|\\$\" \"\\\\|newpage\\\\b\\\\|vspace\\\\b\" \"\\$$\")\n\"*Paragraph starting regexp of common LaTeX source. Use this value\nfor YaTeX-uncomment-paragraph.\")\n\n(defvar YaTeX-paragraph-separate\n(concat \"^[ \\t]*%\\\\|^[ \\t]*$\\\\|^\\C-l\\\\|\\\\\\\\\\\\\\\\$\\\\|^[ \\t]*\\\\\\\\\\$$\" YaTeX-sectioning-regexp ;sectioning commands \"\\\\|begin{\\\\|end{\" ;special declaration \"\\\\|\\$\\\\|\\$\" \"\\\\|newpage\\\\b\\\\|vspace\\\\b\" \"\\$$\")\n\"*Paragraph delimiter regexp of common LaTeX source. Use this value\nfor YaTeX-uncomment-paragraph.\")\n\n(defvar YaTeX-verbatim-environments\n'(\"verbatim\" \"verbatim*\" \"alltt\")\n\"*Assume these environments of this variable disable LaTeX commands.\")\n(defvar YaTeX-verb-regexp \"verb\\\\*?\\\\|path\"\n\"*Regexp of verb family. Do not contain preceding \\\\\\\\ nor \\$$\\$$.\")\n(defvar YaTeX-fill-inhibit-environments\n(append '(\"tabular\" \"tabular*\" \"array\" \"picture\" \"eqnarray\" \"eqnarray*\"\n\"longtable\"\n\"equation\" \"equation*\" \"math\" \"displaymath\")\nYaTeX-verbatim-environments)\n\"*In these environments, YaTeX inhibits fill-paragraph from formatting.\nDefine those environments as a form of list.\")\n\n(defvar YaTeX-itemizing-env-regexp\n\"itemize\\\\|enumerate\\\\|description\\\\|list\\\\|thebibliography\"\n\"*Regexp of itemizing environments\")\n(defvar YaTeX-equation-env-regexp\n\"array\\\\*?\\\\|equation\\\\*?\"\n\"*Regexp of environments for equations\")\n(defvar YaTeX-array-env-regexp\n(concat\n\"array\\\\*?\\\\|eqnarray\\\\*?\\\\|tabbing\\\\|tabular\\\\*?\\\\|\"\t;LaTeX\n\"longtable\\\\|\"\t\t\t\t\t\t;LaTeX2e\n\"matrix\\\\|pmatrix\\\\|bmatrix\\\\|vmatrix\\\\|Vmatrix\\\\|\"\t\t;AMS-LaTeX\n\"align\\\\*?\\\\|split\\\\*?\\\\|aligned\\\\*?\\\\|alignat\\\\*?\\\\|\"\t;AMS-LaTeX\n\"[bpvV]?matrix\\\\|smallmatrix\\\\|cases\\\\|\"\t\t\t;AMS-LaTeX\n\"xalignat\\\\*?\\\\|xxalignat\\\\*?\")\t\t\t\t;AMS-LaTeX\n\"*Regexp of environments where &' becomes field delimiter.\")\n(defvar YaTeX-uncomment-once t\n\"*T for removing all continuous commenting character(%).\nNil for removing only one commenting character at the beginning-of-line.\")\n\n(defvar YaTeX-close-paren-always t\n\"*Close parenthesis always when YaTeX-modify-mode is nil.\")\n\n(defvar YaTeX-greek-by-maketitle-completion nil\n\"*T for greek letters completion by maketitle-type completion.\")\n\n(defvar YaTeX-auto-math-mode t\n\"*T for changing YaTeX-math mode automatically.\")\n(defvar YaTeX-use-AMS-LaTeX t\n\"*T for using AMS-LaTeX\")\n\n(defvar yatex-mode-hook nil\n\"*List of functions to be called at the end of yatex-mode initializations.\")\n\n(defvar YaTeX-search-file-from-top-directory t\n\"*Non-nil means to search input-files from the directory where main file exists.\")\n\n(defvar YaTeX-use-font-lock (and (featurep 'font-lock)\n(fboundp 'x-color-values)\n(fboundp 'font-lock-fontify-region))\n\"*Use font-lock to fontify buffer or not.\")\n\n(defvar YaTeX-use-hilit19 (and (featurep 'hilit19) (fboundp 'x-color-values)\n(fboundp 'hilit-translate)\n(not YaTeX-use-font-lock))\n\"*Use hilit19 to highlight buffer or not.\")\n\n(defvar YaTeX-tabular-indentation 4\n\"*Indentation column-depth of continueing line in tabular environment.\")\n\n(defvar YaTeX-electric-indent-mode -1\n\"*(for Emacs 24.4+) Pass this value to electric-indent-local-mode.\n-1 means off'.\")\n\n;;-- Math mode values --\n\n(defvar YaTeX-math-key-list-default\n'((\";\" . YaTeX-math-sign-alist)\n(\":\" . YaTeX-greek-key-alist))\n\"Default key sequence to invoke math-mode's image completion.\")\n\n(defvar YaTeX-math-key-list-private nil\n\"*User defined alist, math-mode-prefix vs completion alist.\")\n\n(defvar YaTeX-math-key-list\n(append YaTeX-math-key-list-private YaTeX-math-key-list-default)\n\"Key sequence to invoke math-mode's image completion.\")\n\n\"Non-nil skips default argument reader of section-type completion.\")\n\n(defvar YaTeX-simple-messages nil\n\"Non-nil makes minibuffer messages simpler.\")\n\n(defvar YaTeX-template-file \"~/work/template.tex\"\n\"*Template TeX source file. This will be inserted to empty file.\")\n\n(defvar yatex-mode-abbrev-table nil\n\"*Abbrev table in use in yatex-mode buffers.\")\n(define-abbrev-table 'yatex-mode-abbrev-table ())\n\n;------------ Completion table ------------\n; Set tex-section-like command possible completion\n(defvar section-table\n(append\n'((\"part\") (\"chapter\") (\"chapter*\") (\"section\") (\"section*\")\n(\"subsection\") (\"subsection*\")\n(\"subsubsection\") (\"paragraph\") (\"subparagraph\")\n(\"author\") (\"thanks\") (\"documentstyle\") (\"pagestyle\") (\"thispagestyle\")\n(\"title\") (\"underline\") (\"label\") (\"makebox\")\n(\"footnote\") (\"footnotetext\") (\"index\")\n(\"hspace*\") (\"vspace*\") (\"bibliography\") (\"bibitem\") (\"cite\")\n(\"input\") (\"include\") (\"includeonly\") (\"mbox\") (\"hbox\") (\"caption\")\n(\"arabic\") (\"cetering\") (\"uline\")\n(\"newcounter\")\n(\"newlength\") (\"setlength\" 2) (\"addtolength\" 2) (\"settowidth\" 2)\n(\"setcounter\" 2) (\"addtocounter\" 2) (\"stepcounter\" 2)\n(\"newcommand\" 2) (\"renewcommand\" 2)\n(\"newenvironment\" 3) (\"newtheorem\" 2)\n(\"cline\") (\"framebox\") (\"savebox\" 2) (\"sbox\" 2) (\"newsavebox\") (\"usebox\")\n(\"date\") (\"put\") (\"ref\") (\"pageref\") (\"tabref\") (\"figref\") (\"raisebox\" 2)\n(\"multicolumn\" 3) (\"shortstack\") (\"parbox\" 2)\n;; for mathmode accent\n(\"tilde\") (\"hat\") (\"check\") (\"bar\") (\"dot\") (\"ddot\") (\"vec\")\n(\"widetilde\") (\"widehat\") (\"overline\") (\"overrightarrow\")\n;; section types in mathmode\n(\"frac\" 2) (\"sqrt\") (\"mathrm\") (\"mathbf\") (\"mathit\") (\"mathbb\")\n(\"mathscr\") (\"mathrsfs\")\n;;cleveref\n(\"cref\") (\"crefrange\") (\"cpageref\") (\"labelcref\") (\"labelcpageref\")\n;; beamer\n(\"frametitle\") (\"framesubtitle\")\n)\n(if YaTeX-use-LaTeX2e\n'((\"documentclass\") (\"usepackage\")\n(\"textbf\") (\"textgt\") (\"textit\") (\"textmc\") (\"textmd\") (\"textnormal\")\n(\"textrm\") (\"textsc\") (\"textsf\") (\"textsl\") (\"texttt\") (\"textup\")\n(\"mathbf\") (\"mathcal\") (\"mathit\") (\"mathnormal\") (\"mathrm\")\n(\"mathsf\") (\"mathtt\") (\"text\")\n(\"textcircled\")\n(\"scalebox\" 1) ;is faking of argument position\n(\"rotatebox\" 2) (\"resizebox\" 3) (\"reflectbox\")\n(\"colorbox\" 2) (\"fcolorbox\" 3) (\"textcolor\" 2) (\"color\") (\"pagecolor\")\n(\"includegraphics\") (\"includegraphics*\")\n(\"bou\")\t\t\t;defined in plext\n(\"url\")\t\t\t;defined in url\n(\"fancyoval\")\t\t\t;defined in fancybox\n(\"bm\")\t\t\t\t;deined in bm\n(\"verbfile\") (\"listing\")\t;defined in misc\n(\"slashbox\" 2) (\"backslashbox\" 2) ;defined in slashbox\n))\n(if YaTeX-use-AMS-LaTeX\n'((\"DeclareMathOperator\" 2) (\"boldsymbol\") (\"pmb\") (\"eqref\")\n(\"tag\") (\"tag*\"))))\n\"Default completion table for section-type completion.\")\n\n(defvar user-section-table nil)\n(defvar tmp-section-table nil)\n(defvar YaTeX-ams-math-begin-alist\n'((\"align\") (\"align*\") (\"multline\") (\"multline*\") (\"gather\") (\"gather*\")\n(\"alignat\") (\"alignat*\") (\"xalignat\") (\"xalignat*\")\n(\"xxalignat\") (\"xxalignat*\") (\"flalign\") (\"flalign*\") (\"equation*\")))\n(defvar YaTeX-ams-math-gathering-alist\n'((\"matrix\") (\"pmatrix\") (\"bmatrix\") (\"Bmatrix\") (\"vmatrix\") (\"Vmatrix\")\n(\"split\") (\"split*\") (\"aligned\") (\"aligned*\") (\"alignedat\") (\"gathered\")\n(\"smallmatrix\") (\"cases\") (\"subequations\")))\n;; Prepare list(not alist) for YaTeX::ref in yatexadd.el\n(defvar YaTeX-math-other-env-alist-default\n'((\"numcases\") (\"subnumcases\"))\n\"Default alist of additional environments for equations\")\n(defvar YaTeX-math-other-env-alist-private nil\n\"*User defined alist of additional environments for equations\")\n(defvar YaTeX-math-other-env-alist\n(append YaTeX-math-other-env-alist-default\nYaTeX-math-other-env-alist-private)\n\"Alist of additional environments for equations\")\n(defvar YaTeX-math-other-env-list\n(mapcar 'car YaTeX-math-other-env-alist))\n\n(defvar YaTeX-math-begin-list\n(mapcar 'car YaTeX-ams-math-begin-alist))\n(mapcar 'car YaTeX-ams-math-gathering-alist))\n\n(defvar YaTeX-ams-env-table\n(append YaTeX-ams-math-begin-alist YaTeX-ams-math-gathering-alist)\n\"*Standard AMS-LaTeX(2e) environment completion table.\")\n\n; Set tex-environment possible completion\n(defvar env-table\n(append\n'((\"quote\") (\"quotation\") (\"center\") (\"verse\") (\"document\")\n(\"verbatim\") (\"itemize\") (\"enumerate\") (\"description\")\n(\"list\") (\"tabular\") (\"tabular*\") (\"table\") (\"tabbing\") (\"titlepage\")\n(\"sloppypar\") (\"picture\") (\"displaymath\")\n(\"eqnarray\") (\"eqnarray*\") (\"figure\") (\"equation\") (\"equation*\")\n(\"abstract\") (\"array\")\n(\"thebibliography\") (\"theindex\") (\"flushleft\") (\"flushright\")\n(\"minipage\")\n(\"supertabular\")\n(\"wrapfigure\") (\"wraptable\")\n(\"frame\") (\"block\") (\"example\") (\"columns\") (\"column\")\t;beamer\n)\n(if YaTeX-use-LaTeX2e\n'((\"comment\")\t\t\t;defined in version\n(\"longtable\")\t\t\t;defined in longtable\n(\"screen\") (\"boxnote\") (\"shadebox\") ;; (\"itembox\") ;in ascmac\n(\"alltt\")\t\t\t;defined in alltt\n(\"multicols\")\t\t\t;defined in multicol\n(\"breakbox\")))\t\t\t;defined in eclbkbox\n(if YaTeX-use-AMS-LaTeX YaTeX-ams-env-table)\nYaTeX-math-other-env-alist)\n\"Default completion table for begin-type completion.\")\n\n(defvar user-env-table nil)\n(defvar tmp-env-table nil)\n\n; Set {\\Large }-like completion\n(defvar fontsize-table\n'((\"rm\") (\"em\") (\"bf\") (\"boldmath\") (\"it\") (\"sl\") (\"sf\") (\"sc\") (\"tt\")\n(\"dg\") (\"dm\")\n(\"tiny\") (\"scriptsize\") (\"footnotesize\") (\"small\")(\"normalsize\")\n(\"large\") (\"Large\") (\"LARGE\") (\"huge\") (\"Huge\")\n(\"rmfamily\") (\"sffamily\") (\"ttfamily\")\n(\"mdseries\") (\"bfseries\") (\"upshape\")\n(\"itshape\") (\"slshape\") (\"scshape\")\n)\n\"Default completion table for large-type completion.\")\n\n(defvar LaTeX2e-fontstyle-alist\n'((\"rm\" . \"rmfamily\")\n(\"sf\" . \"sffamily\")\n(\"tt\" . \"ttfamily\")\n(\"md\" . \"mdseries\")\n(\"bf\" . \"bfseries\")\n(\"up\" . \"upshape\")\n(\"it\" . \"itshape\")\n(\"sl\" . \"slshape\")\n(\"sc\" . \"scshape\")))\n\n(defvar user-fontsize-table nil)\n(defvar tmp-fontsize-table nil)\n\n(defvar singlecmd-table\n(append\n'((\"maketitle\") (\"makeindex\") (\"sloppy\") (\"protect\") (\"par\") (\"and\")\n(\"LaTeX\") (\"TeX\") (\"item\") (\"item[]\") (\"appendix\") (\"hline\") (\"kill\")\n;;(\"rightarrow\") (\"Rightarrow\") (\"leftarrow\") (\"Leftarrow\")\n(\"pagebreak\") (\"nopagebreak\") (\"tableofcontents\")\n(\"newpage\") (\"clearpage\") (\"cleardoublepage\")\n(\"footnotemark\") (\"verb\") (\"verb*\")\n(\"linebreak\") (\"pagebreak\") (\"noindent\") (\"indent\")\n(\"left\") (\"right\") (\"dots\") (\"smallskip\") (\"medskip\") (\"bigskip\")\n(\"displaystyle\")\n(\"onslide\") (\"pause\")\t\t;beamer\n)\n(if YaTeX-greek-by-maketitle-completion\n'((\"alpha\") (\"beta\") (\"gamma\") (\"delta\") (\"epsilon\")\n(\"varepsilon\") (\"zeta\") (\"eta\") (\"theta\")(\"vartheta\")\n(\"iota\") (\"kappa\") (\"lambda\") (\"mu\") (\"nu\") (\"xi\") (\"pi\")\n(\"varpi\") (\"rho\") (\"varrho\") (\"sigma\") (\"varsigma\") (\"tau\")\n(\"upsilon\") (\"phi\") (\"varphi\") (\"chi\") (\"psi\") (\"omega\")\n(\"Gamma\") (\"Delta\") (\"Theta\") (\"Lambda\")(\"Xi\") (\"Pi\")\n(\"Sigma\") (\"Upsilon\") (\"Phi\") (\"Psi\") (\"Omega\")))\n(if YaTeX-use-LaTeX2e\n'((\"return\") (\"Return\") (\"yen\")))\t;defined in ascmac\n(if YaTeX-use-AMS-LaTeX\n'((\"nonumber\")))\n)\n\"Default completion table for maketitle-type completion.\")\n\n(defvar user-singlecmd-table nil)\n(defvar tmp-singlecmd-table nil)\n\n;---------- Key mode map ----------\n;;;\n;; Create new key map: YaTeX-mode-map\n;; Do not change this section.\n;;;\n(defvar YaTeX-mode-map nil\n\"Keymap used in YaTeX mode\")\n\n(defvar YaTeX-prefix-map nil\n\"Keymap used when YaTeX-prefix key pushed\")\n\n(defvar YaTeX-user-extensional-map (make-sparse-keymap)\n\"*Keymap used for the user's customization\")\n(defvar YaTeX-current-completion-type nil\n\"Has current completion type. This may be used in YaTeX addin functions.\")\n\n(defvar YaTeX-modify-mode nil\n\"*Current editing mode.\nWhen non-nil, each opening parentheses only opens,\nnil enters both open/close parentheses when opening parentheses key pressed.\")\n\n(defvar YaTeX-math-mode nil\n\"Holds whether current mode is math-mode.\")\n;;;\n;; Define key table\n;;;\n(if YaTeX-mode-map\nnil\n(setq YaTeX-mode-map (make-sparse-keymap))\n(setq YaTeX-prefix-map (make-sparse-keymap))\n(define-key YaTeX-mode-map \"\\\"\" 'YaTeX-insert-quote)\n(define-key YaTeX-mode-map \"{\" 'YaTeX-insert-braces)\n(define-key YaTeX-mode-map \"(\" 'YaTeX-insert-parens)\n(define-key YaTeX-mode-map \"$\" 'YaTeX-insert-dollar) (define-key YaTeX-mode-map \"|\" 'YaTeX-insert-bar) (define-key YaTeX-mode-map \"&\" 'YaTeX-insert-amper) (define-key YaTeX-mode-map \"[\" 'YaTeX-insert-brackets) (define-key YaTeX-mode-map YaTeX-prefix YaTeX-prefix-map) (define-key YaTeX-mode-map \"\\M-\\C-@\" 'YaTeX-mark-environment) (define-key YaTeX-mode-map \"\\M-\\C-a\" 'YaTeX-beginning-of-environment) (define-key YaTeX-mode-map \"\\M-\\C-e\" 'YaTeX-end-of-environment) (define-key YaTeX-mode-map \"\\M-\\C-m\" 'YaTeX-intelligent-newline) (define-key YaTeX-mode-map \"\\C-i\" 'YaTeX-indent-line) (YaTeX-define-key \"%\" 'YaTeX-%-menu) (YaTeX-define-key \"t\" 'YaTeX-typeset-menu) (YaTeX-define-key \"w\" 'YaTeX-switch-mode-menu) (YaTeX-define-key \"'\" 'YaTeX-prev-error) (YaTeX-define-key \"^\" 'YaTeX-visit-main) (YaTeX-define-key \"4^\" 'YaTeX-visit-main-other-window) (YaTeX-define-key \"4g\" 'YaTeX-goto-corresponding-*-other-window) (YaTeX-define-key \"44\" 'YaTeX-switch-to-window) (and YaTeX-emacs-19 window-system (progn (YaTeX-define-key \"5^\" 'YaTeX-visit-main-other-frame) (YaTeX-define-key \"5g\" 'YaTeX-goto-corresponding-*-other-frame) (YaTeX-define-key \"55\" 'YaTeX-switch-to-window))) (YaTeX-define-key \" \" 'YaTeX-do-completion) (YaTeX-define-key \"v\" 'YaTeX-version) (YaTeX-define-key \"}\" 'YaTeX-insert-braces-region) (YaTeX-define-key \"]\" 'YaTeX-insert-brackets-region) (YaTeX-define-key \")\" 'YaTeX-insert-parens-region) (YaTeX-define-key \"$\" 'YaTeX-insert-dollars-region)\n(YaTeX-define-key \"i\" 'YaTeX-fill-item)\n(YaTeX-define-key \"\\\\\"\n(function(lambda () (interactive)\n(insert (if (YaTeX-in-math-mode-p) \"\\\\backslash\" \"\\\\textbackslash\")))))\n(if YaTeX-no-begend-shortcut\n(progn\n(YaTeX-define-key \"B\" 'YaTeX-make-begin-end-region)\n(YaTeX-define-key \"b\" 'YaTeX-make-begin-end))\n(YaTeX-define-begend-key \"bc\" \"center\")\n(YaTeX-define-begend-key \"bd\" \"document\")\n(YaTeX-define-begend-key \"bD\" \"description\")\n(YaTeX-define-begend-key \"be\" \"enumerate\")\n(YaTeX-define-begend-key \"bE\" \"equation\")\n(YaTeX-define-begend-key \"bi\" \"itemize\")\n(YaTeX-define-begend-key \"bl\" \"flushleft\")\n(YaTeX-define-begend-key \"bm\" \"minipage\")\n(YaTeX-define-begend-key \"bt\" \"tabbing\")\n(YaTeX-define-begend-key \"bT\" \"tabular\")\n(YaTeX-define-begend-key \"b\\^t\" \"table\")\n(YaTeX-define-begend-key \"bp\" \"picture\")\n(YaTeX-define-begend-key \"bq\" \"quote\")\n(YaTeX-define-begend-key \"bQ\" \"quotation\")\n(YaTeX-define-begend-key \"br\" \"flushright\")\n(YaTeX-define-begend-key \"bv\" \"verbatim\")\n(YaTeX-define-begend-key \"bV\" \"verse\")\n(YaTeX-define-key \"B \" 'YaTeX-make-begin-end-region)\n(YaTeX-define-key \"b \" 'YaTeX-make-begin-end))\n(YaTeX-define-key \"e\" 'YaTeX-end-environment)\n(YaTeX-define-key \"S\" 'YaTeX-make-section-region)\n(YaTeX-define-key \"s\" 'YaTeX-make-section)\n(YaTeX-define-key \"L\" 'YaTeX-make-fontsize-region)\n(YaTeX-define-key \"l\" 'YaTeX-make-fontsize)\n(YaTeX-define-key \"m\" 'YaTeX-make-singlecmd)\n(YaTeX-define-key \".\" 'YaTeX-comment-paragraph)\n(YaTeX-define-key \",\" 'YaTeX-uncomment-paragraph)\n(YaTeX-define-key \">\" 'YaTeX-comment-region)\n(YaTeX-define-key \"<\" 'YaTeX-uncomment-region)\n(YaTeX-define-key \"g\" 'YaTeX-goto-corresponding-*)\n(YaTeX-define-key \"k\" 'YaTeX-kill-*)\n(YaTeX-define-key \"c\" 'YaTeX-change-*)\n(YaTeX-define-key \"a\" 'YaTeX-make-accent)\n(YaTeX-define-key \"?\" 'YaTeX-help)\n(YaTeX-define-key \"/\" 'YaTeX-apropos)\n(YaTeX-define-key \"&\" 'YaTeX-what-column)\n(YaTeX-define-key \"d\" 'YaTeX-display-hierarchy)\n(YaTeX-define-key \"x\" YaTeX-user-extensional-map)\n(YaTeX-define-key \"n\"\n(function(lambda () (interactive)\n(insert \"\\\\\" (if (YaTeX-on-section-command-p \"o?oalign\") \"crcr\" \"\\\\\")))))\n(if YaTeX-dos\n(define-key YaTeX-prefix-map \"\\C-r\"\n(function(lambda () (interactive)\n(YaTeX-set-screen-height YaTeX-saved-screen-height) (recenter))))))\n\n(defvar YaTeX-section-completion-map nil\n\"*Key map used at YaTeX completion in the minibuffer.\")\n(if YaTeX-section-completion-map nil\n(setq YaTeX-section-completion-map\n(copy-keymap (or (and (boundp 'gmhist-completion-map)\ngmhist-completion-map)\nminibuffer-local-completion-map)))\n(define-key YaTeX-section-completion-map\n\" \" 'YaTeX-minibuffer-complete)\n(define-key YaTeX-section-completion-map\n\"\\C-i\" 'YaTeX-minibuffer-complete)\n(define-key YaTeX-section-completion-map\n\n(defvar YaTeX-recursive-map nil\n\"*Key map used at YaTeX reading arguments in the minibuffer.\")\n(if YaTeX-recursive-map nil\n(setq YaTeX-recursive-map (copy-keymap global-map))\n(define-key YaTeX-recursive-map YaTeX-prefix YaTeX-prefix-map)\n(mapcar\n(function\n(lambda (key)\n(define-key YaTeX-mode-map (car key) 'YaTeX-math-insert-sequence)\n(define-key YaTeX-recursive-map (car key) 'YaTeX-math-insert-sequence)))\nYaTeX-math-key-list))\n;---------- Define other variable ----------\n(defvar YaTeX-env-name \"document\" \"*Initial tex-environment completion\")\n(defvar YaTeX-section-name\n(if YaTeX-use-LaTeX2e \"documentclass\" \"documentstyle\")\n\"*Initial tex-section completion\")\n(defvar YaTeX-fontsize-name \"large\" \"*Initial fontsize completion\")\n(defvar YaTeX-single-command \"maketitle\" \"*Initial LaTeX single command\")\n(defvar YaTeX-kanji-code nil\n\"*File kanji code used by Japanese TeX.\nnil: Do not care (Preserve coding-system)\n0: no-converion (mule)\n1: Shift JIS\n2: JIS\n3: EUC\n4: UTF-8\")\n\n(defvar YaTeX-coding-system nil \"File coding system used by Japanese TeX.\")\n(cond\n(YaTeX-emacs-20\n(setq YaTeX-coding-system\n(cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist))))\n((boundp 'MULE)\n(setq YaTeX-coding-system\n(symbol-value (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist))))))\n\n(defvar YaTeX-mode-syntax-table nil\n\"*Syntax table for yatex-mode\")\n\n(if YaTeX-mode-syntax-table nil\n(setq YaTeX-mode-syntax-table (make-syntax-table (standard-syntax-table)))\n(modify-syntax-entry ?\\n \" \" YaTeX-mode-syntax-table)\n(modify-syntax-entry ?\\{ \"(}\" YaTeX-mode-syntax-table)\n(modify-syntax-entry ?\\} \"){\" YaTeX-mode-syntax-table)\n(modify-syntax-entry ?\\t \" \" YaTeX-mode-syntax-table)\n(modify-syntax-entry ?\\f \">\" YaTeX-mode-syntax-table)\n(modify-syntax-entry ?\\n \">\" YaTeX-mode-syntax-table)\n(modify-syntax-entry ?$\"$$\" YaTeX-mode-syntax-table) (modify-syntax-entry ?% \"<\" YaTeX-mode-syntax-table) (modify-syntax-entry ?\\\\ \"/\" YaTeX-mode-syntax-table) (modify-syntax-entry ?~ \" \" YaTeX-mode-syntax-table)) (defvar YaTeX-mode-syntax-table-nonparen nil \"Syntax table for yatex-mode with normal parentheses treated white spaces\") (if YaTeX-mode-syntax-table-nonparen nil (setq YaTeX-mode-syntax-table-nonparen (make-syntax-table YaTeX-mode-syntax-table)) (let ((zenparens \"()()「」『』【】[]{}《》〈〉〔〕\") (i 0) s) (while (string-match \".\" zenparens i) (setq s (substring zenparens (match-beginning 0) (match-end 0)) i (1+ i)) (modify-syntax-entry (string-to-char s) \" \" YaTeX-mode-syntax-table-nonparen)))) ;---------- Provide YaTeX-mode ---------- ;;; ;; Major mode definition ;;; (defun yatex-mode () \" Yet Another LaTeX mode: Major mode for editing input files of LaTeX. -You can invoke processes concerning LaTeX typesetting by \\$YaTeX-typeset-menu] -Complete LaTeX environment form of \\\\begin{env} ... \\\\end{env}' by \\\\[YaTeX-make-begin-end] -Enclose region into some environment by \\\\[universal-argument] \\\\[YaTeX-make-begin-end] -Complete LaTeX command which takes argument like \\\\section{}' by \\\\[YaTeX-make-section] -Put LaTeX command which takes no arguments like \\\\maketitle' by \\\\[YaTeX-make-singlecmd] -Complete font or character size descriptor like {\\\\large }' by \\\\[YaTeX-make-fontsize] -Enclose region into those descriptors above by \\\\[universal-argument] \\\\[YaTeX-make-fontsize] -Enter European accent notations by \\\\[YaTeX-make-accent] -Toggle various modes of YaTeX by \\\\[YaTeX-switch-mode-menu] -Change environt name (on the begin/end line) by \\\\[YaTeX-change-*] -Kill LaTeX command/environment sequences by \\\\[YaTeX-kill-*] -Kill LaTeX command/environment with its contents \\\\[universal-argument] \\\\[YaTeX-kill-*] -Go to corresponding object (begin/end, file, labels) by \\\\[YaTeX-goto-corresponding-*] or \\\\[YaTeX-goto-corresponding-*-other-window] (in other window) \\\\[YaTeX-goto-corresponding-*-other-frame] (in other frame) -Go to main LaTeX source text by \\\\[YaTeX-visit-main] or \\\\[YaTeX-visit-main-other-window] (in other window) \\\\[YaTeX-visit-main-other-frame] (in other frame) -Comment out or uncomment region by \\\\[YaTeX-comment-region] or \\\\[YaTeX-uncomment-region] -Comment out or uncomment paragraph by \\\\[YaTeX-comment-paragraph] or \\\\[YaTeX-uncomment-paragraph] -Make an \\\\item entry hang-indented by \\\\[YaTeX-fill-item] -Enclose the region with parentheses by \\\\[YaTeX-insert-parens-region] \\\\[YaTeX-insert-braces-region] \\\\[YaTeX-insert-brackets-region] \\\\[YaTeX-insert-dollars-region] -Look up the corresponding column header of tabular environment by \\\\[YaTeX-what-column] -Enter a newline and an entry suitable for environment by \\\\[YaTeX-intelligent-newline] -View the structure of file inclusion by \\\\[YaTeX-display-hierarchy] -Refer the online help of popular LaTeX commands by \\\\[YaTeX-help] (help) \\\\[YaTeX-apropos] (apropos) -Edit %# notation' by \\\\[YaTeX-%-menu] Those are enough for fastening your editing of LaTeX source. But further more features are available and they are documented in the manual. \" (interactive) (kill-all-local-variables) (setq major-mode 'yatex-mode) (setq mode-name (if YaTeX-japan \"やてふ\" \"YaTeX\")) (mapcar 'make-local-variable '(dvi2-command fill-column fill-prefix tmp-env-table tmp-section-table tmp-fontsize-table tmp-singlecmd-table paragraph-start paragraph-separate YaTeX-math-mode indent-line-function comment-line-break-function comment-start comment-start-skip )) (YaTeX-set-file-coding-system YaTeX-kanji-code YaTeX-coding-system) (setq fill-column YaTeX-fill-column fill-prefix YaTeX-fill-prefix paragraph-start YaTeX-paragraph-start paragraph-separate YaTeX-paragraph-separate indent-line-function 'YaTeX-indent-line comment-start YaTeX-comment-prefix comment-end \"\" comment-start-skip \"[^\\\\\\$%+[ \\t]*\" local-abbrev-table yatex-mode-abbrev-table) (if (fboundp 'comment-indent-new-line) ;for Emacs21 (setq comment-line-break-function 'YaTeX-comment-line-break)) ;; +dnd for X11 w/ emacs23+ (and window-system (featurep 'dnd) (require 'yatex23 nil t) (set (make-local-variable 'dnd-protocol-alist) (cons (cons \"^file:\" 'YaTeX-dnd-handler) dnd-protocol-alist))) (if (and YaTeX-use-font-lock (featurep 'font-lock)) (progn (require 'yatex19) (YaTeX-font-lock-set-default-keywords) (or (featurep 'xemacs) (set (make-local-variable 'font-lock-defaults) (get 'yatex-mode 'font-lock-defaults))) ;;(font-lock-mode 1) )) (use-local-map YaTeX-mode-map) (set-syntax-table YaTeX-mode-syntax-table) (if YaTeX-dos (setq YaTeX-saved-screen-height (YaTeX-screen-height))) (YaTeX-read-user-completion-table) (and (fboundp 'YaTeX-hilit-setup-alist) (YaTeX-hilit-setup-alist)) (makunbound 'inenv) ;(turn-on-auto-fill) ;1.63 -> 1.79off (if (fboundp 'electric-indent-local-mode) (electric-indent-local-mode YaTeX-electric-indent-mode)) (and (= 0 (buffer-size)) (file-exists-p YaTeX-template-file) (y-or-n-p (format \"Insert %s?\" YaTeX-template-file)) (insert-file-contents (expand-file-name YaTeX-template-file))) (run-hooks 'text-mode-hook 'yatex-mode-hook)) ;---------- Define YaTeX-mode functions ---------- (defvar YaTeX-ec \"\\\\\" \"Escape character of current mark-up language.\") (defvar YaTeX-ec-regexp (regexp-quote YaTeX-ec)) (defvar YaTeX-struct-begin (concat YaTeX-ec \"begin{%1}%2\") \"Keyword format of begin-environment.\") (defvar YaTeX-struct-end (concat YaTeX-ec \"end{%1}\") \"Keyword format of end-environment.\") (defvar YaTeX-struct-name-regexp \"[^}]*\" \"Environment name regexp.\") (defvar YaTeX-TeX-token-regexp (cond (YaTeX-japan \"[A-Za-z*ぁ-ん亜-龠]+\") (t \"[A-Za-z*]+\")) \"Regexp of characters which can be a member of TeX command's name.\") (defvar YaTeX-kanji-regexp \"[ぁ-ん亜-龠]\" \"Generic regexp of Japanese Kanji (and symbol) characters.\") (defvar YaTeX-command-token-regexp YaTeX-TeX-token-regexp \"Regexp of characters which can be a member of current mark up language's command name.\") ;;(defvar YaTeX-struct-section ;; (concat YaTeX-ec \"%1{%2}\") ;; \"Keyword to make section.\") ;;; ;; autoload section ;;; ;;autoload from yatexprc.el (autoload 'YaTeX-visit-main \"yatexprc\" \"Visit main LaTeX file.\" t) (autoload 'YaTeX-visit-main-other-window \"yatexprc\" \"Visit main other window.\" t) (autoload 'YaTeX-main-file-p \"yatexprc\" \"Check if the file is main.\" t) (autoload 'YaTeX-get-builtin \"yatexprc\" \"Get %# built-in.\" t) (autoload 'YaTeX-system \"yatexprc\" \"Call system command\" t) (autoload 'YaTeX-save-buffers \"yatexprc\" \"Save buffers of same major mode\" t) (autoload 'YaTeX-goto-corresponding-viewer \"yatexprc\" \"Viewer jump line\" t) ;;autoload from yatexmth.el (autoload 'YaTeX-math-insert-sequence \"yatexmth\" \"Image input.\" t) (autoload 'YaTeX-in-math-mode-p \"yatexmth\" \"Check if in math-env.\" t) (autoload 'YaTeX-toggle-math-mode \"yatexmth\" \"YaTeX math-mode interfaces.\" t) (autoload 'YaTeX-math-member-p \"yatexmth\" \"Check if a word is math command.\" t) (autoload 'YaTeX-insert-amsparens-region \"yatexmth\" \"AMS parens region\" t) (autoload 'YaTeX-insert-amsbraces-region \"yatexmth\" \"AMS braces region\" t) (autoload 'YaTeX-insert-amsbrackets-region \"yatexmth\" \"AMS brackets region\" t) (autoload 'YaTeX-on-parenthesis-p \"yatexmth\" \"Check if on math-parens\" t) (autoload 'YaTeX-goto-open-paren \"yatexmth\" \"Goto opening paren\" t) (autoload 'YaTeX-change-parentheses \"yatexmth\" \"Change corresponding parens\" t) (autoload 'YaTeX-goto-corresponding-paren \"yatexmth\" \"\\bigl\\bigr jumps\" t) (autoload 'YaTeX-typeset-math-region \"yatexmth\" \"Typeset math-region\" t) ;;autoload from yatexhlp.el (autoload 'YaTeX-help \"yatexhlp\" \"YaTeX helper with LaTeX commands.\" t) (autoload 'YaTeX-apropos \"yatexhlp\" \"Apropos for (La)TeX commands.\" t) ;;autoload from yatexgen.el (autoload 'YaTeX-generate \"yatexgen\" \"YaTeX add-in function generator.\" t) (autoload 'YaTeX-generate-simple \"yatexgen\" \"YaTeX add-in support.\" t) ;;autoload from yatexsec.el (autoload 'YaTeX-section-overview \"yatexsec\" \"YaTeX sectioning(view)\" t) (autoload 'YaTeX-read-section-in-minibuffer \"yatexsec\" \"YaTeX sectioning\" t) (autoload 'YaTeX-make-section-with-overview \"yatexsec\" \"YaTeX sectioning\" t) ;;autoload from yatexenv.el (autoload 'YaTeX-what-column \"yatexenv\" \"YaTeX env. specific funcs\" t) (autoload 'YaTeX-intelligent-newline \"yatexenv\" \"YaTeX env. specific funcs\" t) (autoload 'YaTeX-indent-line-equation \"yatexenv\" \"Indent equation lines.\" t) (autoload 'YaTeX-goto-corresponding-leftright \"yatexenv\" \"\\left\\right jumps\" t) ;;autoload from yatexhie.el (autoload 'YaTeX-display-hierarchy \"yatexhie\" \"YaTeX document hierarchy browser\" t) (autoload 'YaTeX-display-hierarchy-directly \"yatexhie\" \"Same as YaTeX-display-hierarchy. Call from mouse.\" t) ;;autoload from yatexpkg.el (autoload 'YaTeX-package-auto-usepackage \"yatexpkg\" \"Auto \\\\usepackage\" t) ;;; ;; YaTeX-mode functions ;;; (defun YaTeX-insert-begin-end (env region-mode) \"Insert \\\\begin{mode-name} and \\\\end{mode-name}. This works also for other defined begin/end tokens to define the structure.\" (setq YaTeX-current-completion-type 'begin) (let*((ccol (current-column)) beg beg2 exchange (arg region-mode) ;for old compatibility (indent-column (+ ccol YaTeX-environment-indent))(i 1) func) (if (and region-mode (> (point) (mark))) (progn (exchange-point-and-mark) (setq exchange t ccol (current-column) indent-column (+ ccol YaTeX-environment-indent)))) ;;VER2 (insert \"\\\\begin{\" env \"}\" (YaTeX-addin env)) (setq beg (point)) (YaTeX-insert-struc 'begin env) (setq beg2 (point)) (insert \"\\n\") (indent-to indent-column) (save-excursion ;;indent optional argument of \\begin{env}, if any (while (> (point-beginning-of-line) beg) (skip-chars-forward \"\\\\s \" (point-end-of-line)) (indent-to indent-column) (forward-line -1))) (require 'yatexenv) (if region-mode ;;if region-mode, indent all text in the region (save-excursion (if (fboundp (intern-soft (concat \"YaTeX-enclose-\" env))) (funcall (intern-soft (concat \"YaTeX-enclose-\" env)) (point) (mark)) (while (< (progn (forward-line 1) (point)) (mark)) (if (eolp) nil (skip-chars-forward \" \\t\\n\") (indent-to indent-column)))))) (if region-mode (exchange-point-and-mark)) (indent-to ccol) ;;VER2 (insert \"\\\\end{\" env \"}\\n\") (YaTeX-insert-struc 'end env) (YaTeX-reindent ccol) (if region-mode (progn (insert \"\\n\") (or exchange (exchange-point-and-mark))) (goto-char beg2) (YaTeX-intelligent-newline nil) (if (fboundp (intern-soft (concat \"YaTeX-intelligent-newline-\" env))) (progn (message (cond (YaTeX-japan \"%s で次の行の入力に進みます。\") (t \"%s' produces the next line's template.\")) (key-description (car (where-is-internal 'YaTeX-intelligent-newline)))))) (YaTeX-indent-line)) (YaTeX-package-auto-usepackage env 'env) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register)))) (defun YaTeX-make-begin-end (arg) \"Make LaTeX environment command of \\\\begin{env.} ... \\\\end{env.} by completing read. If you invoke this command with universal argument, $$key binding for universal-argument is \\$universal-argument]$$ you can put REGION into that environment between \\\\begin and \\\\end.\" (interactive \"P\") (let* ((region-p (or arg (YaTeX-region-active-p))) (mode (if region-p \" region\" \"\")) (env (save-excursion ;for Emacs24 work-around to avoid point warp (YaTeX-read-environment (format \"Begin environment%s(default %s): \" mode YaTeX-env-name))))) (if (string= env \"\") (setq env YaTeX-env-name)) (setq YaTeX-env-name env) (YaTeX-update-table (list YaTeX-env-name) 'env-table 'user-env-table 'tmp-env-table) (YaTeX-insert-begin-end YaTeX-env-name region-p))) (defun YaTeX-make-begin-end-region () \"Call YaTeX-make-begin-end with ARG to specify region mode.\" (interactive) (YaTeX-make-begin-end t)) (defun YaTeX-guess-section-type () (if (eq major-mode 'yatex-mode) (save-excursion (cond ((save-excursion (not (search-backward YaTeX-ec nil t))) (if YaTeX-use-LaTeX2e \"documentclass\" \"documentstyle\")) ((progn (if (= (char-after (1- (point))) ?~) (forward-char -1)) (forward-char -1) (looking-at \"表\\\\|図\\\\|式\\\\|第\")) \"ref\") ((and (looking-at \"[a-z \\t]\") (progn (skip-chars-backward \"a-z \\t\") (looking-at \"table\\\\|figure\\\\|formula\\\\|eq\\$$\\\\.\\\\|uation\\$$\"))) \"ref\") ((save-excursion (skip-chars-backward \"[^ア-ン]\") (looking-at \"プログラム\\\\|リスト\")) \"ref\") ((YaTeX-re-search-active-backward (concat YaTeX-ec-regexp \"begin{\\$$[^}]+\\$$}\") (regexp-quote YaTeX-comment-prefix) (save-excursion (forward-line -1) (point)) t) (let ((env (YaTeX-match-string 1))) (cdr (assoc env '((\"table\" . \"caption\")))))) )))) (defun YaTeX-make-section (arg &optional beg end cmd) \"Make LaTeX \\\\section{} type command with completing read. With numeric ARG, you can specify the number of arguments of LaTeX command. For example, if you want to produce LaTeX command \\\\addtolength{\\\\topmargin}{8mm} which has two arguments. You can produce that sequence by typing... ESC 2 C-c s add SPC RET \\\\topm SPC RET 8mm RET $$by default$$ Then yatex will automatically complete addtolength' with two arguments next time. You can complete symbol at LaTeX command and the 1st argument. If the optional 2nd and 3rd argument BEG END are specified, enclose the region from BEG to END into the first argument of the LaTeX sequence. Optional 4th arg CMD is LaTeX command name, for non-interactive use.\" (interactive \"P\") (setq YaTeX-current-completion-type 'section) (if (or (equal arg '(4)) (YaTeX-region-active-p)) (setq beg (region-beginning) end (region-end))) (unwind-protect (let* ((source-window (selected-window)) guess (section (or cmd (progn (setq guess (or (YaTeX-guess-section-type) YaTeX-section-name)) (YaTeX-read-section (if YaTeX-simple-messages (format \"Section-type (default %s): \" guess) (if (> (minibuffer-depth) 0) (format \"%s???{} (default %s)%s: \" YaTeX-ec guess (format \"[level:%d]\" (minibuffer-depth))) (format \"(C-v for view-section) %s???{%s} (default %s): \" YaTeX-ec (if beg \"region\" \"\") guess))) nil)))) (section (if (string= section \"\") guess section)) (numarg ;; The number of section-type command's argument (or (and (numberp arg) arg) (nth 1 (YaTeX-lookup-table section 'section)) 1)) (arg-reader (intern-soft (concat \"YaTeX::\" section))) (addin-args (and arg-reader (fboundp arg-reader))) (title \"\") (j 1) (after-change-functions nil) ;inhibit font-locking temporarily (enable-recursive-minibuffers t) (mkarg-func (function (lambda (n) (while (<= j n) (unwind-protect (setq title (cond (addin-args (funcall arg-reader j)) (YaTeX-skip-default-reader \"\") (t (read-string-with-history (format \"Argument %d of %s: \" j section))))) (insert (concat ;to allow nil return value \"{\" title \"}\"))) (setq j (1+ j)))))) );;let (setq YaTeX-section-name section) (if beg (let*((e (make-marker)) (ar2 (intern-soft (concat \"YaTeX::\" section \"-region\"))) (arp (and ar2 (fboundp ar2)))) (goto-char end) (insert \"}\") (set-marker e (point)) (goto-char beg) (unwind-protect (progn (insert YaTeX-ec YaTeX-section-name (YaTeX-addin YaTeX-section-name)) (if (> numarg 1) (funcall mkarg-func (1- numarg)))) (insert \"{\")) (if arp (funcall ar2 (point) e)) (goto-char e) (set-marker e nil)) (use-global-map YaTeX-recursive-map) (if (= numarg 0) (YaTeX-make-singlecmd YaTeX-section-name) (progn (insert YaTeX-ec YaTeX-section-name) (insert (YaTeX-addin YaTeX-section-name)))) ;;read arguments with add-in (funcall mkarg-func numarg)) (YaTeX-update-table (if (/= numarg 1) (list section numarg) (list section)) 'section-table 'user-section-table 'tmp-section-table) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register)) (if (string= (YaTeX-buffer-substring (- (point) 2) (point)) \"{}\") (forward-char -1)) (while (string= (YaTeX-buffer-substring (- (point) 3) (1- (point))) \"{}\") (forward-char -2)) (YaTeX-package-auto-usepackage section 'section)) (if (<= (minibuffer-depth) 0) (use-global-map global-map)) (insert \"\"))) ;insert dummy string to fontify(Emacs20) (defun YaTeX-make-section-region (args beg end) \"Call YaTeX-make-section with arguments to specify region mode.\" (interactive \"P\\nr\") (YaTeX-make-section args beg end)) (defun YaTeX-make-fontsize (arg &optional fontsize) \"Make completion like {\\\\large ...} or {\\\\slant ...} in minibuffer. If you invoke this command with universal argument, you can put region into {\\\\xxx } braces. $$key binding for universal-argument is \\\\[universal-argument]$$\" (interactive \"P\") (YaTeX-sync-local-table 'tmp-fontsize-table) (let* ((region-p (if (or arg (YaTeX-region-active-p)) (cons (region-beginning) (region-end)))) (mode (if region-p \"region\" \"\")) (fontsize (or fontsize (YaTeX-read-fontsize (if YaTeX-simple-messages (format \"Font or size (default %s): \" YaTeX-fontsize-name) (format \"{\\\\??? %s} (default %s)%s: \" mode YaTeX-fontsize-name (if (> (minibuffer-depth) 0) (format \"[level:%d]\" (minibuffer-depth)) \"\"))) nil nil)))) (if (string= fontsize \"\") (setq fontsize YaTeX-fontsize-name)) (setq YaTeX-current-completion-type 'large) (setq YaTeX-fontsize-name fontsize) (YaTeX-update-table (list YaTeX-fontsize-name) 'fontsize-table 'user-fontsize-table 'tmp-fontsize-table) (and YaTeX-use-LaTeX2e (YaTeX-latex2e-p) (setq fontsize (cdr (assoc YaTeX-fontsize-name LaTeX2e-fontstyle-alist))) (setq YaTeX-fontsize-name fontsize)) (if region-p (let ((b (car region-p)) (e (set-marker (make-marker) (cdr region-p)))) (goto-char b) (insert \"{\\\\\" YaTeX-fontsize-name \" \") (goto-char e) (insert \"}\") (set-marker e nil)) (insert (concat \"{\\\\\" YaTeX-fontsize-name \" }\")) (forward-char -1) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register)) (save-excursion (insert (YaTeX-addin YaTeX-fontsize-name))) (YaTeX-package-auto-usepackage YaTeX-fontsize-name 'large)))) (defun YaTeX-make-fontsize-region () \"Call function:YaTeX-make-fontsize with ARG to specify region mode.\" (interactive) (YaTeX-make-fontsize t)) (defvar YaTeX-singlecmd-suffix \"\" \"*Suffix for maketitle-type commands.\") (defvar YaTeX-read-singlecmd-history nil \"Holds maketitle-type history.\") (put 'YaTeX-read-singlecmd-history 'no-default t) (defun YaTeX-make-singlecmd (single) (interactive (list (YaTeX-cplread-with-learning (if YaTeX-simple-messages (format \"maketitle-type (default %s): \" YaTeX-single-command) (format \"%s??? (default %s)%s: \" YaTeX-ec YaTeX-single-command (if (> (minibuffer-depth) 0) (format \"[level:%d]\" (minibuffer-depth)) \"\"))) 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table nil nil nil 'YaTeX-read-singlecmd-history))) (if (string= single \"\") (setq single YaTeX-single-command)) (setq YaTeX-single-command single) (setq YaTeX-current-completion-type 'maketitle) (let ((dollar (and (not (YaTeX-in-math-mode-p)) (YaTeX-math-member-p YaTeX-single-command))) p q) (if dollar (insert \"\")) (insert YaTeX-ec YaTeX-single-command) (setq p (point)) (insert (YaTeX-addin single) YaTeX-singlecmd-suffix) (if dollar (insert \"\")) (setq q (point)) (goto-char p) (forward-char -2) (if (looking-at \"\\\\[\\$\") (forward-char 1) (goto-char q))) (YaTeX-package-auto-usepackage YaTeX-single-command 'maketitle) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register))) (defvar YaTeX-completion-begin-regexp \"[{\\\\]\" \"Regular expression of limit where LaTeX command's completion begins.\") (defun YaTeX-do-completion () \"Try completion on LaTeX command preceding point.\" (interactive) (if (or (eq (preceding-char) ? ) (eq (preceding-char) ?\\t) (eq (preceding-char) ?\\n) (bobp)) (message \"Nothing to complete.\") ;Do not complete (let* ((end (point)) (limit (point-beginning-of-line)) (completion-begin (progn (re-search-backward \"[ \\t\\n]\" limit 1) (point))) (begin (progn (goto-char end) (if (re-search-backward YaTeX-completion-begin-regexp completion-begin t) (1+ (point)) nil)))) (goto-char end) (cond ((null begin) (message \"I think it is not a LaTeX sequence.\")) (t (mapcar 'YaTeX-sync-local-table '(tmp-section-table tmp-env-table tmp-singlecmd-table)) (let*((pattern (YaTeX-buffer-substring begin end)) (all-table (append section-table user-section-table tmp-section-table env-table user-env-table tmp-env-table singlecmd-table user-singlecmd-table tmp-singlecmd-table)) ;; First, ;; search completion without backslash. (completion (try-completion pattern all-table))) (if (eq completion nil) ;; Next, ;; search completion with backslash (setq completion (try-completion (YaTeX-buffer-substring (1- begin) end) all-table nil) begin (1- begin))) (cond ((null completion) (message (concat \"Can't find completion for '\" pattern \"'\")) (ding)) ((eq completion t) (message \"Sole completion.\")) ((not (string= completion pattern)) (delete-region begin end) (insert completion) ) (t (message \"Making completion list...\") (with-output-to-temp-buffer \"*Help*\" (display-completion-list (all-completions pattern all-table))))))))))) (defun YaTeX-toggle-modify-mode (&optional arg) (interactive \"P\") (or (memq 'YaTeX-modify-mode mode-line-format) (setq mode-line-format (append (list \"\" 'YaTeX-modify-mode) mode-line-format))) (if (or arg (null YaTeX-modify-mode)) (progn (setq YaTeX-modify-mode \"*m*\") (message \"Modify mode\")) (setq YaTeX-modify-mode nil) (message \"Cancel modify mode.\")) (set-buffer-modified-p (buffer-modified-p))) ;redraw mode-line (defun YaTeX-switch-mode-menu (arg &optional char) (interactive \"P\") (message \"Toggle: (M)odify-mode ma(T)h-mode\") (let ((c (or char (read-char)))) (cond ((= c ?m) (YaTeX-toggle-modify-mode arg)) ((or (= c ?$) (= c ?t))\n(if YaTeX-auto-math-mode\n(message \"Makes no sense in YaTeX-auto-math-mode.\")\n(YaTeX-toggle-math-mode arg))))))\n\n(defun YaTeX-insert-quote ()\n(interactive)\n(insert\n(cond\n((YaTeX-literal-p) ?\\\")\n((= (preceding-char) ?\\\\ ) ?\\\")\n;((= (preceding-char) ?$$) ?\\\") ((or (= (preceding-char) 32) (= (preceding-char) 9) (= (preceding-char) ?\\n) (bobp) (string-match (regexp-quote (char-to-string (preceding-char))) \"、。,.?!「」『』【】()\")) \"\") (t \"''\")))) (defun YaTeX-closable-p () (and (not YaTeX-modify-mode) (not (eq YaTeX-close-paren-always 'never)) (or YaTeX-close-paren-always (eolp)) (not (input-pending-p)) (not (YaTeX-literal-p))) ;;(or YaTeX-modify-mode ;; (and (not YaTeX-close-paren-always) (not (eolp))) ;; (input-pending-p) ;; (YaTeX-quick-in-environment-p \"verbatim\")) ) (defun YaTeX-insert-braces-region (beg end &optional open close) (interactive \"r\") (save-excursion (goto-char end) (YaTeX-insert-inherit (or close \"}\")) (goto-char beg) (YaTeX-insert-inherit (or open \"{\")))) (defun YaTeX-get-macro-at-point (&optional p) \"Get (La)TeX macro around point P.\" (interactive \"d\") (save-excursion (goto-char (setq p (or p (point)))) (let ((token (substring (substring YaTeX-TeX-token-regexp 1) 0 -2)) bsend) (and (not (bobp)) (or (looking-at YaTeX-TeX-token-regexp) (string-match YaTeX-TeX-token-regexp (char-to-string (preceding-char)))) (progn (skip-chars-backward token) (equal (preceding-char) ?\\$$)\n(save-excursion\n(setq bsend (point))\n(skip-chars-backward \"\\\\\\\\\") ;emacs18 doesn't return distance\n(/= (% (- bsend (point)) 2) 0)) ;consider \\\\\n(looking-at YaTeX-TeX-token-regexp)\n(YaTeX-match-string 0)))))\n\n(defun YaTeX-insert-braces (arg &optional open close)\n(interactive \"p\")\n(let ((begend-guide\n(function\n(lambda ()\n(if (equal (get 'YaTeX-insert-braces 'begend-guide) 2)\nnil\t\t\t;if triggered thrice, do nothing\n(momentary-string-display\n(format\n(cond\n(YaTeX-japan \"begin/end入力には %s を使いましょう\")\n(t \"You don't understand Zen of %s'!\"))\n(key-description\n(car (where-is-internal 'YaTeX-make-begin-end))))\n(point))\n(put 'YaTeX-insert-braces 'begend-guide\n(+ 1 (YaTeX-str2int ;increment counter of beg-end guidance\n(prin1-to-string\n(get 'YaTeX-insert-braces 'begend-guide)))))))))\nenv macro not-literal b e)\n(cond\n((YaTeX-region-active-p)\n(YaTeX-insert-braces-region (region-beginning) (region-end)))\n((YaTeX-jmode) (YaTeX-self-insert arg))\n((not (YaTeX-closable-p)) (YaTeX-self-insert arg))\n((save-excursion\n(and (> (- (point) (point-min)) 6)\n(condition-case () (forward-char -6) (error nil)))\n(looking-at \"\\\\\\\\left\\\\\\\\\"))\n(insert \"{\\\\right\\\\}\")\n(forward-char -8))\n((save-excursion\t\t\t;from matsu<at>math.s.chiba-u.ac.jp\n(and (> (- (point) (point-min)) 6) (forward-char -6))\n(looking-at \"\\\\\\$bB]igl\\\\\\\\\")) (insert (concat \"{\" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) \"r\\\\}\")) (forward-char -7)) ((save-excursion (and (> (- (point) (point-min)) 7) (condition-case () (forward-char -7) (error nil))) (looking-at \"\\\\\\\\[bB]iggl\\\\\\\\\")) (insert (concat \"{\" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) \"r\\\\}\")) (forward-char -8)) ((= (preceding-char) ?\\\\ ) (insert \"{\\\\}\") (forward-char -2)) ;matsu's hack ends here ((and (setq not-literal (not (YaTeX-literal-p))) (equal \"end\" (setq macro (YaTeX-get-macro-at-point))) (setq env (YaTeX-inner-environment))) (funcall begend-guide) (insert \"{\" env \"}\")) ((and not-literal (equal \"begin\" macro)) (insert \"{\") (save-excursion (indent-to (prog1 (- (current-column) 7) (insert \"}\\n\"))) (insert \"\\\\end{}\") (setq e (point))) (setq env (YaTeX-read-environment (format \"Begin environment(default %s): \" YaTeX-env-name))) (if (string= \"\" env) (setq env YaTeX-env-name)) (setq YaTeX-env-name env) (funcall begend-guide) (delete-region (- (point) 7) e) (YaTeX-insert-begin-end env nil)) (t (insert (or open \"{\") (or close \"}\")) (forward-char -1) (if (and (eq (char-after (point)) ?\\}) ;; the case \\\\{}' (eq (char-after (- (point) 2)) ?\\\\ )) (progn (insert \"\\\\\") (forward-char -1))) )))) (defun YaTeX-jmode () (or (and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*) (and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*) (and (boundp 'skk-mode) skk-mode (not skk-latin-mode)) (and (boundp 'default-input-method) default-input-method current-input-method))) (defun YaTeX-jmode-off () (if (cond ((and (boundp 'canna:*japanese-mode*) canna:*japanese-mode*) (canna-toggle-japanese-mode) t) ((and (boundp 'egg:*mode-on*) egg:*mode-on* egg:*input-mode*) (egg:toggle-egg-mode-on-off) t) ((and (fboundp 'skk-mode) (boundp 'skk-mode) skk-mode) (cond ((fboundp 'skk-latin-mode) (or (and (boundp 'skk-henkan-mode) skk-henkan-mode) (and (boundp 'skk-henkan-on) (or skk-henkan-mode skk-henkan-active)) (and (boundp 'j-henkan-on) (or j-henkan-on j-henkan-active)) ;; Deactivate jmode if henkan-mode is not running. ;; Suggested by tt.tetsuo.tsukamoto. (progn (put 'YaTeX-jmode-on 'skkkata skk-katakana) (skk-latin-mode t)))) ((fboundp 'skk-mode-off) (skk-mode-off)) (t (j-mode-off))) t) ((and (fboundp 'toggle-input-method) current-input-method) (toggle-input-method) t) ((and (fboundp 'fep-force-off) (fep-force-off)))) (put 'YaTeX-jmode 'jmode t))) (defun YaTeX-jmode-on () (cond ((boundp 'canna:*japanese-mode*) (if (not canna:*japanese-mode*) (canna-toggle-japanese-mode))) ((boundp 'egg:*mode-on*) (and (not egg:*mode-on*) (not egg:*input-mode*) (egg:toggle-egg-mode-on-off))) ((and (fboundp 'skk-mode) (boundp 'skk-mode)) (if (get 'YaTeX-jmode-on 'skkkata) (skk-j-mode-on t) (skk-mode 1)) (put 'YaTeX-jmode-on 'skkkata nil)) ((fboundp 'toggle-input-method) (if (not current-input-method) (toggle-input-method))) ((and (fboundp 'fep-force-on) (fep-force-on))))) (defun YaTeX-jmode-back () (if (get 'YaTeX-jmode 'jmode) (YaTeX-jmode-on)) (setplist 'YaTeX-jmode nil)) (defun YaTeX-self-insert (arg) (call-interactively (global-key-binding (char-to-string (YaTeX-last-key))))) (defun YaTeX-insert-inherit (&rest args) (apply (if (fboundp 'insert-and-inherit) 'insert-and-inherit 'insert) args)) (defun YaTeX-insert-brackets (arg) \"Insert Kagi-kakko or \\\\ [ \\$ pair or simply $.\" (interactive \"p\") (let ((col (1- (current-column)))) (cond ((YaTeX-region-active-p) (YaTeX-insert-brackets-region (region-beginning) (region-end))) ((YaTeX-jmode) (YaTeX-self-insert arg)) ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) ((save-excursion (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at \"\\\\\\\\left\")) (YaTeX-insert-inherit \"[\\\\right]\") (forward-char -7)) ((save-excursion ;from matsu<at>math.s.chiba-u.ac.jp (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at \"\\\\\\\\[bB]igl\")) (YaTeX-insert-inherit (concat \"[\" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) \"r]\")) (forward-char -6)) ((save-excursion (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at \"\\\\\\\\[bB]iggl\")) (YaTeX-insert-inherit (concat \"[\" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) \"r]\")) (forward-char -7)) ;matsu's hack ends here ((and (= (preceding-char) ?\\\\ ) (/= (char-after (- (point) 2)) ?\\\\ ) (not (YaTeX-in-math-mode-p))) (YaTeX-insert-inherit (YaTeX-last-key) \"\\n\") (indent-to (max 0 col)) (YaTeX-insert-inherit \"\\$\")\n(beginning-of-line)\n(open-line 1)\n(delete-region (point) (progn (beginning-of-line) (point)))\n(indent-to (+ YaTeX-environment-indent (max 0 col)))\n(or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1)))\n((YaTeX-closable-p)\n(YaTeX-insert-inherit \"[]\")\n(backward-char 1))\n(t (YaTeX-self-insert arg)))))\n\n(defun YaTeX-insert-brackets-region (beg end)\n(interactive \"r\")\n(YaTeX-insert-braces-region beg end \"[\" \"]\"))\n\n(defun YaTeX-insert-parens (arg)\n\"Insert parenthesis pair.\"\n(interactive \"p\")\n(cond\n((YaTeX-region-active-p)\n(YaTeX-insert-parens-region (region-beginning) (region-end)))\n((YaTeX-jmode) (YaTeX-self-insert arg))\n((not (YaTeX-closable-p)) (YaTeX-self-insert arg))\n((save-excursion\n(and (> (- (point) (point-min)) 5) (forward-char -5))\n(looking-at \"\\\\\\\\left\"))\n(YaTeX-insert-inherit \"(\\\\right)\")\n(forward-char -7))\n((save-excursion\t\t\t;from matsu<at>math.s.chiba-u.ac.jp\n(and (> (- (point) (point-min)) 5) (forward-char -5))\n(looking-at \"\\\\\\$bB]igl\")) (YaTeX-insert-inherit (concat \"(\" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) \"r)\")) (forward-char -6)) ((save-excursion (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at \"\\\\\\\\[bB]iggl\")) (YaTeX-insert-inherit (concat \"(\" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) \"r)\")) (forward-char -7)) ((= (preceding-char) ?\\\\ ) ;matsu's hack ends here (YaTeX-insert-inherit \"(\\\\)\") (backward-char 2)) ((YaTeX-closable-p) (YaTeX-insert-inherit \"()\") (backward-char 1)) (t (YaTeX-self-insert arg)))) (defun YaTeX-insert-parens-region (beg end) (interactive \"r\") (YaTeX-insert-braces-region beg end \"(\" \")\")) (defun YaTeX-insert-bar (arg) \"Insert bar pair.\" (interactive \"p\") (cond ((YaTeX-jmode) (YaTeX-self-insert arg)) ((not (YaTeX-closable-p)) (YaTeX-self-insert arg)) ((save-excursion (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at \"\\\\\\\\left\")) (YaTeX-insert-inherit \"|\\\\right|\") (forward-char -7)) ((save-excursion ;from matsu<at>math.s.chiba-u.ac.jp (and (> (- (point) (point-min)) 5) (forward-char -5)) (looking-at \"\\\\\\\\[bB]igl\")) (insert (concat \"|\" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) \"r|\")) (forward-char -6)) ((save-excursion (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at \"\\\\\\\\[bB]iggl\")) (insert (concat \"|\" (buffer-substring (match-beginning 0) (- (match-end 0) 1)) \"r|\")) (forward-char -7)) ((save-excursion ; added by Jin <MAF01011<at>nifty.ne.jp> (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at \"\\\\\\\\left\\\\\\\\\")) (YaTeX-insert-inherit \"|\\\\right\\\\|\") (forward-char -8)) ((save-excursion (and (> (- (point) (point-min)) 6) (forward-char -6)) (looking-at \"\\\\\\\\[bB]igl\\\\\\\\\")) (insert (concat \"|\" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) \"r\\\\|\")) (forward-char -7)) ((save-excursion (and (> (- (point) (point-min)) 7) (forward-char -7)) (looking-at \"\\\\\\\\[bB]iggl\\\\\\\\\")) (insert (concat \"|\" (buffer-substring (match-beginning 0) (- (match-end 0) 2)) \"r\\\\|\")) (forward-char -8)) ; added by Jin up to here. ((= (preceding-char) ?\\\\ ) (YaTeX-insert-inherit \"|\\\\|\") (backward-char 2)) ; ((and (YaTeX-closable-p) ; (/= (preceding-char) ?|) ; (/= (following-char) ?|)) ; (YaTeX-insert-inherit \"||\") ; (backward-char 1)) (t (YaTeX-self-insert arg)))) (defvar YaTeX-use-jmode-hook (and (featurep 'canna) (boundp 'canna:*initialized*) canna:*initialized*) ;; (not (and (fboundp 'skk-mode) (boundp 'skk-mode))) \"*Non-nil means activate automatic jmode switcher within/out math mode. Hopefully, change default to t in the next version of 1.75.\") (defun YaTeX-jmode-hook (old new) \"A hook controling jmode on/off.\" ;; This function is called via point-entered/leave hook, so that ;; codes in it is evaluated on such emacsen as having text-properties. (let ((inhibit-point-motion-hooks t) (oldp (plist-get (text-properties-at old) 'point-left)) (newp (plist-get (text-properties-at new) 'point-left)) (lnew (plist-get (text-properties-at new) 'last-new)) (mjmode (plist-get (text-properties-at new) 'mjmode)) (bmp (buffer-modified-p)) (jm (YaTeX-jmode)) b e) (unwind-protect (cond ((eq lnew new) nil) ;Do nothing if continuous entry ((and (not (eq newp 'YaTeX-jmode-hook)) (eq oldp 'YaTeX-jmode-hook) (plist-get (text-properties-at old) 'entered)) ;; leave (remove-text-properties (setq b (1+ (or (previous-single-property-change old 'point-left) (1- (point))))) (setq e (1- (or (next-single-property-change old 'point-left) (1+ (point))))) (list 'last-new nil 'entered nil)) (add-text-properties b e (list 'mjmode jm)) (if (boundp 'skk-katakana) (put 'YaTeX-jmode-on 'skkkata skk-katakana)) (if (plist-get (text-properties-at old) 'jmode) (YaTeX-jmode-on))) ((and (not (eq oldp 'YaTeX-jmode-hook)) (eq newp 'YaTeX-jmode-hook) (not (plist-get (text-properties-at new) 'entered))) ;; enter (add-text-properties (1+ (or (previous-single-property-change new 'point-left) (1- (point)))) (1- (or (next-single-property-change new 'point-left) (1+ (point)))) (list 'jmode jm 'last-new new 'entered t)) (if (boundp 'skk-katakana) ;care for skk katakana mode (put 'YaTeX-jmode-on 'skkkata skk-katakana)) (if mjmode (YaTeX-jmode-on) (YaTeX-jmode-off)))) ;;unwind job (set-buffer-modified-p bmp)))) (defun YaTeX-insert-dollar () (interactive) (if (or (not (YaTeX-closable-p)) (= (preceding-char) 92) (and (YaTeX-in-math-mode-p) (or (/= (preceding-char) ?) (/= (following-char) ?)))) (insert \"\") (insert \"\") (forward-char -1) (and YaTeX-use-jmode-hook (fboundp 'add-text-properties) (add-text-properties (1- (point)) (1+ (point)) (list 'point-left 'YaTeX-jmode-hook 'point-entered 'YaTeX-jmode-hook 'front-sticky t 'rear-nonsticky t 'mjmode nil 'jmode (YaTeX-jmode)))) (YaTeX-jmode-off) (or YaTeX-auto-math-mode YaTeX-math-mode (YaTeX-toggle-math-mode 1)))) (defun YaTeX-insert-dollars-region (beg end) (interactive \"r\") (YaTeX-insert-braces-region beg end \"\" \"\")) (defun YaTeX-insert-amper () (interactive) (if (or (string-match YaTeX-array-env-regexp (or (YaTeX-inner-environment t) \"document\")) (= (preceding-char) 92) (YaTeX-literal-p) (YaTeX-in-math-mode-p)) (insert \"&\") (insert \"\\\\&\"))) (defun YaTeX-version () \"Return string of the version of running YaTeX.\" (interactive) (message (concat \"Yet Another tex-mode \" (if YaTeX-japan \"「野鳥」\" \"Wild Bird'\") \" Revision \" YaTeX-revision-number))) (defun YaTeX-typeset-menu (arg &optional char) \"Typeset, preview, visit error and miscellaneous convenient menu. Optional second argument CHAR is for non-interactive call from menu.\" (interactive \"P\") (message (concat \"J)latex R)egion E)nv B)ibtex mk(I)dx \" \"latex+p(D)f \" (if (fboundp 'start-process) \"K)ill \") \"P)review \" (and (boundp 'window-system) window-system \"S)earch \") \"V)iewErr L)pr\")) (let ((sw (selected-window)) (c (or char (read-char)))) (require 'yatexprc) ;for Nemacs's bug (select-window sw) (cond ((memq c '(?j ?\\C-j)) (YaTeX-typeset-buffer) ; memq for usability test (put 'dvi2-command 'format 'dvi)) ((= c ?r) (YaTeX-typeset-region)) ((= c ?e) (YaTeX-typeset-environment)) ((= c ?b) (YaTeX-call-builtin-on-file \"BIBTEX\" bibtex-command arg)) ((= c ?i) (YaTeX-call-builtin-on-file \"MAKEINDEX\" makeindex-command arg)) ((= c ?k) (YaTeX-kill-typeset-process YaTeX-typeset-process)) ((= c ?p) (call-interactively 'YaTeX-preview)) ((= c ?q) (YaTeX-system \"lpq\" \"Printer queue\")) ((= c ?d) (YaTeX-typeset-buffer (or (YaTeX-get-builtin \"DVIPDF\") YaTeX-dvipdf-command)) (put 'dvi2-command 'format 'pdf)) ((= c ?v) (YaTeX-view-error)) ((= c ?l) (YaTeX-lpr arg)) ((= c ?m) (YaTeX-switch-mode-menu arg)) ((= c ?s) (YaTeX-xdvi-remote-search arg))))) (if (fboundp 'wrap-function-to-control-ime) (wrap-function-to-control-ime 'YaTeX-typeset-menu t \"P\")) (defun YaTeX-%-menu (&optional beg end char) \"Operate %# notation.\" ;;Do not use interactive\"r\" for the functions which require no mark (interactive) (message \"!)Edit-%%#! D)VIPDF B)EGIN-END P)review pdf(V)iew L)PR M)akeidx b)ibtex dp(I)\") (let ((c (or char (read-char))) (string \"\") key (b (make-marker)) (e (make-marker))) (save-excursion (cond ((rindex \"!plmibdv\" c) ;Edit %#xxx (setq key (cdr (assq c '((?! . \"!\") (?p . \"PREVIEW\") (?l . \"LPR\") (?m . \"MAKEINDEX\") (?d . \"DVIPDF\") (?v . \"PDFVIEW\") (?i . \"IMAGEDPI\") (?b . \"BIBTEX\"))))) (YaTeX-getset-builtin key t)) ((= c ?B) ;%#BEGIN %#END region (or end (setq beg (min (point) (mark)) end (max (point) (mark)))) (set-marker b beg) (set-marker e end) (goto-char (point-min)) (while (re-search-forward \"^%#\\$$BEGIN\\$$\\\\|\\$$END\\$$\" nil t) (beginning-of-line) (delete-region (point) (progn (forward-line 1) (point)))) (goto-char b) (open-line 1) (delete-region (point) (progn (beginning-of-line)(point)));for 19 :-< (insert \"%#BEGIN\") (goto-char e) (insert \"%#END\\n\") (set-marker b nil) (set-marker e nil)))))) (defvar YaTeX-refcommand-def-regexp-default \"label\\\\|bibitem\") (defvar YaTeX-refcommand-def-regexp-private nil \"*Regexp of defining label commands\") (defvar YaTeX-refcommand-def-regexp (concat (if YaTeX-refcommand-def-regexp-private (concat YaTeX-refcommand-def-regexp-private \"\\\\|\")) YaTeX-refcommand-def-regexp-default)) (defvar YaTeX-refcommand-ref-regexp-default \"\\$$page\\\\|eq\\\\|fig\\$$?ref\\\\|cite\" \"Regexp of LaTeX's label-referring macros. Searching for this will be done without \\\\\\\\'. So you need not add patterns if new referring macro ends with \\\"ref\\\".\") (defvar YaTeX-refcommand-ref-regexp-private nil \"*Regexp of referring label commands. See documentation of YaTeX-refcommand-ref-regexp-default'.\") (defvar YaTeX-refcommand-ref-regexp (concat (if YaTeX-refcommand-ref-regexp-private (concat YaTeX-refcommand-ref-regexp-private \"\\\\|\")) YaTeX-refcommand-ref-regexp-default)) (defvar YaTeX-refcommand-regexp (concat YaTeX-refcommand-def-regexp \"\\\\|\" YaTeX-refcommand-ref-regexp) \"Regexp of label defining/referring command name.\") (defun YaTeX-goto-corresponding-label (reverse &optional otherwin) \"Jump to corresponding \\\\label{} and \\\\ref{} or \\\\cite and \\\\bibitem. The default search direction depends on the command at the cursor position. When the cursor is on \\\\ref(\\\\cite), YaTeX will try to search the corresponding \\\\label(\\\\bibitem) backward, and if it fails search forward again. And when the cursor is on \\\\label(\\\\bibitem), YaTeX will search the corresponding \\\\ref(\\\\cite) forward at first and secondary backward. Argument REVERSE non-nil makes the default direction rule reverse. Since Search string is automatically set in search-last-string, you can repeat search the same label/ref by typing \\\\[isearch-forward] or \\\\[isearch-backward]. If optional second argument OTHERWIN is non-nil, move to other window.\" (let ((scmd \"\") label direc string blist (p (point)) (cb (current-buffer)) (refcommands YaTeX-refcommand-regexp) (foundmsg (format \"Type %s %c to return to original position.\" (key-description (car (or (where-is-internal 'register-to-point) (where-is-internal 'jump-to-register)))) YaTeX-current-position-register)) (func (function (lambda (string sfunc) (or (funcall sfunc string nil t) (funcall (if (eq sfunc 're-search-forward) 're-search-backward 're-search-forward) string nil t)))))) (cond ((YaTeX-on-section-command-p refcommands) (setq scmd (cdr (assoc (YaTeX-match-string 1) '((\"label\" . \"\\\\\\\\\\$$page\\\\|eq\\$$?ref{%k}\") (\"ref\" . \"\\\\\\\\label{%k}\") (\"eqref\" . \"\\\\\\\\label{%k}\") (\"pageref\" . \"\\\\\\\\label{%k}\") (\"cite\" . \"\\\\\\\\bibitem\\$$\\\\[[^]]+\\$\\$$?{%k}\\\\|^\\\\s *@[a-z]+{%k,\")\n(\"bibitem\" . \"\\\\\\\\cite\\$$\\$[^]]+\\$\\$$?\")))))\n(goto-char (match-end 0))\n(let ((label (YaTeX-buffer-substring\n(1- (point)) (progn (backward-list 1) (1+ (point)))))\n(fp (make-marker))fl fn\n(goother (function (lambda (buffer point)\n(goto-char point)\n(if (one-window-p)\n(split-window-calculate-height\nYaTeX-default-pop-window-height))\n(select-window (get-lru-window))\n(switch-to-buffer buffer)))))\n;(setq string (concat \"\\\\\" scmd \"{\" label \"}\"))\n;(setq string (concat \"\\\\\\\\\" scmd \"{\" (regexp-quote label) \"}\"))\n(setq string (YaTeX-replace-format scmd \"k\" (regexp-quote label)))\n(setq direc (if (string-match \"ref\\\\|cite\" scmd)\n're-search-forward 're-search-backward))\n(if YaTeX-current-position-register\n(point-to-register YaTeX-current-position-register))\n(if reverse (setq direc (if (eq direc 're-search-forward)\n're-search-backward 're-search-forward)))\n(if (funcall func string direc)\t;label/ref found!\n(progn\n(if otherwin (funcall goother cb p))\n(goto-char (match-beginning 0))\n(push-mark p))\n(goto-char p)\t\t\t;resume position of current buffer\n(catch 'found\n(setq blist (YaTeX-yatex-buffer-list))\n(while blist\n;; search for corresponding keyword\n(set-buffer (car blist))\n(if (YaTeX-on-section-command-p refcommands)\n(goto-char (match-beginning 0)))\n(cond\n; cond1\n((funcall func string direc)\n(cond\n(otherwin\n(set-buffer cb)\n(funcall goother (car blist) p))\n((or (get-buffer-window (car blist))\n(and YaTeX-emacs-19\n(get-buffer-window (car blist) t)))\n(goto-buffer-window (car blist)))\n(t\n(switch-to-buffer (car blist))\n(message foundmsg)))\n(goto-char (match-beginning 0))\n(throw 'found t))\n; cond2\n((and\n(string-match \"bibitem\" scmd)\n(catch 'found2\n(save-excursion\n(goto-char (point-min))\n(while (YaTeX-re-search-active-forward\n\"\\\\\\\\bibliography{\\$$[^}]*\\$$}\" \"%\" nil t)\n(setq fl (YaTeX-split-string (YaTeX-match-string 1) \",\"))\n(while fl\n(if (or (file-exists-p (setq fn (car fl)))\n(file-exists-p (setq fn (concat fn \".bib\"))))\n(progn\n(set-buffer (find-file-noselect fn))\n(save-excursion\n(goto-char (point-min))\n(if (YaTeX-re-search-active-forward\nstring \"%\" nil t)\n(throw 'found2\n(set-marker fp (point)))))))\n(setq fl (cdr fl)))))))\n(if otherwin\n(funcall goother (marker-buffer fp) fp)\n(switch-to-buffer (marker-buffer fp))\n(goto-char fp))\n(set-marker fp nil)\n(message foundmsg)\n(throw 'found t)))\n(setq blist (cdr blist)))\n;; search for bibliography\n)))\n(if YaTeX-emacs-19\n(setq regexp-search-ring\n(cons string (delete string regexp-search-ring)))\n(setq search-last-regexp string)))\n(t nil))))\n\n;;YaTeX-goto-corresponding-environment was moved to yatexlib\n\n(defun YaTeX-goto-corresponding-file (&optional other)\n\"Visit or switch buffer of corresponding file,\nlooking at \\\\input or \\\\include or \\\\includeonly on current line.\"\n(if (not (YaTeX-on-includes-p)) nil\n(let ((parent buffer-file-name) input-file b)\n(save-excursion\n(if (and (re-search-forward \"[{%]\" (point-end-of-line) t)\n(= ?{ (char-after (match-beginning 0))))\nnil\n(skip-chars-backward \"^,{\"))\n(setq input-file\n(YaTeX-buffer-substring\n(point) (progn (skip-chars-forward \"^ ,}\") (point))))\n(if (not (string-match \"\\\\.\\$$tex\\\\|sty\\$$$\" input-file)) (setq input-file (concat input-file \".tex\")))) (cond (other (YaTeX-switch-to-buffer-other-window input-file)) ((setq b (YaTeX-get-file-buffer input-file)) (goto-buffer-window b)) (t (YaTeX-switch-to-buffer input-file))) (or (YaTeX-get-builtin \"!\") YaTeX-parent-file (setq YaTeX-parent-file parent))))) (defun YaTeX-goto-corresponding-BEGIN-END () (if (not (YaTeX-on-BEGIN-END-p)) nil (if (cond ((equal (match-beginning 0) (match-beginning 1)) ;if on %#BEGIN (not (search-forward \"%#END\" nil t))) (t ; if on %#END (not (search-backward \"%#BEGIN\" nil t)))) (error \"Corresponding %%#BEGIN/END not found.\")) (beginning-of-line) t)) (defvar YaTeX-processed-file-regexp-alist nil \"Alist of regexp of processed file regexp vs. its file name part; For example, if you include image file with \\\\epsfile{file=FILE}' where FILE' is processed file. You might want to view FILE with other previewer such as ghostview, or want to preview its source which was drawn with other drawing tool, tgif for example. Then you should set entire regexp of including expression and enclose its file name part with \\\\\\$$and \\\\\\$$. Ex. (\\\"\\\\\\\\\\\\\\\\epsfile{[^}]*file=\\\\\\$$[^,} ]+\\\\\\$$\\\\\\$$\\\\\\\\.e?ps\\\\\\$$?[^}]*}\\\" 1) Where the first group surrounded by \\\\\\$$and \\\\\\$$ is the file name part of expression. So you should set 1 to second element. And the first matching group is sent to (image) processor defined by the variable YaTeX-file-processor-alist. See also the documentation of YaTeX-file-processor-alist. ↑じゃ良くわかんないすね。例えば tgif hoge.obj して hoge.eps を \\\\epsfile{file=hoge.eps} でインクルードしているとしよう。その行で $prefix$ g を押した時に tgif を起動して欲しかったら、まず上のような 正規表現を設定する。\\\\\\$$と\\\\\\$$で囲んだところがファイル名になるように 注意する。でファイル名部分が何番目の\\\\\\$$\\\\\\$$になるかをリストの2番目に書く。 すると、その部分が変数 YaTeX-file-processor-alist で定義された 処理プログラムに渡される。というわけ。 ん〜やっぱりむずかしいね。分からない時は隣の Lisper に聞くか、 fj野鳥の会で聞こう! \") (defvar YaTeX-processed-file-regexp-alist-default '((\"\\\\\\\\epsfile\\$$\\$[^]]+\\$\\$$?{[^},]*file=\\$$\\\\([^,} ]*/\\$$?[^,}. ]+\\\\)\\$$\\\\.e?ps\\$$?[^}]*}\" 2) (\"\\\\\\\\epsfig{[^},]*fi\\$$le\\\\|gure\\$$=\\$$\\\\([^,} ]*/\\$$?[^,}. ]+\\\\)\\$$\\\\.e?ps\\$$?[^}]*}\" 2) (\"\\\\\\\\postscriptbox{[^}]*}{[^}]*}{\\$$\\\\([^,} ]*/\\$$?[^}. ]+\\\\)\\$$\\\\.e?ps\\$$?}\" 1) (\"\\\\\\\\\\$$epsfbox\\\\|epsfig\\$$\\\\*?{\\$$\\\\([^,} ]*/\\$$?[^}. ]+\\\\)\\$$\\\\.e?ps\\$$?}\" 2) ;\\epsfbox{hoge.ps} (\"\\\\\\\\includegraphics\\\\*?\\$$.*\\\\]\\\\|\\\\s \\$$?{\\$$.*\\$$\\$$\\\\.ai\\\\|\\\\.pdf\\\\|\\\\.svg\\\\|\\\\.png\\\\|\\\\.jpe?g\\\\|\\\\.e?ps\\$$}\" 2) ;\\includegraphics[options...]{hoge.eps} (\"\\\\\\\\\\$$psbox\\$$\\$$\\$[^]]+\\$\\$$?{\\$$\\\\([^,} ]*/\\$$?[^} ]+\\\\)\\$$\\\\.e?ps\\$$}\" 3) ;\\psbox[options...]{hoge.eps} (97/1/11) (\"\\\\\\\\input{\\$$[^} ]+\\$$\\$$\\\\.tps\\$$}\" 1) ;tgif2tex (1998/9/16) ) \"See the documentation of YaTeX-processed-file-regexp-alist.\") (defvar YaTeX-file-processor-alist nil \"*Alist of files' processor vs. its extension; See also the documentation of YaTeX-processed-file-regexp-alist.\") (defvar YaTeX-file-processor-alist-default (list (cons YaTeX-cmd-tgif \".obj\") (cons YaTeX-cmd-gimp \".xcf\") (cons YaTeX-cmd-gimp \".xcf.gz\") (cons YaTeX-cmd-gimp \".xcf.bz2\") (cons YaTeX-cmd-edit-svg \".svg\") (cons YaTeX-cmd-edit-svg \".svgz\") (cons YaTeX-cmd-edit-ai \".ai\") '(\"dia\" . \".dia\") (cons YaTeX-cmd-ooo \".odg\") (cons YaTeX-cmd-edit-images \".jpeg\") (cons YaTeX-cmd-edit-images \".jpg\") (cons YaTeX-cmd-edit-images \".png\") (cons YaTeX-cmd-edit-ps \".ps\") (cons YaTeX-cmd-edit-ps \".eps\") (cons YaTeX-cmd-edit-pdf \".pdf\") '(t . \".tex\") '(t . \".sty\") '(t . \"\")) \"See the documentation of YaTeX-file-processor-alist.\") (defun YaTeX-goto-corresponding-file-processor (&optional other) \"Execute corresponding file processor.\" (save-excursion (or (looking-at YaTeX-ec-regexp) (skip-chars-backward (concat \"^\" YaTeX-ec) (point-beginning-of-line))) (let ((list (append YaTeX-processed-file-regexp-alist YaTeX-processed-file-regexp-alist-default)) (p (point)) flist file (peol (point-end-of-line)) (basedir (if YaTeX-search-file-from-top-directory (save-excursion (YaTeX-visit-main t) default-directory) \".\"))) (setq flist (catch 'found (while list (goto-char p) (if (re-search-forward (car (car list)) peol t) (progn (setq file (YaTeX-match-string (car (cdr (car list))))) (throw 'found (cdr (car list))))) (setq list (cdr list))))) (if flist ;if pattern and file name found (let*((plist (append YaTeX-file-processor-alist YaTeX-file-processor-alist-default)) (plist0 plist) ext cmd src buf (alt (car (cdr flist)))) (if (and (re-search-forward (concat YaTeX-comment-prefix \"\\\\s *\\$$.*\\$$$\") peol t)\n(assoc (setq cmd (YaTeX-match-string 1))\nYaTeX-file-processor-alist))\n(setq src\t\t;if processor is specified\n(concat file\n(cdr (assoc cmd YaTeX-file-processor-alist))))\n(while plist\t\t;if processor is not specified\n(setq ext (cdr (car plist)))\n(if (and (string< \"\" (concat file ext))\n(file-exists-p\n(expand-file-name (concat file ext) basedir)))\n(setq cmd (car (car plist))\nsrc (concat file ext) plist nil))\n(setq plist (cdr plist)))\n(if (and (null src) alt YaTeX-create-file-prefix-g)\n(setq cmd alt\nsrc (concat file (cdr (assoc alt plist0))))))\n(if src\t\t\t;if processor and src file found\n(let ((default-directory basedir))\n(cond\n((stringp cmd)\n(YaTeX-system (concat cmd \" \" src) cmd)\nt)\n((eq t cmd)\n(let ((parent buffer-file-name))\n(funcall\n(cond\n(other 'YaTeX-switch-to-buffer-other-window)\n((get-file-buffer src) 'goto-buffer-window)\n(t 'YaTeX-switch-to-buffer))\nsrc)\n(or (YaTeX-get-builtin \"!\")\nYaTeX-parent-file\n(setq YaTeX-parent-file parent))\nt))\n((symbolp cmd)\n(cond\n((symbol-function cmd)\n(funcall cmd src other)))\nt)))))))))\n\n(defun YaTeX-on-section-command-p (command)\n\"Check if point is on the LaTeX command: COMMAND(regexp).\nReturn nil if point is not on it. Otherwise return the\nnumber of argument position.\nSection command name is stored in match-data #1.\nParsing information is stored to plist.\nMacros name stored to propname 'command.\nMacro's argument number stored to propname 'argc.\"\n(let ((p (point)) md (parg 0) (argc 1) word (grouping 0) (i 0)\n(ec+command (concat YaTeX-ec-regexp \"\\$$\" command \"\\$$\")))\n(setplist 'YaTeX-on-section-command-p nil)\n(while (setq i (string-match \"\\\\\\$$\" command i)) (setq grouping (1+ grouping) i (+ i 2))) (save-excursion (if (looking-at ec+command) nil (catch 'found ;caught value has no meaning ;;(1) looking at current position (and (looking-at command) (save-excursion (while (and (not (bobp)) (looking-at command)) (forward-char -1)) (looking-at ec+command)) (goto-char (match-beginning 0)) (throw 'found t)) ;;If inside of parentheses, try to escape. (unwind-protect (progn (set-syntax-table YaTeX-mode-syntax-table-nonparen) (while (and (not (= (preceding-char) ?\\])) ;skip optional arg (condition-case err (progn (up-list -1) t) (error nil))))) (set-syntax-table YaTeX-mode-syntax-table)) (while (equal (preceding-char) ?\\]) (backward-list)) ;;(2) search command directly (skip-chars-forward \"^{}[]\") (and (YaTeX-re-search-active-backward ec+command YaTeX-comment-prefix nil t) (>= p (match-beginning 0)) (throw 'found (goto-char (match-beginning 0)))) ;;(3) search token (goto-char p) (while t (if (bobp) (throw 'found nil)) (cond ((looking-at YaTeX-ec-regexp) (throw 'found t)) ((looking-at \"[[{]\") nil) ((looking-at \"[]}]\")(condition-case nil (up-list -1) (error nil))) (t (skip-chars-backward \" \\t\\r\\n\"))) (skip-chars-backward (concat \"^ \\t\\r\\n{}[]\" YaTeX-ec-regexp)) (or (bobp) (forward-char -1))))) (if (and (looking-at (concat ec+command \"\\\\(\\\\(\\$[^]]+\\$\\\\|([0-9,]+)\\$$*\\\\)\"\t;optional arg\n;\"[ \\t\\n\\r]*{[^}]+}\")) ;arg braces\n\"[ \\t\\n\\r]*{[^}]*}\")) ;arg braces\n(not (YaTeX-lookup-table\n(setq word (YaTeX-match-string 1)) 'singlecmd)))\n(progn\n(setq md (match-data))\n(skip-chars-forward \"^{\")\n(if (<= (point) p) (setq parg (1+ parg)))\n(setq argc\n(or (car (cdr (YaTeX-lookup-table word 'section)))\nargc))\n(put 'YaTeX-on-section-command-p 'argc argc)\n(put 'YaTeX-on-section-command-p 'command argc)\n(while (and (>= (setq argc (1- argc)) 0)\n(progn (skip-chars-forward \" \\t\\n\\r\")\n(looking-at \"{\")))\n(forward-list 1)\n(if (<= (point) p) (setq parg (1+ parg))))\n(store-match-data md)\n(setq i (+ 2 grouping))\n(if (and (match-beginning i)\n(>= p (match-beginning i)) (< p (match-end i)))\n-1\t\t\t;return -1 if point is on optional arg\n(if (< p (point)) parg))\n)))))\n\n(defun YaTeX-on-maketitle-p ()\n\"Check if point is on maketitle type commands.\nCall this function after YaTeX-on-section-command-p.\"\n(let ((p (point)))\n(save-excursion\n(or (= (char-after (point)) ?\\\\ )\n(progn\n(skip-chars-backward\n(concat \"^\" YaTeX-ec-regexp) (point-beginning-of-line))\n(or (bobp) (bolp) (backward-char 1))))\n(and (looking-at (concat YaTeX-ec-regexp YaTeX-TeX-token-regexp))\n(<= (match-beginning 0) p)\n(> (match-end 0) p)))))\n\n(defun YaTeX-on-begin-end-p ()\n(save-excursion\n(if (and (boundp 'in-leftright-p) in-leftright-p)\n;; Dirty workaround for YaTeX-goto-corresponding-leftright 2003/3/28\n(let ((md (match-data)))\t; for safety\n(if (looking-at YaTeX-ec-regexp)\nnil\t\t\t; stay here\n(cond\n((looking-at \"\\\\w\")\t\t(skip-chars-backward \"A-Za-z\"))\n((looking-at \"\\\\.()\\$\\$|\")\t(forward-char -1)))\n(if (equal (char-after (1- (point)))\n(string-to-char YaTeX-ec))\n(forward-char -1))))\n;(beginning-of-line)\n(if (equal (char-after (point)) ?\\\\) nil\t;stay here\n(skip-chars-backward \"^\\n\\\\\\\\\")\n(or (bolp) (forward-char -1))))\n(re-search-forward\n;;\"\\\\\\\\begin{\\$$[^}]+\\$$}\\\\|\\\\\\\\end{\\$$[^}]+\\$$}\"\n(concat\n(YaTeX-replace-format-args\n(regexp-quote YaTeX-struct-begin)\n(concat \"\\$$\" YaTeX-struct-name-regexp \"\\$$\") \"\" \"\" \"\")\n\"\\\\|\"\n(YaTeX-replace-format-args\n(regexp-quote YaTeX-struct-end)\n(concat \"\\$$\" YaTeX-struct-name-regexp \"\\$$\") \"\" \"\" \"\")\n\"\\\\|\\$$\" YaTeX-ec-regexp ;;\"[][()]\\$$\"\n\"[\\\\]\\$]\\\\)\" ) (point-end-of-line) t))) (defun YaTeX-on-includes-p () (save-excursion (beginning-of-line) (re-search-forward \"\\$$\\\\(include[^}]*\\$$\\\\|\\$$input\\$$\\\\){[^}]*}\" (point-end-of-line) t))) (defun YaTeX-on-comment-p (&optional sw) \"Return t if current line is commented out. Optional argument SW t to treat all %' lines as comment, even if on %#' notation.\" (save-excursion (beginning-of-line) (skip-chars-forward \"\\\\s \") (looking-at (if sw \"%\" \"%[^#]\")))) (defun YaTeX-on-BEGIN-END-p () (save-excursion (let ((case-fold-search nil)) (beginning-of-line) (re-search-forward \"\\$$%#BEGIN\\$$\\\\|\\$$%#END\\$$\" (point-end-of-line) t)))) (defun YaTeX-goto-corresponding-* (arg) \"Parse current line and call suitable function.\" (interactive \"P\") (let (mm) (cond ((YaTeX-goto-corresponding-label arg)) ((YaTeX-goto-corresponding-environment)) ((YaTeX-goto-corresponding-file-processor arg)) ((YaTeX-goto-corresponding-file arg)) ((YaTeX-goto-corresponding-BEGIN-END)) ((and (setq mm (YaTeX-in-math-mode-p)) (YaTeX-goto-corresponding-leftright))) ((and ;;mm YaTeX-use-AMS-LaTeX (YaTeX-goto-corresponding-paren))) ;;((and (string-match ;; YaTeX-equation-env-regexp ;to delay loading ;; (or (YaTeX-inner-environment t) \"document\")) ;; (YaTeX-goto-corresponding-leftright))) ((YaTeX-goto-corresponding-viewer)) (t (message \"I don't know where to go.\"))))) (defun YaTeX-goto-corresponding-*-other-window (arg) \"Parse current line and call suitable function.\" (interactive \"P\") (cond ((YaTeX-goto-corresponding-label arg t)) ;;((YaTeX-goto-corresponding-environment)) ((YaTeX-goto-corresponding-file t)) ;;((YaTeX-goto-corresponding-BEGIN-END)) (t (message \"I don't know where to go.\")))) (defun YaTeX-comment-region (alt-prefix) \"Comment out region by '%'. If you call this function on the 'begin{}' or 'end{}' line, it comments out whole environment\" (interactive \"P\") (if (not (YaTeX-on-begin-end-p)) (comment-out-region (if alt-prefix (read-string-with-history \"Insert prefix: \") YaTeX-comment-prefix)) (YaTeX-comment-uncomment-env 'comment-out-region))) (defun YaTeX-uncomment-region (alt-prefix) \"Uncomment out region by '%'.\" (interactive \"P\") (if (not (YaTeX-on-begin-end-p)) (uncomment-out-region (if alt-prefix (read-string-with-history \"Remove prefix: \") YaTeX-comment-prefix) (region-beginning) (region-end) YaTeX-uncomment-once) (YaTeX-comment-uncomment-env 'uncomment-out-region))) (defun YaTeX-comment-uncomment-env (func) \"Comment or uncomment out one LaTeX environment switching function by FUNC.\" (let (beg (p (point))) (save-excursion (beginning-of-line) (setq beg (point)) (YaTeX-goto-corresponding-environment) (beginning-of-line) (if (> p (point)) (setq beg (1+ beg)) (forward-char 1)) (funcall func YaTeX-comment-prefix beg (point) YaTeX-uncomment-once))) (message \"%sommented out current environment.\" (if (eq func 'comment-out-region) \"C\" \"Un-c\"))) (defun YaTeX-comment-paragraph () \"Comment out current paragraph.\" (interactive) (save-excursion (cond ((YaTeX-on-begin-end-p) (beginning-of-line) (insert YaTeX-comment-prefix) (YaTeX-goto-corresponding-environment) (beginning-of-line) (insert YaTeX-comment-prefix)) ((YaTeX-on-comment-p) (message \"Already commented out.\")) (t (mark-paragraph) (if (looking-at paragraph-separate) (forward-line 1)) (comment-out-region \"%\"))))) (defun YaTeX-uncomment-paragraph () \"Uncomment current paragraph.\" (interactive) (save-excursion (if (YaTeX-on-begin-end-p) (let ((p (point-marker))) (YaTeX-goto-corresponding-environment) (YaTeX-remove-prefix YaTeX-comment-prefix YaTeX-uncomment-once) (goto-char p) (YaTeX-remove-prefix YaTeX-comment-prefix YaTeX-uncomment-once) (set-marker p nil)) (if (YaTeX-on-comment-p) (let*((fill-prefix \"\") ;;append ^%' to head of paragraph delimiter. (paragraph-start (concat \"^\\\\|^%\\$$\" YaTeX-paragraph-separate \"\\$$\")) (paragraph-separate paragraph-start)) (mark-paragraph) (if (not (bobp)) (forward-line 1)) (uncomment-out-region \"%\" nil nil YaTeX-uncomment-once)) (message \"This line is not a comment line.\"))))) (defun YaTeX-remove-prefix (prefix &optional once) \"Remove prefix on current line as far as prefix detected. But optional argument ONCE makes deletion once.\" (interactive \"sPrefix:\") (beginning-of-line) (while (re-search-forward (concat \"^\" prefix) (point-end-of-line) t) (replace-match \"\") (if once (end-of-line)))) (defun YaTeX-kill-some-pairs (predicate gofunc kill-contents) \"Kill some matching pair. This function assumes that pairs occupy whole of each line where they resid.\" (if (not (funcall predicate)) nil (let ((b1 (match-beginning 0)) (e1 (match-end 0)) b2 e2) (save-excursion (funcall gofunc) (funcall predicate) ;get match data (if (< (point) e1) ;if currently on begin-line (progn (setq b2 b1 e2 e1 b1 (match-beginning 0) e1 (match-end 0)) (goto-char e2)) ;goto end-line's end (setq b2 (match-beginning 0) e2 (match-end 0)) (goto-char e2)) ;now e2 has surely end-line's end (skip-chars-forward \" \\t\") (and (eolp) (not (eobp)) (setq e2 (1+ (point)))) (if (not kill-contents) (kill-region (progn (goto-char b2) (skip-chars-backward \" \\t%\") (if (bolp) (point) b2)) e2)) (goto-char b1) (skip-chars-backward \" \\t%\") (if (not kill-contents) (progn (kill-append (buffer-substring (setq b1 (if (bolp) (point) b1)) (setq e1 (progn (goto-char e1) (while (looking-at \"{\\\\| \\t\") (forward-list 1)) (skip-chars-forward \" \\t\") (if (and (eolp) (not (eobp))) (1+ (point)) (point))))) t) (delete-region b1 e1)) (kill-region (if (bolp) (point) b1) e2))) t))) (defun YaTeX-kill-section-command (point kill-all) \"Kill section-type command at POINT leaving its last argument. Non-nil for the second argument kill its last argument too.\" (let ((cmd (get 'YaTeX-on-section-command-p 'command)) (argc (get 'YaTeX-on-section-command-p 'argc)) beg (end (make-marker))) (save-excursion (goto-char point) (or (looking-at YaTeX-ec-regexp) (progn (skip-chars-backward (concat \"^\" YaTeX-ec-regexp)) (forward-char -1))) (setq beg (point)) (skip-chars-forward \"^{\") (while (> (setq argc (1- argc)) 0) (skip-chars-forward \"^{\") (forward-list 1)) (kill-region beg (point)) (forward-list 1) (set-marker end (point)) (if kill-all (progn (kill-append (buffer-substring beg end) nil) (delete-region beg end)) (goto-char beg) (kill-append (buffer-substring (point) (progn (skip-chars-forward \"^{\" end) (1+ (point)))) nil) (delete-region beg (1+ (point))) (goto-char end) (set-marker end nil) (kill-append (buffer-substring (point) (1- (point))) nil) (delete-backward-char 1))))) (defun YaTeX-kill-paren (kill-contents) \"Kill parentheses leaving its contents. But kill its contents if the argument KILL-CONTENTS is non-nil.\" (interactive \"P\") (let (p bsl (backslash-syntax (char-to-string (char-syntax ?\\\\))) (md (match-data))) (unwind-protect (save-excursion (modify-syntax-entry ?\\\\ \" \") (if (looking-at \"\\\\s(\\\\|\\$$\\\\s)\\$$\") (progn (if (match-beginning 1) (up-list -1)) (if (and (> (point) (point-min)) (= (char-after (1- (point))) ?\\\\ )) (setq p (1- (point)) bsl t) (setq p (point))) (forward-list 1) ;(YaTeX-goto-open-paren t) (if kill-contents (delete-region p (point)) (backward-delete-char 1) (cond ((save-excursion (forward-char -2) (looking-at (concat YaTeX-ec-regexp \"/\"))) (backward-delete-char 2)) ((= (char-after (1- (point))) ?\\\\) (backward-delete-char 1))) (goto-char p) (if (looking-at (concat \"{\" YaTeX-ec-regexp YaTeX-command-token-regexp \"+\" \"\\\\s +\")) (delete-region (point) (match-end 0)) (delete-char 1) (if bsl (delete-char 1)))) t))) (modify-syntax-entry ?\\\\ backslash-syntax) (store-match-data md)))) (defvar YaTeX-read-environment-history nil \"Holds history of environments.\") (put 'YaTeX-read-environment-history 'no-default t) (defun YaTeX-read-environment (prompt &optional predicate must-match initial) \"Read a LaTeX environment name with completion.\" (YaTeX-sync-local-table 'tmp-env-table) (completing-read-with-history prompt (append tmp-env-table user-env-table env-table) predicate must-match initial 'YaTeX-read-environment-history)) (defvar YaTeX-read-section-history nil \"Holds history of section-types.\") (put 'YaTeX-read-section-history 'no-default t) (defun YaTeX-read-section (prompt &optional predicate initial) \"Read a LaTeX section-type command with completion.\" (YaTeX-sync-local-table 'tmp-section-table) (let ((minibuffer-completion-table (append tmp-section-table user-section-table section-table))) (read-from-minibuffer-with-history prompt initial YaTeX-section-completion-map nil 'YaTeX-read-section-history))) (defun YaTeX-read-section-with-overview () \"Read sectioning command with overview. This function refers a local variable source-window' in YaTeX-make-section, because this function is called with no argument.\" (interactive) (require 'yatexsec) ;some case needs this (if (> (minibuffer-depth) 1) (error \"Too many minibuffer levels for overview.\")) (let ((sw (selected-window)) (minibuffer-max-depth nil) ; for XEmacs20 (enable-recursive-minibuffers t) sect) (unwind-protect (progn (select-window source-window) (setq sect (YaTeX-read-section-in-minibuffer \"Sectioning(Up=C-p, Down=C-n, Help=?): \" YaTeX-sectioning-level (YaTeX-section-overview)))) (select-window sw)) (YaTeX-minibuffer-erase) (insert sect) (exit-minibuffer))) (defvar YaTeX-read-fontsize-history nil \"Holds history of font designator.\") (put 'YaTeX-read-fontsize-history 'no-default t) (defun YaTeX-read-fontsize (prompt &optional predicate must-match initial) \"Read a LaTeX font changing command with completion.\" (YaTeX-sync-local-table 'tmp-fontsize-table) (completing-read-with-history prompt (append tmp-fontsize-table user-fontsize-table fontsize-table) predicate must-match initial 'YaTeX-read-fontsize-history)) (defun YaTeX-change-environment () \"Change the name of environment.\" (interactive) (if (not (YaTeX-on-begin-end-p)) nil (save-excursion (let (p env newenv (m1 (match-beginning 1)) (m2 (match-beginning 2))) (setq env (if m1 (YaTeX-buffer-substring m1 (match-end 1)) (YaTeX-buffer-substring m2 (match-end 2)))) (goto-char (match-beginning 0)) (set-mark-command nil) (YaTeX-goto-corresponding-environment) (setq newenv (YaTeX-read-environment (format \"Change environment %s' to: \" env))) (cond ((string= newenv \"\") (message \"Change environment cancelled.\")) ((string= newenv env) (message \"No need to change.\")) (t (search-forward (concat \"{\" env) (point-end-of-line) t) (replace-match (concat \"{\" newenv) t) (exchange-point-and-mark) (search-forward (concat \"{\" env) (point-end-of-line) t) (replace-match (concat \"{\" newenv) t))) t)))) (defun YaTeX-change-section () \"Change section-type command.\" (interactive) (let*((where (YaTeX-on-section-command-p YaTeX-command-token-regexp)) (p (point)) (cmd (YaTeX-match-string 1)) (beg (make-marker)) (end (make-marker)) old new) (if (null where) nil (unwind-protect (let ((source-window (selected-window))) (cond ((equal where 0);;if point is on section command (set-marker beg (match-beginning 1)) (set-marker end (match-end 1)) (goto-char beg) ;beginning of the command (setq new (YaTeX-read-section (format \"Change %s' to: \" cmd) nil) old cmd)) ((= where -1);;if point is on a optional parameter (set-marker beg (match-beginning 2)) (skip-chars-forward \"^{\") (set-marker end (point)) (goto-char p) (setq new (if (fboundp (intern-soft (concat YaTeX-addin-prefix cmd))) (YaTeX-addin cmd) (concat \"[\" (read-string (format \"Change %s' to: \" (setq old (YaTeX-buffer-substring (1+ beg) (1- end))))) \"]\")))) ((> where 0);;if point is in arguments' braces (or (looking-at \"{\") (progn (skip-chars-backward \"^{\") (forward-char -1))) (set-marker beg (1+ (point))) (forward-list 1) (forward-char -1) (set-marker end (point)) (setq old (YaTeX-buffer-substring beg end)) (goto-char p) (if (> (length old) 40) (setq old (concat (substring old 0 12) \"...\" (substring old -12)))) (setq new (if (intern-soft (concat \"YaTeX::\" cmd)) (funcall (intern-soft (concat \"YaTeX::\" cmd)) where) (read-string (format \"Change %s' to: \" old))))) ) ;cond (if (string= old new) nil ;do not replace (delete-region beg end) (goto-char beg) (insert-before-markers new))) (set-marker beg nil) (set-marker end nil)) ;;(goto-char (marker-position p)) new))) (defun YaTeX-change-fontsize () \"Change large-type command.\" (let ((lt (append tmp-fontsize-table user-fontsize-table fontsize-table)) (p (point)) large old new beg end) ;;(and (looking-at \"}\") (up-list -1)) ;;(and (looking-at \"{\") (forward-char 1)) ;;Is above convenient? (save-excursion (or (looking-at YaTeX-ec-regexp) (progn (skip-chars-backward (concat \"^\" YaTeX-ec-regexp)) (forward-char -1))) (cond ((and (looking-at (concat YaTeX-ec-regexp \"\\$$\" YaTeX-TeX-token-regexp \"\\$$\")) (< p (match-end 0)) (assoc (setq old (YaTeX-match-string 1)) lt)) (goto-char p) (setq beg (match-beginning 1) end (match-end 1) ;save match position new (completing-read (format \"Change font/size %s' to : \" old) lt)) (delete-region beg end) (goto-char beg) (insert-before-markers new) new) (t nil) )))) (defun YaTeX-change-math-image () \"Change with image completion.\" (let (maketitle memberp beg end) (if (and (YaTeX-on-maketitle-p) (progn (setq maketitle (substring (YaTeX-match-string 0) 1)) (setq memberp (YaTeX-math-member-p maketitle)))) (let*((last-command-char (string-to-char (car memberp))) (last-command-event last-command-char)) (setq beg (match-beginning 0) end (match-end 0)) (delete-region beg end) (YaTeX-math-insert-sequence t (cdr memberp)))))) (defun YaTeX-kill-* (&optional arg) \"Parse current line and call suitable function. Non-nil for ARG kills its contents too.\" (interactive \"P\") (cond ((YaTeX-kill-some-pairs 'YaTeX-on-begin-end-p 'YaTeX-goto-corresponding-environment arg)) ((YaTeX-kill-some-pairs 'YaTeX-on-BEGIN-END-p 'YaTeX-goto-corresponding-BEGIN-END arg)) ((YaTeX-on-section-command-p YaTeX-command-token-regexp);on any command (YaTeX-kill-section-command (match-beginning 0) arg)) ((YaTeX-kill-paren arg)) ((and (fboundp 'overlays-at) (member YaTeX-on-the-fly-overlay (overlays-at (point)))) (YaTeX-on-the-fly-cancel)) (t (message \"I don't know what to kill.\")))) (defun YaTeX-change-* () \"Parse current line and call suitable function.\" (interactive) (cond ((YaTeX-change-parentheses)) ((YaTeX-change-environment)) ((YaTeX-change-section)) ((YaTeX-change-fontsize)) ((YaTeX-change-math-image)) (t (message \"I don't know what to change.\")))) ;;; ;Check availability of add-in functions ;;; (cond ((featurep 'yatexadd) nil) ;Already provided. ((progn (load \"yatexadd\" t) (featurep 'yatexadd)) nil) (t (message \"YaTeX add-in functions not supplied.\"))) (defun YaTeX-addin (name) \"Check availability of addin function and call it if exists.\" (if (and (not (get 'YaTeX-generate 'disabled)) (intern-soft (concat YaTeX-addin-prefix name)) (fboundp (intern-soft (concat YaTeX-addin-prefix name)))) (let ((s (funcall (intern (concat YaTeX-addin-prefix name))))) (if (stringp s) s \"\")) \"\")) ;Add in function is not bound. (defun YaTeX-on-item-p (&optional point) \"Return t if POINT (default is (point)) is on \\\\item.\" (let ((p (or point (point)))) (save-excursion (goto-char p) (end-of-line) (setq p (point)) (re-search-backward YaTeX-paragraph-delimiter nil t) (re-search-forward YaTeX-item-regexp p t)))) (defun YaTeX-in-verb-p (&optional point) \"Check if POINT is in verb or verb*. Default of POINT is (point).\" (setq point (or point (point))) (save-excursion (let ((md (match-data))) (goto-char point) (unwind-protect (if (not (re-search-backward (concat YaTeX-ec-regexp \"\\$$\" YaTeX-verb-regexp \"\\$$\" \"\\$$[^-A-Za-z_*]\\$$\") (point-beginning-of-line) t)) nil (goto-char (match-end 2)) (skip-chars-forward (concat \"^\" (YaTeX-buffer-substring (match-beginning 2) (match-end 2)))) (and (< (match-beginning 2) point) (< (1- point) (point)))) (store-match-data md))))) (defun YaTeX-literal-p (&optional point) \"Check if POINT is in verb or verb* or verbatime environment family. Default of POINT is (point).\" (let ((md (match-data))) (unwind-protect (cond ((equal YaTeX-ec \"\\\\\") ;maybe LaTeX (save-excursion (and point (goto-char point)) (or (YaTeX-in-verb-p (point)) (and (not (looking-at \"\\\\\\\\end{verb\")) (YaTeX-quick-in-environment-p YaTeX-verbatim-environments)))))) (store-match-data md)))) ;; Filling \\item (defun YaTeX-remove-trailing-comment (start end) \"Remove trailing comment from START to end.\" (save-excursion (let ((trcom (concat YaTeX-comment-prefix \"\"))) (goto-char start) (while (re-search-forward trcom end t) (if (/= (char-after (1- (match-beginning 0))) ?\\\\ ) (replace-match \"\\\\1\")))))) (defvar YaTeX-itemize-withlabel-max-indent-depth 8) (defun YaTeX-get-item-info (&optional recent thisenv) \"Return the list of the beginning of \\\\item and column of its item. If it seems to be outside of itemizing environment, just return nil. Non-nil for optional argument RECENT refers recent \\\\item. Optional second argument THISENV omits calling YaTeX-inner-environment.\" (save-excursion (let* ((p (point)) env e0 c cc md (bndry (and (setq env (or thisenv (YaTeX-inner-environment t))) (get 'YaTeX-inner-environment 'point)))) (end-of-line) (if (if recent (catch 'found (while (YaTeX-re-search-active-backward YaTeX-item-regexp YaTeX-comment-prefix bndry t) (setq md (match-data)) (YaTeX-inner-environment t) (store-match-data md) (if (= bndry (get 'YaTeX-inner-environment 'point)) (throw 'found t)))) (goto-char bndry) (YaTeX-re-search-active-forward YaTeX-item-regexp YaTeX-comment-prefix p t)) (progn (goto-char (match-end 0)) ;(setq c (current-column)) (if (string-match \"desc\" env) (setq c 6) (setq cc (current-column)) (if (equal (following-char) ?\\[) (forward-list 1)) (if (< (- (current-column) cc) YaTeX-itemize-withlabel-max-indent-depth) (setq c 0) (move-to-column cc) (setq c YaTeX-itemize-withlabel-max-indent-depth))) (skip-chars-forward \" \\t\" (point-end-of-line)) (list (point-beginning-of-line) (+ c (current-column)))))))) (defun YaTeX-fill-item () \"Fill item in itemize environment.\" (interactive) (save-excursion (let* ((p (point)) (item-term (concat \"\\$$^[ \\t]*\\$$\\\\|\" YaTeX-item-regexp \"\\\\|\\$$\" YaTeX-ec-regexp \"\\\\(begin\\\\|end\\$$\\\\)\")) ;;This value depends on LaTeX. fill-prefix start col (info (YaTeX-get-item-info t))) (if (null info) nil ;not on \\item, do nothing (setq start (car info) col (car (cdr info))) (save-excursion (if (re-search-backward \"^\\\\s *\" start t) ;;if separated from \\item line, isolate this block (progn (setq start (1+ (match-end 0))) (goto-char start) (skip-chars-forward \" \\t\") (delete-region (point) start) ;is this your favor??? (indent-to col)))) (beginning-of-line) (if (<= (save-excursion (re-search-forward (concat \"\\\\\\\\end{\\\\|\\\\\\\\begin{\\\\|^[ \\t]*\") nil t) (match-beginning 0)) p) (progn (message \"Not on itemize.\") nil) (end-of-line) (newline) (indent-to col) (setq fill-prefix (YaTeX-buffer-substring (point-beginning-of-line)(point))) (beginning-of-line) (delete-region (point) (progn (forward-line 1) (point))) (re-search-forward item-term nil 1) (YaTeX-remove-trailing-comment start (point)) (beginning-of-line) (push-mark (point) t) (goto-char start) (forward-line 1) (while (< (point) (mark)) (delete-region (point) (progn (skip-chars-forward \" \\t\") (point))) (forward-line 1)) (fill-region-as-paragraph start (mark)) (if NTT-jTeX (while (progn(forward-line -1)(end-of-line) (> (point) start)) (insert ?%))) (pop-mark)))))) (defun YaTeX-fill-paragraph (arg) \"YaTeX adjustment function for fill-paragraph. *Protect \\\\verb from unexpected broken up.\" (interactive \"P\") (cond ((not (eq major-mode 'yatex-mode)) (fill-paragraph arg)) ((YaTeX-quick-in-environment-p YaTeX-fill-inhibit-environments) nil) ((YaTeX-in-math-mode-p) nil) (t (save-excursion (let*((verbrex (concat YaTeX-ec-regexp \"\\$$\" YaTeX-verb-regexp \"\\$$\" ;match#1 \"\\$$.\\$$.*\\$$\\\\2\\$$\")) ;match #2 and #3 (tilderex (concat \"\\$$\" YaTeX-kanji-regexp \"~\" \"\\$$\" YaTeX-ec-regexp \"\\\\|\\$$\" \"~\" YaTeX-kanji-regexp \"\\$$\")) (p (point)) ii end poslist spacelist lenlist b e n (fill-prefix fill-prefix) (inenv (or (YaTeX-inner-environment t) \"document\")) (border (get 'YaTeX-inner-environment 'point))) (cond ((save-excursion (beginning-of-line) ;if point is on the first (setq end (point)) ;non-whitespace char (skip-chars-forward \" \\t\") (equal (point) p)) (setq fill-prefix (YaTeX-buffer-substring p end))) ((and ;;(not YaTeX-emacs-19) (string-match YaTeX-itemizing-env-regexp inenv) (setq ii (YaTeX-get-item-info))) (save-excursion (beginning-of-line) (indent-to-column (car (cdr ii))) (setq fill-prefix (YaTeX-buffer-substring (point) (point-beginning-of-line))) (delete-region (point) (progn (beginning-of-line) (point)))))) (cond ((string-match \"tabular\" inenv) (let ((b (point-beginning-of-line)) (e (point-end-of-line))) (if (re-search-backward \"&\\\\|\\\\\\\\\\\\\\\\\\\\|\\\\\\\\\\$$begin\\\\|end\\$${\" border t) (setq b (if (match-beginning 1) (progn (forward-line 1) (point)) (point-beginning-of-line)))) (goto-char p) (if (re-search-forward \"&\\\\|\\\\\\\\\\\\\\\\\\\\|\\\\\\\\\\$$end\\\\|begin\\$${\" nil t) (setq e (if (match-beginning 1) (progn (forward-line -1) (point-end-of-line)) (match-beginning 0)))) (set-mark e) (goto-char b))) (t (mark-paragraph))) (save-restriction (narrow-to-region (region-beginning) (region-end)) (YaTeX-remove-trailing-comment (point-min) (point-max)) ;; First, replace spaces in verb to _ temporarily. (goto-char (point-min)) (while (YaTeX-re-search-active-forward verbrex YaTeX-comment-prefix (point-max) t) (setq end (match-beginning 3)) (goto-char (match-beginning 2)) (while (re-search-forward \"\\\\s \" end t) (setq poslist (cons (make-marker) poslist) spacelist (cons (preceding-char) spacelist) lenlist (cons 1 lenlist)) (replace-match \"_\") (set-marker (car poslist) (match-beginning 0)))) ;; Second, replace \"表~\\ref{...}\" to \"\\\\\\ref{...}\" (goto-char (point-min)) (while (YaTeX-re-search-active-forward tilderex YaTeX-comment-prefix (point-max) t) (if (match-beginning 1) (setq b (match-beginning 1) e (match-end 1) n 1) (setq b (match-beginning 2) e (match-end 2) n 2)) (setq poslist (cons (make-marker) poslist) spacelist (cons (YaTeX-match-string n) spacelist) lenlist (cons 2 lenlist)) (goto-char (match-beginning 0)) (delete-region (point) e) (insert YaTeX-ec YaTeX-ec) ;set-marker should be here (set-marker (car poslist) b)) ;;(fill-paragraph arg) (fill-region-as-paragraph (point-min) (point-max) arg) (while spacelist (goto-char (car poslist)) (set-marker (car poslist) nil) (and (eolp) (skip-chars-forward \"\\n\\t \")) (delete-char (car lenlist)) (insert (car spacelist)) (setq spacelist (cdr spacelist) poslist (cdr poslist) lenlist (cdr lenlist))) (goto-char (point-min)) (forward-word 1) (beginning-of-line) (while (re-search-forward \"\\\\\\\\\\$$[a-z]*ref\\\\|cite\\$${\" nil t) (if (< (point-end-of-line) (save-excursion (forward-char -1) (forward-list 1) (point))) (progn (end-of-line) (if (save-excursion (backward-word 1) (looking-at \"[^0-9A-z!-)]\")) (insert YaTeX-comment-prefix))))) ;; Nonbreak space ~' (goto-char (point-min)) (while (YaTeX-re-search-active-forward \"~\\$$\\\\s *\\$$\" YaTeX-comment-prefix (point-max) t) (delete-region (match-beginning 1) (match-end 1)) (insert YaTeX-comment-prefix)) (goto-char (point-min)) (if (and NTT-jTeX (looking-at \"[ \\t]\\\\|^\")) (progn (goto-char (point-min)) (while (not (eobp)) (end-of-line) (or (bolp) (save-excursion (backward-word 1) (looking-at \"[0-9A-z!-)]\")) ;is not japanese string (progn (setq p (point)) (insert YaTeX-comment-prefix))) (forward-line 1)) (goto-char p) (if (looking-at \"%\") (delete-char 1)) ;remove last inserted %' )))))))) (if (fboundp 'YaTeX-saved-indent-new-comment-line) nil (fset 'YaTeX-saved-indent-new-comment-line (symbol-function 'indent-new-comment-line)) (fset 'indent-new-comment-line 'YaTeX-indent-new-comment-line)) (defun YaTeX-indent-new-comment-line (&optional soft) \"Tuned indent-new-comment-line' function for yatex. See the documentation of YaTeX-saved-indent-new-comment-line'.\" (interactive) (cond ((or (not (memq major-mode '(yatex-mode yahtml-mode))) (string-match \"document\" (or (and (boundp 'inenv) inenv) (or (YaTeX-inner-environment t) \"document\")))) (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft)))) ; ((and (eq major-mode 'yahtml-mode) ; (string-match ; \"^[Pp][Rr][Ee]\" (yahtml-inner-environment-but \"^[Aa]\\\\b\" t))) ; (yahtml-indent-new-commnet-line)) ((and (eq major-mode 'yatex-mode) ;1997/2/4 (YaTeX-in-math-mode-p)) nil) ;1996/12/30 (t (let (fill-prefix) (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft))))))) (defun YaTeX-fill-* () \"Fill paragraph according to its condition.\" (interactive) (cond ((YaTeX-fill-item)) )) ;; Accent completion (defun YaTeX-read-accent-char (x) \"Read char in accent braces.\" (let ((c (read-char))) (concat (if (and (or (= c ?i) (= c ?j)) (not (string-match (regexp-quote x) \"cdb\"))) \"\\\\\" \"\") (char-to-string c)))) (defun YaTeX-make-accent () \"Make accent usage.\" (interactive) (message \"1: 2:' 3:^ 4:\\\" 5:~ 6:= 7:. u v H t c d b\") (let ((c (read-char))(case-fold-search nil)) (setq c (cond ((and (> c ?0) (< c ?8)) (substring \"'^\\\"~=.\" (1- (- c ?0)) (- c ?0))) ((= c ?h) \"H\") (t (char-to-string c)))) (if (not (string-match c \"'^\\\"~=.uvHtcdb\")) nil (insert \"\\\\\" c \"{}\") (backward-char 1) (insert (YaTeX-read-accent-char c)) (if (string= c \"t\") (insert (YaTeX-read-accent-char c))) (forward-char 1)))) ;; Field skip in tabular (defun YaTeX-forward-field (arg) \"Move forward to the ARGth next column field of table.\" (interactive \"p\") (if (< arg 0) (YaTeX-backward-field (- arg)) (let ((ep (save-excursion (YaTeX-end-of-environment) (point))) (wc (car (YaTeX-array-what-column-internal)))) (while (>= (setq arg (1- arg)) 0) (skip-chars-forward \"^&\\\\\\\\\") (while (and (not (eobp)) (> ep (point)) (looking-at \"\\\\&\\\\|\\\\\\\\\") (= wc (car (YaTeX-array-what-column-internal)))) (skip-chars-forward \"&\" ep) (while (looking-at \"[\\n\\t ]+\\\\|\\\\\\\\\\\\\\\\\\\\|\\\\\\\\.line\\\\>\") (goto-char (match-end 0)) )))))) (defun YaTeX-backward-field (arg) \"Move backward to the ARGth next column field of table.\" (interactive \"p\") (if (< arg 0) (YaTeX-forward-field (- arg)) (let ((bp (save-excursion (YaTeX-beginning-of-environment) (point-end-of-line))) (wc (car (YaTeX-array-what-column-internal)))) (while (>= (setq arg (1- arg)) 0) (skip-chars-backward \"^&\\\\\\\\\" bp) (while (and (not (bobp)) (< bp (point)) (memq (preceding-char) '(?& ?\\\\)) (= wc (car (YaTeX-array-what-column-internal)))) (skip-chars-backward \"&\\\\\\\\\" bp) (skip-chars-backward \"\\n\\t \" bp)) (if (eolp) (skip-chars-forward \"^&\\\\\\\\\")))))) ;; Indentation (defun YaTeX-current-indentation () \"Return the indentation of current environment.\" (save-excursion ;;(beginning-of-line) (if (YaTeX-beginning-of-environment t) (goto-char (get 'YaTeX-inner-environment 'point)) (forward-line -1) (beginning-of-line) (skip-chars-forward \" \\t\")) (current-column))) (defun YaTeX-previous-line-indentation () (save-excursion (forward-line -1) (skip-chars-forward \" \\t\") (current-column))) (defvar YaTeX-noindent-env-regexp \"verbatim\\\\*?\\\\|alltt\" \"*Regexp of environment names that should begin with no indentation. All verbatime-like environment name should match with.\") (defun YaTeX-indent-line () \"Indent corrent line referrin current environment.\" (interactive) (let ((indent-relative (function (lambda (&optional additional) (YaTeX-reindent (+ (YaTeX-current-indentation) (or additional 0) YaTeX-environment-indent))))) sect depth iteminfo (p (point)) pp (peol (point-end-of-line)) begend ;;inenv below is sometimes defined in YaTeX-indent-new-comment-line (inenv (or (and (boundp 'inenv) inenv) (YaTeX-inner-environment t)))) ;;(if NTT-jTeX ;;Do you need this section? ;; (save-excursion ;; (end-of-line) ;; (let ((p (point))) ;; (forward-line -1) ;; (end-of-line) ;; (or (= p (point)) ;; (progn (backward-char (length YaTeX-comment-prefix)) ;; (not (looking-at (regexp-quote YaTeX-comment-prefix)))) ;; (progn ;; (skip-chars-backward YaTeX-comment-prefix) ;; (kill-line)))))) (or inenv (setq inenv \"document\")) ;is the default environment (cond ((and (prog1 (YaTeX-on-begin-end-p) (setq begend (match-beginning 0))) (or (match-beginning 2) ;if \\end (and (match-beginning 3) ;if \\)$\n(= (char-syntax (char-after (1+ (match-beginning 3)))) ?\\)))))\n(YaTeX-reindent\n(save-excursion\n(YaTeX-goto-corresponding-environment)\n(current-column))))\n;; on the begining of verbatime line, remove all indentation\n((and begend ;; match-beginning 0 of \\begin\nYaTeX-noindent-env-regexp\n(stringp YaTeX-noindent-env-regexp)\n(save-excursion\n(and ;; if the \\begin is the first declaration of this line\n(progn (beginning-of-line) (skip-chars-forward \" \\t\")\n(= begend (point)))\n(progn\n(goto-char begend)\n(looking-at\n(concat YaTeX-ec-regexp\n\"begin{\\$$\" YaTeX-noindent-env-regexp \"\\$$}\"))))))\n(save-excursion\n(goto-char begend)\n(delete-region (point) (point-beginning-of-line))))\n((string-match YaTeX-equation-env-regexp inenv)\n(;(YaTeX-in-environment-p '(\"itemize\" \"enumerate\" \"description\" \"list\"))\n(string-match YaTeX-itemizing-env-regexp inenv)\n;;(YaTeX-on-item-p) ??\n;;(setq iteminfo (YaTeX-get-item-info t))\n(if (save-excursion\n(beginning-of-line)\n(re-search-forward YaTeX-item-regexp peol t))\n(progn\n(save-excursion\n(goto-char (1+ (match-beginning 0)))\n(setq depth\n(* YaTeX-environment-indent\n(cond\n((looking-at \"subsubsub\")\t3)\n((looking-at \"subsub\")\t2)\n((looking-at \"sub\")\t1)\n(t\t\t\t0)))))\n(funcall indent-relative depth))\n(YaTeX-reindent (or (car (cdr (YaTeX-get-item-info t inenv)))\n(+ (save-excursion\n(beginning-of-line)\n(YaTeX-current-indentation))\nYaTeX-environment-indent))))\n)\n((YaTeX-literal-p)\t\t\t;verbatims\n(tab-to-tab-stop))\n((string-match \"\\$$tabular\\\\|array\\$$\" inenv) ;1.73\n(let ((n 1) (cc (current-column)) (p (point)))\n(condition-case err\n(save-excursion\n(beginning-of-line)\n(skip-chars-forward \"[ \\t]\")\n;;(if (looking-at \"&\") (forward-char 1))\n(require 'yatexenv)\n(setq n (car (YaTeX-array-what-column-internal))))\n(error nil))\n(YaTeX-reindent\n(+ (YaTeX-current-indentation)\nYaTeX-environment-indent\n(* (1- n) YaTeX-tabular-indentation)))\n(and (= cc (current-column))\n(= p (point))\n(equal last-command 'YaTeX-indent-line)\n;; if NO indent action occured, move to the next column\n(YaTeX-forward-field 1))))\n((and inenv (not (equal \"document\" inenv)))\n(funcall indent-relative))\n((YaTeX-on-section-command-p YaTeX-sectioning-regexp)\n(require 'yatexsec)\t\t;to know YaTeX-sectioning-level\n(setq sect (YaTeX-match-string 1))\n(if (string-match \"\\\\*\\$\" sect)\n(setq sect (substring sect 0 -1)))\n(YaTeX-reindent\n(* (max\n(1-\t\t\t\t;I want chapter to have indentation 0\n(or (cdr (assoc sect YaTeX-sectioning-level))\n0))\n0)\nYaTeX-environment-indent)))\n;;Default movement\n((and (bolp) fill-prefix) (insert fill-prefix))\n(t (save-excursion\n(beginning-of-line)\n(if fill-prefix\n(progn\n(delete-region (point)\n(progn (skip-chars-forward \" \\t\")\n(point)))\n(insert fill-prefix))\n(skip-chars-forward \" \\t\")\n(if (bobp)\nnil\n(indent-relative-maybe))))\n(skip-chars-forward \" \\t\")))\n;;if current line is \\begin, re-indent \\end too\n(if (and (YaTeX-on-begin-end-p) (match-beginning 1))\n(save-excursion\n;;(beginning-of-line)\n;;(search-forward \"\\\\begin\")\n(goto-char (match-beginning 0))\n(setq depth (current-column))\n(YaTeX-goto-corresponding-environment)\n(YaTeX-reindent depth)))\n(if (or\n(and NTT-jTeX\n(save-excursion (beginning-of-line) (looking-at \"[ \\t]\")))\n(save-excursion\n(beginning-of-line)\n(and\n(not (bobp))\n(progn\n(backward-char 1)\n(re-search-backward\n\"\\\\\\\\\\$$\\\\(page\\$$?ref\\\\|cite\\\\){\" (point-beginning-of-line) t))\n(goto-char (1- (match-end 0)))\n(> (save-excursion\n(condition-case ()\n(progn (forward-list 1) (point))\n(error (point-max))))\n(point-end-of-line)))))\n(save-excursion\n(end-of-line)\n(let ((p (point)))\n(forward-line -1)\n(end-of-line)\n(or (= p (point))\n(looking-at (regexp-quote YaTeX-comment-prefix))\n(bobp) (bolp)\n(save-excursion\n(backward-word 1)\n(looking-at \"\\\\sw+\")) ;is not japanese string\n(insert YaTeX-comment-prefix)))))))\n\n(defun YaTeX-comment-line-break (&optional soft)\n\"Call comment-indent-new-line and YaTeX-indent-line\"\n(comment-indent-new-line soft)\n(YaTeX-indent-line))\n\n(defun YaTeX-latex2e-p ()\n(let ((b (current-buffer))\n(ptn (concat YaTeX-ec \"documentclass\")))\n(unwind-protect\n(or (save-excursion (search-backward ptn nil t))\n(progn\n(YaTeX-visit-main t)\n(save-excursion (search-backward ptn nil t))))\n(set-buffer b))))\n\n(provide 'yatex)\n\"*List of functions to be called when yatex.el is loaded.\")\n(if (and YaTeX-emacs-19 YaTeX-display-color-p (not (featurep 'yatex19)))\n`" ]
[ null, "https://www.gravatar.com/avatar/ec5ea55b0b69ae50a41f96f98eb86a89", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5252233,"math_prob":0.6647178,"size":108549,"snap":"2021-43-2021-49","text_gpt3_token_len":32571,"char_repetition_ratio":0.20011055,"word_repetition_ratio":0.048404254,"special_character_ratio":0.31231058,"punctuation_ratio":0.07174625,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98480976,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-04T11:15:52Z\",\"WARC-Record-ID\":\"<urn:uuid:771cf4e8-b89d-4f63-bf39-ff587d1af324>\",\"Content-Length\":\"160647\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ad6a9599-0552-417e-ad47-41ea5388b3ff>\",\"WARC-Concurrent-To\":\"<urn:uuid:2bd3e4f4-2e0b-47b4-987d-983b252573bf>\",\"WARC-IP-Address\":\"219.117.249.82\",\"WARC-Target-URI\":\"https://www.yatex.org/gitbucket/yuuji/yatex/blob/febcf27f47b7cd918cea5d0f99a73b6c37817e19/yatex.el\",\"WARC-Payload-Digest\":\"sha1:S7YZZVPKG4326YZGBYZIG5RMFPSYAJ5U\",\"WARC-Block-Digest\":\"sha1:37ANFTN4LM5KT2LU33IBRIWLWMN7QTUN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964362969.51_warc_CC-MAIN-20211204094103-20211204124103-00337.warc.gz\"}"}
https://mathhelpforum.com/threads/of-2005-integers-whose-product-is-even-at-most-how-many-can-be-odd.242067/
[ "# Of 2005 integers whose product is even, at most how many can be odd?\n\n#### Frustration\n\nHow would you solve this? The question doesn't specify which integers, but my mentor tells me there is a solution.\nCould someone please reasonably explain this to me?\n\nThanks!\n\n#### Shakarri\n\nLook at the problem the other way round. Of 2005 integers whose product is even, at least how many must be even?\n\n•", null, "1 person\n\n#### JeffM\n\nShakarri gave you a neat way to think about this problem. Here is another way. Whenever you are stuck on a problem, it frequently helps to think about simpler problems of the same type.\n\nIf the product of two integers is even, what is the maximum number that can be odd.\n\nIf the product of three integers is even, what is the maximum number that can be odd.\n\nAny thoughts now?\n\n•", null, "2 people\n\n#### Frustration\n\nwhen you put it that way, shak, it is still difficult for me to understand\n\nI still don't understand the answer to the original question though, jeff.\n\n#### JeffM\n\nwhen you put it that way, shak, it is still difficult for me to understand\n\nI still don't understand the answer to the original question though, jeff.\n\nYou got the correct answers to the simpler problems.\n\nSo if the product of TWO integers is even, at most ONE integer can be odd, which means least ONE integer must be even.\n\nSo if the product of THREE integers is even, at most TWO integer can be odd, which means at least ONE integer must be even.\n\nWhy must at least one integer be even in those two simple cases? Does that reason generalize?\n\n•", null, "1 person\n\n#### Frustration\n\nYay, I got them correct!", null, "------\nHmm, one must be even because it needs to balance out?\nThe pattern that I'm getting is that you basically subtract one from original number?\n2004?\n\n#### JeffM\n\nYes. The product of n odd numbers is an odd number. The product of an odd number and an even number is even. So you only need 1 even number as a factor of a product of integers for the product to be even. That was the clue that shakarri gave you. So you can multiply 2004 odd integers together, getting an odd number. When you multiply that odd number by an even number, you get an even number. For a product of n integers to be even, you can have at most n - 1 odd factors because at least one factor must be even.\n\nRemember this trick of trying simpler problems of the same type when you are stuck. It doesn't always work, but if you are stuck, you need things to try.\n\n•", null, "1 person" ]
[ null, "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", null, "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", null, "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", null, "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", null, "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.96007955,"math_prob":0.9306967,"size":669,"snap":"2019-51-2020-05","text_gpt3_token_len":158,"char_repetition_ratio":0.17894737,"word_repetition_ratio":0.0,"special_character_ratio":0.23467863,"punctuation_ratio":0.10067114,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98626274,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-21T23:01:46Z\",\"WARC-Record-ID\":\"<urn:uuid:ec76dbf0-25b7-4d04-9dbd-5472996061cc>\",\"Content-Length\":\"91187\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5d466caf-cc2b-4089-aa8f-d0a056ee41f2>\",\"WARC-Concurrent-To\":\"<urn:uuid:74eb13e3-a853-4cfd-b567-57c22ca7bae7>\",\"WARC-IP-Address\":\"138.68.240.87\",\"WARC-Target-URI\":\"https://mathhelpforum.com/threads/of-2005-integers-whose-product-is-even-at-most-how-many-can-be-odd.242067/\",\"WARC-Payload-Digest\":\"sha1:ACS3EOHCGRHLXADV57G2HMY73VXQQ65G\",\"WARC-Block-Digest\":\"sha1:A2XWYJV6HWYM7V4ZWSFAMQE22M6EPNDL\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579250606226.29_warc_CC-MAIN-20200121222429-20200122011429-00078.warc.gz\"}"}
https://www.oreilly.com/library/view/matlab-mathematical-analysis/9781484203491/9781484203507_Ch05.xhtml
[ "CHAPTER 5", null, "Limits of Sequences and Functions. Continuity in One and Several Variables\n\nLimits\n\nMATLAB incorporates features that allow you to work with limits of sequences and functions. In addition to calculating limits of sequences and functions, one can use these commands to analyze the continuity and differentiability of functions, as well as the convergence of numerical series and power series. The following table summarizes the most common MATLAB functions relating to limits.\n\n limit (sequence, inf) Calculates the limit of the sequence, indicated by its general term, as n tends to infinity >> syms n>> limit(((2*n-3)/(3*n-7))^4, n,inf) ...\n\nGet MATLAB Mathematical Analysis now with O’Reilly online learning.\n\nO’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers." ]
[ null, "https://www.oreilly.com/library/view/matlab-mathematical-analysis/9781484203491/images/frontdot.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.89198893,"math_prob":0.9190849,"size":831,"snap":"2020-34-2020-40","text_gpt3_token_len":176,"char_repetition_ratio":0.12938331,"word_repetition_ratio":0.0,"special_character_ratio":0.21179302,"punctuation_ratio":0.12751678,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96517557,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-26T22:34:07Z\",\"WARC-Record-ID\":\"<urn:uuid:17e9097f-a54d-4c7c-93fe-3b6984924ab8>\",\"Content-Length\":\"48438\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b91a141e-8fdf-4aa5-ae9f-77cb7c078e2e>\",\"WARC-Concurrent-To\":\"<urn:uuid:e4e9270d-d26d-43c5-8e23-1a24f4dca218>\",\"WARC-IP-Address\":\"104.117.6.234\",\"WARC-Target-URI\":\"https://www.oreilly.com/library/view/matlab-mathematical-analysis/9781484203491/9781484203507_Ch05.xhtml\",\"WARC-Payload-Digest\":\"sha1:NXZ5MYOSQTSRKFFMF4CDFAGINGNDSZP4\",\"WARC-Block-Digest\":\"sha1:77KIW7YYYZ5I4N55FJSEERCR4UVCRJHV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400245109.69_warc_CC-MAIN-20200926200523-20200926230523-00230.warc.gz\"}"}
https://metanumbers.com/1270935
[ "# 1270935 (number)\n\n1,270,935 (one million two hundred seventy thousand nine hundred thirty-five) is an odd seven-digits composite number following 1270934 and preceding 1270936. In scientific notation, it is written as 1.270935 × 106. The sum of its digits is 27. It has a total of 5 prime factors and 24 positive divisors. There are 665,280 positive integers (up to 1270935) that are relatively prime to 1270935.\n\n## Basic properties\n\n• Is Prime? No\n• Number parity Odd\n• Number length 7\n• Sum of Digits 27\n• Digital Root 9\n\n## Name\n\nShort name 1 million 270 thousand 935 one million two hundred seventy thousand nine hundred thirty-five\n\n## Notation\n\nScientific notation 1.270935 × 106 1.270935 × 106\n\n## Prime Factorization of 1270935\n\nPrime Factorization 32 × 5 × 61 × 463\n\nComposite number\nDistinct Factors Total Factors Radical ω(n) 4 Total number of distinct prime factors Ω(n) 5 Total number of prime factors rad(n) 423645 Product of the distinct prime numbers λ(n) -1 Returns the parity of Ω(n), such that λ(n) = (-1)Ω(n) μ(n) 0 Returns: 1, if n has an even number of prime factors (and is square free) −1, if n has an odd number of prime factors (and is square free) 0, if n has a squared prime factor Λ(n) 0 Returns log(p) if n is a power pk of any prime p (for any k >= 1), else returns 0\n\nThe prime factorization of 1,270,935 is 32 × 5 × 61 × 463. Since it has a total of 5 prime factors, 1,270,935 is a composite number.\n\n## Divisors of 1270935\n\n24 divisors\n\n Even divisors 0 24 12 12\nTotal Divisors Sum of Divisors Aliquot Sum τ(n) 24 Total number of the positive divisors of n σ(n) 2.2439e+06 Sum of all the positive divisors of n s(n) 972969 Sum of the proper positive divisors of n A(n) 93496 Returns the sum of divisors (σ(n)) divided by the total number of divisors (τ(n)) G(n) 1127.36 Returns the nth root of the product of n divisors H(n) 13.5935 Returns the total number of divisors (τ(n)) divided by the sum of the reciprocal of each divisors\n\nThe number 1,270,935 can be divided by 24 positive divisors (out of which 0 are even, and 24 are odd). The sum of these divisors (counting 1,270,935) is 2,243,904, the average is 93,496.\n\n## Other Arithmetic Functions (n = 1270935)\n\n1 φ(n) n\nEuler Totient Carmichael Lambda Prime Pi φ(n) 665280 Total number of positive integers not greater than n that are coprime to n λ(n) 4620 Smallest positive number such that aλ(n) ≡ 1 (mod n) for all a coprime to n π(n) ≈ 97732 Total number of primes less than or equal to n r2(n) 0 The number of ways n can be represented as the sum of 2 squares\n\nThere are 665,280 positive integers (less than 1,270,935) that are coprime with 1,270,935. And there are approximately 97,732 prime numbers less than or equal to 1,270,935.\n\n## Divisibility of 1270935\n\n m n mod m 2 3 4 5 6 7 8 9 1 0 3 0 3 1 7 0\n\nThe number 1,270,935 is divisible by 3, 5 and 9.\n\n• Arithmetic\n• Deficient\n\n• Polite\n\n## Base conversion (1270935)\n\nBase System Value\n2 Binary 100110110010010010111\n3 Ternary 2101120101200\n4 Quaternary 10312102113\n5 Quinary 311132220\n6 Senary 43123543\n8 Octal 4662227\n10 Decimal 1270935\n12 Duodecimal 5135b3\n20 Vigesimal 7ih6f\n36 Base36 r8nr\n\n## Basic calculations (n = 1270935)\n\n### Multiplication\n\nn×y\n n×2 2541870 3812805 5083740 6354675\n\n### Division\n\nn÷y\n n÷2 635468 423645 317734 254187\n\n### Exponentiation\n\nny\n n2 1615275774225 2052910516114650375 2609115826798173174350625 3316016623331736223343311584375\n\n### Nth Root\n\ny√n\n 2√n 1127.36 108.32 33.5761 16.6274\n\n## 1270935 as geometric shapes\n\n### Circle\n\n Diameter 2.54187e+06 7.98552e+06 5.07454e+12\n\n### Sphere\n\n Volume 8.59921e+18 2.02982e+13 7.98552e+06\n\n### Square\n\nLength = n\n Perimeter 5.08374e+06 1.61528e+12 1.79737e+06\n\n### Cube\n\nLength = n\n Surface area 9.69165e+12 2.05291e+18 2.20132e+06\n\n### Equilateral Triangle\n\nLength = n\n Perimeter 3.8128e+06 6.99435e+11 1.10066e+06\n\n### Triangular Pyramid\n\nLength = n\n Surface area 2.79774e+12 2.41938e+17 1.03771e+06\n\n## Cryptographic Hash Functions\n\nmd5 5ee3e762096152da7509ac740edfac15 9ad6a80974f9e0b6b3e4648ea1f6d4c6f53ce338 0d22bab4c0d602f1eea46816e26d665cb7aeeca4fefa04025890be31660e487b 18fb2d508484d8b9d19a6eebfc599050c422c6b0d3a75f8c7ab8472a6561eeda20a9957527014b040e95f1729c9c11ae69ae4af6301e28fb6a5da002220e50b9 fe61b2a6e150ea9b492edf6d141a5e6c1e3439d6" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.6072322,"math_prob":0.9840143,"size":4716,"snap":"2021-43-2021-49","text_gpt3_token_len":1696,"char_repetition_ratio":0.121816635,"word_repetition_ratio":0.03953148,"special_character_ratio":0.46840543,"punctuation_ratio":0.08571429,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9956468,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-27T17:14:51Z\",\"WARC-Record-ID\":\"<urn:uuid:8cc2d77d-3f06-47d1-918c-4185788993d0>\",\"Content-Length\":\"39882\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fbf3fa39-b162-45d4-9d66-409dea7d29ef>\",\"WARC-Concurrent-To\":\"<urn:uuid:fc7d852c-16b4-4f96-b3e2-1319f55aed02>\",\"WARC-IP-Address\":\"46.105.53.190\",\"WARC-Target-URI\":\"https://metanumbers.com/1270935\",\"WARC-Payload-Digest\":\"sha1:ZKGGCQWZY7TFKROA563UVMHDZV3U2XQF\",\"WARC-Block-Digest\":\"sha1:XNR2WR5NUWWDDXRHTBSDUULZXDWICRQN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323588216.48_warc_CC-MAIN-20211027150823-20211027180823-00410.warc.gz\"}"}
https://mathematica.stackexchange.com/questions/143184/find-intersection-of-two-interpolation-functions
[ "# Find Intersection of Two Interpolation Functions\n\nHow can I find the intersection between two interpolation functions?\n\ndata1 = Table[10*x, {x, 0, 10, 1}]\ndata2 = Table[-10*x, {x, -10, 2, 1}]\n\nintdata1 = Interpolation[data1];\nintdata2 = Interpolation[data2];\n\nListLinePlot[{data1, data2}]\n\nSolve[intdata1[x] == intdata2[x], x]\n\n\nThis doesn't work, with an error of\n\nSolve::nsmet: This system cannot be solved with the methods available to Solve.\n\nIn:= x/.FindRoot[intdata1[x]==intdata2[x],{x,3}]" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.71254313,"math_prob":0.9933547,"size":388,"snap":"2021-43-2021-49","text_gpt3_token_len":123,"char_repetition_ratio":0.14322917,"word_repetition_ratio":0.0,"special_character_ratio":0.3273196,"punctuation_ratio":0.2278481,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98389405,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-20T19:51:39Z\",\"WARC-Record-ID\":\"<urn:uuid:4e42fdb0-b08f-42f7-aaf4-daf4276c0ee5>\",\"Content-Length\":\"165120\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b94d91d6-8b21-4ed4-9dcf-e58d8c8c1148>\",\"WARC-Concurrent-To\":\"<urn:uuid:1d7fe8f7-0778-4d24-a78f-2e636fbe4630>\",\"WARC-IP-Address\":\"151.101.193.69\",\"WARC-Target-URI\":\"https://mathematica.stackexchange.com/questions/143184/find-intersection-of-two-interpolation-functions\",\"WARC-Payload-Digest\":\"sha1:5XWSCZM5WFEWWWXQNKEFGPUGNTHPW7KB\",\"WARC-Block-Digest\":\"sha1:NQVTK3A2XRBOVO2MHK3HLFNLICJKNNVH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585348.66_warc_CC-MAIN-20211020183354-20211020213354-00080.warc.gz\"}"}
https://www.mathworks.com/matlabcentral/answers/1848368-meaning-of-sys-k-xkm1-uk-xkm1-2-25-xkm1-1-xkm1-2-8-cos-1-2-k-uk
[ "# meaning of sys=@(k, xkm1, uk) xkm1/2 + 25*xkm1/(1+xkm1^2) + 8*cos(1.2*k) + uk;\n\n1 view (last 30 days)\nHi, I am new to matlab and trying to do particle filtering based on particle filter code example by matlab. At the beginning of the coding, there is a equation or function\nsys=@(k, xkm1, uk) xkm1/2 + 25*xkm1/(1+xkm1^2) + 8*cos(1.2*k) + uk;\nand I dont really understand the equation meaning. I reaaly need help on this.\n\nWalter Roberson on 11 Nov 2022\nEdited: Walter Roberson on 15 Nov 2022\nIn order to understand what MATLAB will calculate for that, then it is important to know that in your code at https://www.mathworks.com/matlabcentral/answers/1843283-particle-filter-error-solution?s_tid=srchtitle that all of those inputs are scalars. The code could also work if k and uk are non-scalars that are compatible sizes, but the code is broken for the case where xkm1 is non-scalar.\nThe / operator is the MATLAB \"matrix right divide\" operator. However in the case where the right hand side is a scalar, the / operator uses the behaviour of the ./ element-by-element division operation instead. Since 2 is scalar, xkm1/2 will be treated as xkm1./2 which will divide each element of xkm1 by 2, giving a temporary output the same size as xkm1 .\nThe * operator is the \"inner product\" operator, sometimes referred to as algebraic matrix multiplication. However, in the case where one side or both sides are scalars, the * operator uses the behaviour of the .* element-by-element multiplication operation instead. Since 25 is scalar, 25*xkm1 will be treated as 25.*xkm1 which will multiple each element of xkm1 by 25, giving a temporary output the same size as xkm1.\nThe ^ operator is the matrix-power operator. xkm1^2 is the same as xkm1*xkm1 where * is the inner-product operator. For inner product P*Q the number of columns of the first operand must be the same as the number of rows of the second operand, and the result would be the number of rows of the first operand by the number of columns of the second operand. If xkm1 is a square matrix, N x N (including 1 x 1) then that would be a (N x N) * (N x N) giving an N x N result and the operation would be permitted (even if it were not what you intended) But if xkm1 is a row vector, say 1 x N, then that would be (1 x N) * (1 x N) and the number of columns of the first operand, N, would not match the number of rows of the second operand, 1, and the operation would fail. So xkm1^2 will fail if xkm1 is not a square matrix (including that it would not fail for xkm1 scalar) . Chances are high that you wanted the element-by-element square .^2 instead of ^2\nIf you manage to get through xkm1^2 getting out a square result, then the 1+ would add one to each element, giving a square result (non-square would have failed in the ^2 operation.)\nYou now have xkm1 matrix-right-divide an matrix the same size, and you can be sure that the two are the same size if you managed to get through the ^2 operation. A matrix matrix-right-divide another matrix of the same size is well defined, and will be roughly the same as (25*xkm1) * pinv(1+xkm1^2) where pinv is pseudo-inverse and * is the inner-product operation. You will get out a matrix the same size as xkm1 ... provided that xkm1 was a square matrix. It just probably isn't what you wanted to calculate: you probably wanted to do element-by-element division, ./ instead of /\nAfter the temporary variables for the two terms xkm1/2 and 25*xkm1/(1+xkm1^2) are calculated, the temporary variable will be added together, giving a result the same size as xkm1 .\n8*cos(1.2*k) + uk\nAgain, scalar * something is treated the same as if you had properly specified .* element-by-element multiplication. so that will be treated as 8 .* cos(1.2 .* k) with appropriate multiplications and cosine calculation and more multiplication. Then that temporary variable would be added to the result from the first two terms, and it would be an error if k turned out to be an incompatible size to add to xkm1 . We cannot easily say what size the output will be; you would need to know about implicit expansion to calculate the size properly for the case where xkm1 and k are not scalars.\nFinally uk is added to the temporary output, with it being an error if they are incompatible sizes. Again implicit expansion might occur so we cannot say at the moment what the output size would be, not without using the knowledge that in practice you will be passing in scalars.\nNow, I suspect that you wanted to know why that expression is used, what the physical significance of that calculation is. However that is not a question about MATLAB. We can tell you how MATLAB will process the expression, but information about why that particular calculation and not a different one is off-topic here.\nThank you very much for the recommendation. I will try to read these and find the answer to my question." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9303511,"math_prob":0.98945284,"size":5107,"snap":"2023-40-2023-50","text_gpt3_token_len":1313,"char_repetition_ratio":0.13639036,"word_repetition_ratio":0.056792874,"special_character_ratio":0.2508322,"punctuation_ratio":0.09169055,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9972647,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-22T20:48:11Z\",\"WARC-Record-ID\":\"<urn:uuid:c39c58b5-4e8e-46bf-96f9-f0998a58c9c3>\",\"Content-Length\":\"144594\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5cecf081-a826-422f-8155-a4cec4552ab1>\",\"WARC-Concurrent-To\":\"<urn:uuid:d9b8d7fd-18a8-46b5-8d31-c0459da6fcbf>\",\"WARC-IP-Address\":\"23.34.160.82\",\"WARC-Target-URI\":\"https://www.mathworks.com/matlabcentral/answers/1848368-meaning-of-sys-k-xkm1-uk-xkm1-2-25-xkm1-1-xkm1-2-8-cos-1-2-k-uk\",\"WARC-Payload-Digest\":\"sha1:QFZUKYGVNAPTHS465SU7XQU7BZMRZVUR\",\"WARC-Block-Digest\":\"sha1:JZT5CX3SQG3FB6IS7XCAFBSJIW3O6MSI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233506423.70_warc_CC-MAIN-20230922202444-20230922232444-00526.warc.gz\"}"}
https://www.circuitbread.com/textbooks/fundamentals-of-electrical-engineering-i/information-communication/block-channel-coding
[ "", null, "# Block Channel Coding\n\nBecause of the higher datarate imposed by the channel coder, the probability of bit error occurring in the digital channel increases relative to the value obtained when no channel coding is used. The bit interval duration must be reduced by\n\nin comparison to the no-channel-coding situation, which means the energy per bit\n\ngoes down by the same amount. The bit interval must decrease by a factor of three if the transmitter is to keep up with the data stream, as illustrated here.\n\n### Point of Interest:\n\nIt is unlikely that the transmitter's power could be increased to compensate. Such is the sometimes-unfriendly nature of the real world.\n\nBecause of this reduction, the error probability\n\nof the digital channel goes up. The question thus becomes does channel coding really help: Is the effective error probability lower with channel coding even though the error probability for each transmitted bit is larger? The answer is no: Using a repetition code for channel coding cannot ultimately reduce the probability that a data bit is received in error. The ultimate reason is the repetition code's inefficiency: transmitting one data bit for every three transmitted is too inefficient for the amount of error correction provided.\n\n### Exercise\n\nUsing MATLAB, calculate the probability a bit is received incorrectly with a three-fold repetition code. Show that when the energy per bit\n\nis reduced by\n\nthat this probability is larger than the no-coding probability of error.\n\nWith no coding, the average bit-error probability pep e is given by the probability of error equation :\n\n. With a threefold repetition code, the bit-error probability is given by\n\n, where\n\n. Plotting this reveals that the increase in bit-error probability out of the channel because of the energy reduction is not compensated by the repetition coding.\n\nThe repetition code represents a special case of what is known as block channel coding. For every\n\nbits that enter the block channel coder, it inserts an additional\n\nerror-correction bits to produce a block of\n\nbits for transmission. We use the notation (N,K) to represent a given block code's parameters. In the three-fold repetition code,\n\nand\n\n. A block code's coding efficiency\n\nequals the ratio\n\n, and quantifies the overhead introduced by channel coding. The rate at which bits must be transmitted again changes: So-called data bits\n\nemerge from the source coder at an average rate\n\nand exit the channel at a rate\n\nhigher. We represent the fact that the bits sent through the digital channel operate at a different rate by using the index ll for the channel-coded bit stream\n\n. Note that the blocking (framing) imposed by the channel coder does not correspond to symbol boundaries in the bit stream\n\n, especially when we employ variable-length source codes.\n\nDoes any error-correcting code reduce communication errors when real-world constraints are taken into account? The answer now is yes. To understand channel coding, we need to develop first a general framework for channel coding, and discover what it takes for a code to be maximally efficient: Correct as many errors as possible using the fewest error correction bits as possible (making the efficiency\n\nas large as possible).", null, "Swipe left and right to change pages.", null, "", null, "" ]
[ null, "https://www.facebook.com/tr", null, "https://www.circuitbread.com/img/textbooks/icon-swipe.svg", null, "https://www.circuitbread.com/img/sf-toaster-normal.svg", null, "https://www.circuitbread.com/img/icon-search-white-2x.svg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9157648,"math_prob":0.9195568,"size":3384,"snap":"2019-43-2019-47","text_gpt3_token_len":682,"char_repetition_ratio":0.1556213,"word_repetition_ratio":0.0,"special_character_ratio":0.19267139,"punctuation_ratio":0.087804876,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9947313,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-21T02:42:30Z\",\"WARC-Record-ID\":\"<urn:uuid:483c616b-a087-4606-a90d-f42a4d7eb4c4>\",\"Content-Length\":\"212461\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:80725750-aec3-4577-b4a1-9c9b513f89a0>\",\"WARC-Concurrent-To\":\"<urn:uuid:e5d7b21e-e329-4261-92b6-25e9fcec245c>\",\"WARC-IP-Address\":\"54.70.27.247\",\"WARC-Target-URI\":\"https://www.circuitbread.com/textbooks/fundamentals-of-electrical-engineering-i/information-communication/block-channel-coding\",\"WARC-Payload-Digest\":\"sha1:PHJOC2E674M34LR6QNGFECLFGEL65OLG\",\"WARC-Block-Digest\":\"sha1:LJTZR7BHBKLUT5FGX75O3CUXTXL6V5P3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496670729.90_warc_CC-MAIN-20191121023525-20191121051525-00436.warc.gz\"}"}
https://www.cuemath.com/learn/prime-number-program-in-java/
[ "Math & Beyond\nPrime Number Program in Java\n11.9k views\n\n 1 Introduction 2 What are Prime Numbers 3 How to Check if a Number is Prime in Java? 4 Java Programs for Finding out Prime Number 5 Conclusion 6 Frequently Asked Questions (FAQs) 7 External References\n\n26 January 2021\n\nLearn how to check whether a number is prime or not using the Java program.\n\n## What Are Prime Numbers?\n\nPositive numbers which are numbers including and greater than 1 are known as natural numbers. Prime numbers are a special type of natural numbers.\n\nThe specialty of prime numbers lies in the fact that prime numbers are not divisible by any number apart from 1 and themselves.\n\nThis means no numbers apart from 1, and the number itself can be multiplied with each other to obtain the number in question.\n\nAn example of a prime number is 7. The only pair of numbers that can be multiplied with each other to obtain the number 7 is 1, and 7. 1 and 7 are hence the factors of the number 7.\n\nNumbers that are not prime, and have more than two factors are known as composite numbers or composites. Primality is the property of a number that indicates whether it is prime or not. It was demonstrated by Euclid using Euclid’s Theorem that an endless number of prime numbers exist.\n\nThese numbers are nearly randomly distributed throughout the array of natural numbers. However, the probability that a number is prime is inversely proportional to the number of digits it has.\n\nBut why study these numbers separately? Why do we want to make a special program for prime numbers? In the real world, prime numbers have tons and tons of applications, in information technology and outside of it.\n\nThe main computer science application of prime numbers can be found in the form of cryptography. Scores of cryptography algorithms have their foundations in prime numbers of high orders.\n\nPrime numbers also form the basis of hash tables and checksum methods. Other applications of prime numbers are in mathematics, quantum mechanics as well as biology.\n\n## Prime Number Program in Java\n\nProgram to check whether the given number is prime or not? How to display prime numbers using Java Code. The main method contains a loop to check prime numbers one by one. Prime Number Program in Java is mentioned below in the Downloadable PDF.\n\n## How to Check if a Number is Prime in Java?\n\nJava is an object-oriented programming language developed by Oracle. It is an extremely popular language, especially for beginners to programming, since it has very few dependencies.\n\nAs with most other blocks of code, the prime number program in Java is also bound to follow a particular algorithm.\n\nThe algorithm of the prime number program in Java is based on an age-old method to find whether a number is prime or not. Two basic methods can distinguish prime numbers in Java.\n\nThe first method, followed by the prime number program in Java is to check whether the remainder of the number when it is divided by each number up to half of itself is greater than 0.\n\nThe second method to distinguish prime numbers in Java is to check whether the remainder of the number when it is divided by each number from 2 to its square root is greater than zero.\n\nThis follows the fact that the remainder of a number when it is divided by one of its factors is zero, and no factor can be greater than its square root.\n\nHere is the list of steps to be followed to build a prime number program in Java.\n\n• Take the input of the number to check if a number is prime in Java.\n\n• Once the input has been taken, declare a variable that represents the divisors. This variable will be incremented, and the input will be divided by it at every step. Initialize this with the value 2.\n\n• Declare a boolean with the value false. If a divisor is found, the boolean will be converted to true and the program will output the result.\n\n• Define a for loop using the divisor, from the divisor value 2 to half of the input number. Increment the divisor by 1 on every step.\n\n• Inside the for loop, define a conditional statement that exits the loop by changing the value of the boolean if the remainder between the input number and the divisor is found to be zero.\n\n• Outside the loop, define a conditional statement that tells if the number is prime or not on the basis of the boolean value.\n\n• You can also develop the same program using a while loop, that increments the value of the divisor by 1 while the value of the boolean is false.\n\n## Java Programs for Finding out Prime Number\n\nThe following is the program for prime number in Java as per the previous rules using both the for loop and the while loop.\n\nPrime Number Program in Java Using For Loop\n\npublic class Main {\n\npublic static void main(String[] args) {\n\nint num = 29;\nboolean flag = false;\nfor(int i = 2; i <= num/2; ++i)\n{\nif(num % i == 0)\n{\nflag = true;\nbreak;\n}\n}\n\nif (!flag)\nSystem.out.println(num + \" is a prime number.\");\nelse\nSystem.out.println(num + \" is not a prime number.\");\n}\n}\n\nPrime Number Program in Java Using While Loop\n\npublic class Main {\n\npublic static void main(String[] args) {\n\nint num = 33, i = 2;\nboolean flag = false;\nwhile(i <= num/2)\n{\nif(num % i == 0)\n{\nflag = true;\nbreak;\n}\n\n++i;\n}\n\nif (!flag)\nSystem.out.println(num + \" is a prime number.\");\nelse\nSystem.out.println(num + \" is not a prime number.\");\n}\n}\n\n## Conclusion\n\nPrime numbers are an inseparable part of mathematics, and every programmer needs to know how to distinguish prime numbers in Java. The prime number program in Java is hence among the first programs that are taught to beginners. This text provided a brief on how to develop a program for prime number in Java. To know more, and if you have any questions, do not forget to comment!\n\nCuemath, a student-friendly mathematics and coding platform, conducts regular Online Classes for academics and skill-development, and their Mental Math App, on both iOS and Android, is a one-stop solution for kids to develop multiple skills. Understand the Cuemath Fee structure and sign up for a free trial.\n\n## What are co-prime numbers?\n\nPair of Numbers that have their greatest common divisor i.e. GCD is unity, which means that the only number that can divide each of them is 1.\n\n## How to find prime numbers?\n\nPrime Numbers can be found by using the Sieve of Eratosthenes.\n\n## How many prime numbers are from 1-100?\n\nThere are 25 prime numbers from 1-100.\n\n## What are twin prime numbers?\n\nThe pair of primes that differ by an amount of 2 are known as twin prime numbers.\n\n## What is the sieve of Eratosthenes?\n\nIt is an algorithm to find all given numbers up to a limit.\n\nRelated Articles" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9110856,"math_prob":0.98114514,"size":6594,"snap":"2023-40-2023-50","text_gpt3_token_len":1457,"char_repetition_ratio":0.1828528,"word_repetition_ratio":0.13720539,"special_character_ratio":0.22611465,"punctuation_ratio":0.10091743,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9946242,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-30T23:50:15Z\",\"WARC-Record-ID\":\"<urn:uuid:41402095-8b7a-4a99-ba1a-3810b35232de>\",\"Content-Length\":\"187104\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:465868e4-3198-40b3-814f-3ddde92cfa11>\",\"WARC-Concurrent-To\":\"<urn:uuid:84aa8840-f62c-4639-9566-ca551aca92c9>\",\"WARC-IP-Address\":\"104.18.19.168\",\"WARC-Target-URI\":\"https://www.cuemath.com/learn/prime-number-program-in-java/\",\"WARC-Payload-Digest\":\"sha1:OOMNNVMC4PYUUZYMO3UAFCBSYQ5VTWPX\",\"WARC-Block-Digest\":\"sha1:STDJDDLTCATL2FZW4AN5RXKH73CCA7ZH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510730.6_warc_CC-MAIN-20230930213821-20231001003821-00445.warc.gz\"}"}
https://pysal.org/notebooks/explore/giddy/Sequence.html
[ "Sequence\n\n# Alignment-based sequence methods\n\nThis notebook introduces the alignment-based sequence methods (operationalized by the Optimal Matching (OM) algorithm), which was originally developed for matching protein and DNA sequences in biology and used extensively for analyzing strings in computer science and recently widely applied to explore the neighborhood change.\n\nIt generally works by finding the minimum cost for aligning one sequence to match another using a combination of operations including substitution, insertion, deletion and transposition. The cost of each operation can be parameterized diferently and may be theory-driven or data-driven. The minimum cost is considered as the distance between the two sequences.\n\nThe sequence module in giddy provides a suite of alignment-based sequence methods.\n\nAuthor: Wei Kang [email protected]\n\nimport numpy as np\nimport pandas as pd\n\nimport libpysal\nimport mapclassify as mc\nf = libpysal.io.open(libpysal.examples.get_path(\"usjoin.csv\"))\npci = np.array([f.by_col[str(y)] for y in range(1929,2010)])\nq5 = np.array([mc.Quantiles(y,k=5).yb for y in pci]).transpose()\nq5\n\n/Users/weikang/anaconda3/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.\nreturn np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval\n\narray([[0, 0, 0, ..., 0, 0, 0],\n[2, 2, 2, ..., 1, 1, 0],\n[0, 0, 0, ..., 0, 0, 0],\n...,\n[1, 1, 1, ..., 0, 0, 0],\n[3, 3, 2, ..., 2, 2, 2],\n[3, 3, 3, ..., 4, 4, 4]])\nq5.shape\n\n(48, 81)\n\nImport Sequence class from giddy.sequence:\n\nfrom giddy.sequence import Sequence\n\n\n### \"hamming\"\n\n• substitution cost = 1\n• insertion/deletion cost = $\\infty$\nseq_hamming = Sequence(q5, dist_type=\"hamming\")\nseq_hamming\n\n<giddy.sequence.Sequence at 0x7ff498df1160>\nseq_hamming.seq_dis_mat #pairwise sequence distance matrix\n\narray([[ 0., 75., 7., ..., 21., 81., 78.],\n[75., 0., 80., ..., 79., 57., 73.],\n[ 7., 80., 0., ..., 14., 81., 81.],\n...,\n[21., 79., 14., ..., 0., 81., 81.],\n[81., 57., 81., ..., 81., 0., 51.],\n[78., 73., 81., ..., 81., 51., 0.]])\n\n### \"interval\"\n\nAssuming there are $k$ states in the sequences and they are ordinal/continuous.\n\n• substitution cost = differences between states\n• insertion/deletion cost = $k-1$\nseq_interval = Sequence(q5, dist_type=\"interval\")\nseq_interval\n\n<giddy.sequence.Sequence at 0x7ff451d8d160>\nseq_interval.seq_dis_mat\n\narray([[ 0., 123., 7., ..., 21., 190., 225.],\n[123., 0., 130., ..., 116., 69., 108.],\n[ 7., 130., 0., ..., 14., 197., 232.],\n...,\n[ 21., 116., 14., ..., 0., 183., 218.],\n[190., 69., 197., ..., 183., 0., 61.],\n[225., 108., 232., ..., 218., 61., 0.]])\n\n### \"arbitrary\"\n\n• substitution cost = 0.5\n• insertion/deletion cost = 1\nseq_arbitrary = Sequence(q5, dist_type=\"arbitrary\")\nseq_arbitrary\n\n<giddy.sequence.Sequence at 0x7ff451d8dc18>\nseq_arbitrary.seq_dis_mat\n\narray([[ 0. , 37.5, 3.5, ..., 10.5, 40.5, 39. ],\n[37.5, 0. , 40. , ..., 39.5, 28.5, 36.5],\n[ 3.5, 40. , 0. , ..., 7. , 40.5, 40.5],\n...,\n[10.5, 39.5, 7. , ..., 0. , 40.5, 40.5],\n[40.5, 28.5, 40.5, ..., 40.5, 0. , 25.5],\n[39. , 36.5, 40.5, ..., 40.5, 25.5, 0. ]])\n\n### \"markov\"\n\n• substitution cost = $1-\\frac{p_{ij}+p_{ji}}{2}$ where $p_{ij}$ is the empirical rate of transitioning from state $i$ to $j$\n• insertion/deletion cost = 1\nseq_markov = Sequence(q5, dist_type=\"markov\")\nseq_markov\n\n<giddy.sequence.Sequence at 0x7ff451d8df28>\nseq_markov.seq_dis_mat\n\narray([[ 0. , 72.31052406, 6.34073233, ..., 19.02219698,\n80.2334688 , 77.48002783],\n[72.31052406, 0. , 77.05042347, ..., 74.77437281,\n50.75696949, 65.9128181 ],\n[ 6.34073233, 77.05042347, 0. , ..., 12.68146465,\n80.97128589, 80.51785856],\n...,\n[19.02219698, 74.77437281, 12.68146465, ..., 0. ,\n80.10306616, 80.46369148],\n[80.2334688 , 50.75696949, 80.97128589, ..., 80.10306616,\n0. , 41.57088046],\n[77.48002783, 65.9128181 , 80.51785856, ..., 80.46369148,\n41.57088046, 0. ]])\n\n### \"tran\"\n\nBiemann, T. (2011). A Transition-Oriented Approach to Optimal Matching. Sociological Methodology, 41(1), 195–221. https://doi.org/10.1111/j.1467-9531.2011.01235.x\n\nseq_tran = Sequence(q5, dist_type=\"tran\")\nseq_tran\n\n<giddy.sequence.Sequence at 0x7ff451d8d588>\nseq_tran.seq_dis_mat\n\narray([[ 0., 23., 8., ..., 12., 24., 21.],\n[23., 0., 17., ..., 16., 28., 22.],\n[ 8., 17., 0., ..., 4., 18., 16.],\n...,\n[12., 16., 4., ..., 0., 21., 15.],\n[24., 28., 18., ..., 21., 0., 23.],\n[21., 22., 16., ..., 15., 23., 0.]])\nseq_tran.seq_dis_mat\n\narray([[ 0., 220., 25., ..., 55., 220., 220.],\n[220., 0., 241., ..., 199., 93., 123.],\n[ 25., 241., 0., ..., 44., 241., 241.],\n...,\n[ 55., 199., 44., ..., 0., 207., 220.],\n[220., 93., 241., ..., 207., 0., 84.],\n[220., 123., 241., ..., 220., 84., 0.]])" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.74100184,"math_prob":0.9990513,"size":1846,"snap":"2021-21-2021-25","text_gpt3_token_len":457,"char_repetition_ratio":0.13789359,"word_repetition_ratio":0.0,"special_character_ratio":0.23510292,"punctuation_ratio":0.16613418,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99190575,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-05-12T04:43:57Z\",\"WARC-Record-ID\":\"<urn:uuid:3c33ae4d-24f9-43e3-b223-edc78fe01aab>\",\"Content-Length\":\"77247\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:12ae179a-9f38-4031-8653-fda15777db9a>\",\"WARC-Concurrent-To\":\"<urn:uuid:d8013175-e772-4b87-90bd-860359795daa>\",\"WARC-IP-Address\":\"185.199.108.153\",\"WARC-Target-URI\":\"https://pysal.org/notebooks/explore/giddy/Sequence.html\",\"WARC-Payload-Digest\":\"sha1:6BDDSQMJQLLQTH5GYNKTXGH4Z527M6CP\",\"WARC-Block-Digest\":\"sha1:SXPSMCGXSJGTXOTVQ5JQFE6CONBDTWIT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-21/CC-MAIN-2021-21_segments_1620243991252.15_warc_CC-MAIN-20210512035557-20210512065557-00281.warc.gz\"}"}
https://teachsomebody.com/course/view/introduction-to-python/nL8HuuFyHGcUs8E0CUpJD/4VI-HiK__xxx-eUA9zG7p/loops/
[ "", null, "Introduction to Python : Loops\n\n# Loops\n\nLoops are blocks of code that are used to execute a set of instructions repeatedly over a sequence or as long as a condition remains true. There are two types of loops in Python:\n\nFor...in loop\n\nThe for...in loop is used to execute a set of statements as we iterate over a sequence or list.\n\n``````for i in [1, 2, 3, 4]:\nprint(i + 1)``````\n\nThis simple program will output 2, 3, 4, and 5. On the first iteration, 'i' takes the value of 1 in the list and therefore outputs 2 (which is 1+1). In the second iteration, 'i' becomes 2 and therefore outputs 3 (2 +1), and so forth until we are at the end of the list.\n\nWhile loop\n\nThe 'while' loop is used to execute a block of code as long as a condition remains true. Example:\n\n``````x = 5\nwhile x < 8:\nprint(x)\nx = x + 1``````\n\nThis program will print 5, 6, and 7 since 'x' is initially equal to 5 which is less than 8. 'x' then becomes 6, 7 and 8 on subsequent iterations since 1 is added to the value of 'x' on each iteration. Once 'x' becomes 8, the condition fails (8 < 8 becomes False) and therefore the loop terminates.", null, "##### Introduction to Python\nNumber of sections:\n11\nContent length:\nDelivery formats:\nIntroduction to Python" ]
[ null, "https://www.facebook.com/tr", null, "https://public-media.teachsomebody.com/75eecd049cb343fbb0b6859000789a1c-pythonresi.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.94460106,"math_prob":0.97848034,"size":1039,"snap":"2021-31-2021-39","text_gpt3_token_len":301,"char_repetition_ratio":0.109178744,"word_repetition_ratio":0.066985644,"special_character_ratio":0.2983638,"punctuation_ratio":0.13114753,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9968832,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-08-03T20:03:17Z\",\"WARC-Record-ID\":\"<urn:uuid:5a0b81ff-e8d4-42e7-bb9a-5944bb10fce8>\",\"Content-Length\":\"100651\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:309f716a-c09c-40a1-a7b9-e125ff69f18a>\",\"WARC-Concurrent-To\":\"<urn:uuid:05451a5c-0ca1-4b91-995d-b6c6ee35eb21>\",\"WARC-IP-Address\":\"99.84.216.118\",\"WARC-Target-URI\":\"https://teachsomebody.com/course/view/introduction-to-python/nL8HuuFyHGcUs8E0CUpJD/4VI-HiK__xxx-eUA9zG7p/loops/\",\"WARC-Payload-Digest\":\"sha1:CV5RHXQDEICFTLT7332QXLNRCF6PMJA7\",\"WARC-Block-Digest\":\"sha1:EY3HGS57U62Z7YYN4HHE755TL3X6G4YL\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046154471.78_warc_CC-MAIN-20210803191307-20210803221307-00238.warc.gz\"}"}
https://www.vacations.info/metric/f-to-c.php?f=-50.5
[ "#### Convert -50.5 degrees Fahrenheit to Celsius\n\n##### -50.5 degrees Fahrenheit = -45.83 degrees Celsius\n Use this calculator to convert -50.5°f to Celsius. How many degrees Celsius in -50.5°f? -50.5°f to degrees Celsius is -45.83°c. How hot is -50.5°f in Celsius? How cold? Type the information into the input boxes and the degrees in Celsius will update automatically. Once again, -50.5°f in Celsius is equal to -45.83°c. Some units are rounded.\n\n#### Fahrenheit to Celsius Conversions\n\nFahrenheit\nCelsius\nHow much is -50.5 in Fahrenheit to Celsius?\n-50.5 degrees in Fahrenheit is -45.833333333333 degrees in Celsius" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8155626,"math_prob":0.93553734,"size":343,"snap":"2019-13-2019-22","text_gpt3_token_len":101,"char_repetition_ratio":0.19764012,"word_repetition_ratio":0.0,"special_character_ratio":0.32069972,"punctuation_ratio":0.18604651,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9916221,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-03-26T22:25:01Z\",\"WARC-Record-ID\":\"<urn:uuid:96b86204-ec28-4aa7-98bb-09d03739bee1>\",\"Content-Length\":\"5045\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9efd56e0-783c-4aec-9215-fc383c72f344>\",\"WARC-Concurrent-To\":\"<urn:uuid:5e1198e8-719c-4656-aa4f-f9edf7b71eb0>\",\"WARC-IP-Address\":\"34.229.141.192\",\"WARC-Target-URI\":\"https://www.vacations.info/metric/f-to-c.php?f=-50.5\",\"WARC-Payload-Digest\":\"sha1:43JKHOED4MBT6TP2TYTPBGOYFD766FWJ\",\"WARC-Block-Digest\":\"sha1:W2OWKXKC72J6MX6LM55ILMTBEQ765ESC\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-13/CC-MAIN-2019-13_segments_1552912206677.94_warc_CC-MAIN-20190326220507-20190327002507-00136.warc.gz\"}"}
https://search.r-project.org/CRAN/refmans/colourvision/html/CTTKmodel.html
[ "CTTKmodel {colourvision} R Documentation\n\n## Chittka (1992) colour vision model\n\n### Description\n\nChittka (1992) colour hexagon extended to animals with any number of photoreceptors types.\n\n### Usage\n\nCTTKmodel(photo=ncol(C)-1, R, I, Rb, C,\ninterpolate=TRUE, nm=seq(300,700,1))\n\n\n### Arguments\n\n photo Number of photoreceptor types. Model accepts any number of photoreceptor types (>=2). For instance, dichromatic: photo=2; trichromatic: photo=3; tetrachromatic: photo=4, etc. Default gets number of photoreceptor types from C argument. R Reflectance of observed objects. A data frame with first column corresponding to wavelength values and following columns with reflectance values. R must be in the same scale as Rb (percentage or proportion). I Irradiance spectrum. A data frame with two columns only: first column corresponding to wavelength values and second column with irradiance values. Irradiance values must be in quantum flux units. Rb Background reflectance. A data frame with two columns only: first column corresponding to wavelength values and second column with reflectance values. Rb must be in the same scale as R (percentage or proportion). C Photoreceptor sensitivity curves, from lowest to longest lambda-max. A data frame: first column corresponding to wavelength values and following columns with photoreceptor sensitivity values (see function photor). interpolate Whether data files should be interpolated before further calculations. See approx. nm A sequence of numeric values specifying where interpolation is to take place. See approx.\n\n### Details\n\nThe original model is available for trichromatic animals only. Thery and Casas (2002) derived a version for tetrachromatic animals which is implemented here. In colourvision, this model was extended to any number of photoreceptors types (Gawryszewski 2018; see also Pike 2012). The colour hexagon in Chittka (1992) has a vector of length = 1.0 The chromaticity coordinates in colourvision preserve the same vector length.\n\nPhotoreceptor outputs (E_i) are calculated by:\n\nE_i = \\frac{q_i}{q_i+1}\n\nwhere q_i is given by Qr.\n\nThen, for trichromatic vision, coordinates in the colour space are found by (Chittka 1992):\n\nX_1 = \\frac{\\sqrt{3}}{2}(E_3-E_1)\n\nX_2 = E_2-\\frac{1}{2}(E_1+E_3)\n\nFor tetrachromatic vision (Thery and Casas 2002):\n\nX_1 = \\frac{\\sqrt{3}\\sqrt{2}}{3}(E_3-E_4)\n\nX_2 = E_1-\\frac{1}{3}(E_2+E_3+E_4)\n\nX_3 = \\frac{2\\sqrt{2}}{3}(\\frac{1}{2}(E_3+E_4)-E_2)\n\nFor a pentachromatic animal following the same vector length:\n\nX_1 = \\frac{5}{2\\sqrt{2}\\sqrt{5}}(E_2-E_1)\n\nX_2 = \\frac{5\\sqrt{2}}{2\\sqrt{3}\\sqrt{5}}(E_3-\\frac{E_1+E_2}{2})\n\nX_3 = \\frac{5\\sqrt{3}}{4\\sqrt{5}}(E_4-\\frac{E_1+E_2+E_3}{3})\n\nX_4 = E_5-\\frac{E1+E2+E3+E4}{4}\n\n### Value\n\n Qri Photoreceptor photon catch values after the von Kries transformation (see function Qr). Ei Photoreceptor output values. Values can vary from 0 to 1. Xi Coordinates in the colour space. deltaS Euclidean distance to the origin of the colour space. It represents the conspicuousness of the stimulus (R) in relation to the background (Rb).\n\n### Author(s)\n\nFelipe M. Gawryszewski [email protected]\n\n### References\n\nChittka, L. 1992. The colour hexagon: a chromaticity diagram based on photoreceptor excitations as a generalized representation of colour opponency. J Comp Physiol A 170:533-543.\n\nGawryszewski, F.M. 2018. Colour vision models: Some simulations, a general n-dimensional model, and the colourvision R package. Ecology and Evolution, 10.1002/ece3.4288.\n\nPike, T.W. 2012. Generalised chromaticity diagrams for animals with n-chromatic colour vision. Journal of Insect Behavior 255: 277-286.\n\nThery, M., and J. Casas. 2002. Predator and prey views of spider camouflage. Nature 415:133-133.\n\nCTTKhexagon, CTTKhexagon3D, photor, RNLmodel, EMmodel, deltaS\n\n### Examples\n\n##Photoreceptor sensitivity curves\n##with lambda max at 350nm, 450nm and 550nm:\nC<-photor(lambda.max=c(350,450,550))\n\n## Grey background\n## with 10 percent reflectance from 300 to 700nm:\nRb <- data.frame(300:700, rep(10, length(300:700)))\n\n## Read CIE D65 standard illuminant\ndata(\"D65\")\n\n## Reflectance data\n## with a sigmoid spectrum and midpoint at 500nm\nR<-logistic(x=seq(300,700,1), x0=500, L=50, k=0.04)\n\n## Run model\nmodel<-CTTKmodel(photo=3, R=R, I=D65,\nRb=Rb, C=C)\n\n#plot\nplot(model)\n\n\n[Package colourvision version 2.0.4 Index]" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.6304592,"math_prob":0.9786052,"size":3809,"snap":"2023-40-2023-50","text_gpt3_token_len":1172,"char_repetition_ratio":0.12536137,"word_repetition_ratio":0.07378641,"special_character_ratio":0.30375427,"punctuation_ratio":0.14825174,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9920058,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-04T20:30:01Z\",\"WARC-Record-ID\":\"<urn:uuid:22909fd3-b357-4581-8d8a-63c81ce9f20a>\",\"Content-Length\":\"8350\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d6dfbfaa-88ee-4a9d-8b44-b21f663fa69e>\",\"WARC-Concurrent-To\":\"<urn:uuid:05293596-3318-4966-9593-c6f4420564b0>\",\"WARC-IP-Address\":\"137.208.57.46\",\"WARC-Target-URI\":\"https://search.r-project.org/CRAN/refmans/colourvision/html/CTTKmodel.html\",\"WARC-Payload-Digest\":\"sha1:X6MGVNWWYWG6YISWY4MTWG2Q3IYZY2HR\",\"WARC-Block-Digest\":\"sha1:7CAJAAN5D6AVTQFRZTHKGTSQZVPOJADP\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100534.18_warc_CC-MAIN-20231204182901-20231204212901-00526.warc.gz\"}"}
https://discuss.algo.monster/t/count-of-smaller-numbers-after-self-miscellaneous-divide-and-conquer/152
[ "# Count of Smaller Numbers After Self - Miscellaneous / Divide and Conquer\n\nPlease make animation little slower. Its too fast to understand.\n\nYou can view the images manually.\n\n“To answer that question we just have to sum up the numbers in the above output array: 2 + 1 + 1 = 5 swaps.”\n\nShould be 2 + 1 + 1 = 4…\n\nThanks, we’ve fix it.\n\nnot for this one, it appears as a gif for me\n\nI found it more intuitive to write a bubble sort that tracked the number of times a an element was pushed down the list in a dictionary. How does that compare to this solution?\n\nBubble sort is a O(n^2) solution. It would be equivalent (and easier) to just to a double for loop counting the number of smaller elements after the current one, with the inner loop starting from the end of the array and going to the index of the outer loop. However, that would not be the optimal solution.\n\nThis is exactly what I needed, thanks!" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9319332,"math_prob":0.9057424,"size":889,"snap":"2023-40-2023-50","text_gpt3_token_len":211,"char_repetition_ratio":0.10282486,"word_repetition_ratio":0.025,"special_character_ratio":0.24184477,"punctuation_ratio":0.10326087,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96887684,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-22T15:02:21Z\",\"WARC-Record-ID\":\"<urn:uuid:05bbc013-1359-4d59-987d-d3ed91a95512>\",\"Content-Length\":\"27542\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1aab1893-b75f-446a-b8cb-62192cca737a>\",\"WARC-Concurrent-To\":\"<urn:uuid:08188005-0bec-45bd-bc64-e9ca84a74c12>\",\"WARC-IP-Address\":\"74.82.16.203\",\"WARC-Target-URI\":\"https://discuss.algo.monster/t/count-of-smaller-numbers-after-self-miscellaneous-divide-and-conquer/152\",\"WARC-Payload-Digest\":\"sha1:WZRKCWEK7WGJB6A5KOBBJD2WMCARNJEH\",\"WARC-Block-Digest\":\"sha1:R326YS5QPL3HZOP3XL3T7XNTGGCWQEUV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233506420.84_warc_CC-MAIN-20230922134342-20230922164342-00064.warc.gz\"}"}
http://ashafrance.org/worksheet-for-year-2/
[ "# Worksheet For Year 2", null, "worksheet for year 2 greater less than worksheets greater than and less than worksheet worksheets year 2 maths place value.", null, "worksheet for year 2 free worksheets library download and print on for kindergarten.", null, "worksheet for year 2 printable activities for 2 year 2 year printable learning educational activity sheets for 2 year worksheet worksheets for 2 year.", null, "worksheet for year 2 doubling worksheets year 2 multiplying two digit decimals worksheet grade lovely multiplication and single double halving.", null, "worksheet for year 2 comparison workshes for grade 1 comparing fractions and preview money s year 2 common core.", null, "worksheet for year 2 chance test year 2 teaching resource.", null, "worksheet for year 2 worksheets for year 2 printable free 5 comprehension grade 4 song worksheet work.", null, "worksheet for year 2 jack and the beanstalk maths.", null, "worksheet for year 2 year 2 phonics worksheets grade 2 phonics worksheets worksheets for all download and share free printable grade 2 phonics worksheets.", null, "worksheet for year 2 shapes worksheets grade 5 year 2 names vertices and sides worksheet for maths.", null, "worksheet for year 2 count by worksheets free counting worksheets count by s collection of in worksheet year 2 download.", null, "worksheet for year 2 division word problem worksheets problems with tables multiplication and year 2 long times table 3.", null, "worksheet for year 2 doubling worksheets year 2 free doubling worksheets year 2 doubling worksheets doubling and halving worksheets grade 1.", null, "worksheet for year 2.", null, "worksheet for year 2 yr 2 maths worksheets year addition and subtraction kindergarten add a digit number numeracy free.", null, "worksheet for year 2 grade division worksheets multiplication.", null, "worksheet for year 2 year 2 numbers counting archives star worksheets skip by grade backwards worksheet 1.", null, "worksheet for year 2 s es worksheets plurals adding year 2 spelling practice y and activity sheet.", null, "worksheet for year 2 number and place value test year 2 teaching resource.", null, "worksheet for year 2 kids maths worksheets maths find the missing number addition and subtraction worksheets missing number addition and subtraction worksheets year 2.", null, "worksheet for year 2 designed by teachers money worksheets year 2 3 more.", null, "worksheet for year 2 5 times e worksheet year 2 worksheets free prine multiplication 1 kindergarten es practice blank.", null, "worksheet for year 2 save resource.", null, "worksheet for year 2 division work sheets worksheets for roots long grade 3 year 2 5 games worksheet graders printable division worksheets grade 2." ]
[ null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-greater-less-than-worksheets-greater-than-and-less-than-worksheet-worksheets-year-2-maths-place-value.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-free-worksheets-library-download-and-print-on-for-kindergarten.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-printable-activities-for-2-year-2-year-printable-learning-educational-activity-sheets-for-2-year-worksheet-worksheets-for-2-year.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-doubling-worksheets-year-2-multiplying-two-digit-decimals-worksheet-grade-lovely-multiplication-and-single-double-halving.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-comparison-workshes-for-grade-1-comparing-fractions-and-preview-money-s-year-2-common-core.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-chance-test-year-2-teaching-resource.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-worksheets-for-year-2-printable-free-5-comprehension-grade-4-song-worksheet-work.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-jack-and-the-beanstalk-maths.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-year-2-phonics-worksheets-grade-2-phonics-worksheets-worksheets-for-all-download-and-share-free-printable-grade-2-phonics-worksheets.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-shapes-worksheets-grade-5-year-2-names-vertices-and-sides-worksheet-for-maths.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-count-by-worksheets-free-counting-worksheets-count-by-s-collection-of-in-worksheet-year-2-download.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-division-word-problem-worksheets-problems-with-tables-multiplication-and-year-2-long-times-table-3.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-doubling-worksheets-year-2-free-doubling-worksheets-year-2-doubling-worksheets-doubling-and-halving-worksheets-grade-1.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-yr-2-maths-worksheets-year-addition-and-subtraction-kindergarten-add-a-digit-number-numeracy-free.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-grade-division-worksheets-multiplication.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-year-2-numbers-counting-archives-star-worksheets-skip-by-grade-backwards-worksheet-1.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-s-es-worksheets-plurals-adding-year-2-spelling-practice-y-and-activity-sheet.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-number-and-place-value-test-year-2-teaching-resource.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-kids-maths-worksheets-maths-find-the-missing-number-addition-and-subtraction-worksheets-missing-number-addition-and-subtraction-worksheets-year-2.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-designed-by-teachers-money-worksheets-year-2-3-more.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-5-times-e-worksheet-year-2-worksheets-free-prine-multiplication-1-kindergarten-es-practice-blank.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-save-resource.jpg", null, "http://ashafrance.org/wp-content/uploads/2019/01/worksheet-for-year-2-division-work-sheets-worksheets-for-roots-long-grade-3-year-2-5-games-worksheet-graders-printable-division-worksheets-grade-2.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.74854755,"math_prob":0.6185156,"size":2498,"snap":"2019-43-2019-47","text_gpt3_token_len":495,"char_repetition_ratio":0.38251805,"word_repetition_ratio":0.089058526,"special_character_ratio":0.19295436,"punctuation_ratio":0.057007127,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96347815,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"im_url_duplicate_count":[null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-14T17:19:17Z\",\"WARC-Record-ID\":\"<urn:uuid:2f580966-1459-4556-bb51-effb6ea5d3e4>\",\"Content-Length\":\"38050\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:86f2baea-dcb9-4159-ac13-136ac885c1db>\",\"WARC-Concurrent-To\":\"<urn:uuid:745175c3-68c5-4524-bf28-a897abaf50cb>\",\"WARC-IP-Address\":\"104.31.69.141\",\"WARC-Target-URI\":\"http://ashafrance.org/worksheet-for-year-2/\",\"WARC-Payload-Digest\":\"sha1:DCOWH6NXSZMH5JJBWB5XNN7NMSFUOZRC\",\"WARC-Block-Digest\":\"sha1:277I4AS3RMXMN7AZE3YL2IBZHEUJWNDO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496668529.43_warc_CC-MAIN-20191114154802-20191114182802-00248.warc.gz\"}"}
https://artofproblemsolving.com/wiki/index.php/2007_UNCO_Math_Contest_II_Problems/Problem_9
[ "# 2007 UNCO Math Contest II Problems/Problem 9\n\n## Problem\n\nA circle is inscribed in an equilateral triangle whose side length is", null, "$2$. Then another circle is inscribed externally tangent to the first circle but inside the triangle as shown. And then another, and another. If this process continues forever what is the total area of all the circles? Express your answer as an exact multiple of", null, "$\\pi$ (and not as a decimal approximation).", null, "$[asy] path T=polygon(3); draw(unitcircle,black); draw(scale(2)*T,black); draw(shift(2/sqrt(3),-2/3)*scale(1/3)*unitcircle,black); draw(shift(2/sqrt(3)/3,-2/9)*shift(2/sqrt(3),-2/3)*scale(1/9)*unitcircle,black); [/asy]$\n\n## Solution\n\nLet", null, "$ABC$ be the equilateral triangle and let", null, "$A_1B_1$ be the internal common tangent of the two largest circles, with the points", null, "$A_1$ and", null, "$B_1$ laying on the sides", null, "$AB$ and", null, "$BC$, respectively.\n\nLet", null, "$L$ be the point of tangency of the two circles.\n\nLet", null, "$OM$ be the inscribed circle's radius, with", null, "$O$ being its center and", null, "$M$ being the midpoint of", null, "$AB$. Let", null, "$BH$ be the triangle's altitude. We can calculate", null, "$OM$ using Pythagoras' Theorem:", null, "$OM^2 = BO^2 - BM^2$", null, "$OM^2 = \\left(\\frac{2}{3} \\times BH \\right)^2 - \\left(\\frac{1}{2} \\times AB \\right)^2$", null, "$OM^2 = \\left( \\frac{2 \\sqrt{3}}{3} \\right)^2 - 1^2$", null, "$OM = \\frac{\\sqrt3}{3}$", null, "$\\Rightarrow OM = \\frac{BH}{3}$\n\nFrom there we have", null, "$BL = OM = \\frac{BH}{3}$. This means the scale factor of the similar triangles", null, "$ABC$ and", null, "$A_1B_1B$ is", null, "$\\frac {1}{3}$ (because the ratio of their altitudes", null, "$\\frac{BL}{BH}$ is equal to", null, "$\\frac{1}{3}$ .)\n\nSince the smaller circle is inscribed in", null, "$A_1B_1B$, its radius is equal to", null, "$\\frac{OM}{3} = \\frac{\\sqrt3}{9}$ . Repeating this trend infinitely and summing all the areas gives us:", null, "$Area = \\pi \\left(\\frac{\\sqrt3}{3}\\right)^2 + \\pi \\left(\\frac{\\sqrt3}{9}\\right)^2 + \\pi \\left(\\frac{\\sqrt3}{27}\\right)^2 +\\pi \\left(\\frac{\\sqrt3}{81}\\right)^2 + ...$", null, "$Area = \\pi \\left(\\frac{1}{3} + \\frac{1}{3^3} + \\frac{1}{3^5} + \\frac{1}{3^7} + ... \\right)$\n\nWe have the geometric progression", null, "$B_n = \\frac{1}{3^{2n-1}}$ with a scale factor of", null, "$\\frac{1}{3}$ and a common ratio of", null, "$\\frac{1}{9}$ :", null, "$Area = \\pi \\times \\frac{\\frac{1}{3}}{1 - \\frac{1}{9}}$", null, "$Area = \\frac{3}{8} \\pi$" ]
[ null, "https://latex.artofproblemsolving.com/4/1/c/41c544263a265ff15498ee45f7392c5f86c6d151.png ", null, "https://latex.artofproblemsolving.com/f/2/c/f2ca003a7da0de4994b4733e203b74ff52d42553.png ", null, "https://latex.artofproblemsolving.com/8/a/f/8af6a485cf6e58a89645057e34404328fd5cbaa7.png ", null, "https://latex.artofproblemsolving.com/e/2/a/e2a559986ed5a0ffc5654bd367c29dfc92913c36.png ", null, "https://latex.artofproblemsolving.com/f/4/6/f468920603bf6bb9fc352c0b775c4c350b2dd9a4.png ", null, "https://latex.artofproblemsolving.com/3/6/c/36c7f3f828cf12ab9cafeffad282468a95219600.png ", null, "https://latex.artofproblemsolving.com/2/4/3/243af6fad28c15abb3e11996374ba60e745bf543.png ", null, "https://latex.artofproblemsolving.com/5/7/e/57ee5125358c0606c9b588580ddfa66f83e607b7.png ", null, "https://latex.artofproblemsolving.com/6/c/5/6c52a41dcbd739f1d026c5d4f181438b75b76976.png ", null, "https://latex.artofproblemsolving.com/8/5/9/859ccf4cd60c7bc6b8fa1afc9a42dc811a826d6f.png ", null, "https://latex.artofproblemsolving.com/b/b/2/bb2f5d57528aa7eeb9d5080cb5c25b4b06192862.png ", null, "https://latex.artofproblemsolving.com/5/1/d/51da37d984564162c87710ca27bea422f657fb73.png ", null, "https://latex.artofproblemsolving.com/5/d/1/5d1e4485dc90c450e8c76826516c1b2ccb8fce16.png ", null, "https://latex.artofproblemsolving.com/5/7/e/57ee5125358c0606c9b588580ddfa66f83e607b7.png ", null, "https://latex.artofproblemsolving.com/4/b/f/4bfc6159e268a0f5d736eca73477c99a13209da9.png ", null, "https://latex.artofproblemsolving.com/b/b/2/bb2f5d57528aa7eeb9d5080cb5c25b4b06192862.png ", null, "https://latex.artofproblemsolving.com/6/2/f/62fe76846cbedd71eeea21e84d85cf8245b66baf.png ", null, "https://latex.artofproblemsolving.com/8/3/7/8377f9d0ba46c11197a474a5e491e6b37fd24ff4.png ", null, "https://latex.artofproblemsolving.com/4/0/b/40bd511ac85652033a40a456d10f6cfaf08bec16.png ", null, "https://latex.artofproblemsolving.com/8/9/3/8938f3d6018aa79f2f17cf52587bc68a8d3cf15a.png ", null, "https://latex.artofproblemsolving.com/9/a/2/9a2d84945169e46661f99b0c6615480056765cc0.png ", null, "https://latex.artofproblemsolving.com/4/8/f/48ffb502755b67846b22edbde6a9476925367964.png ", null, "https://latex.artofproblemsolving.com/e/2/a/e2a559986ed5a0ffc5654bd367c29dfc92913c36.png ", null, "https://latex.artofproblemsolving.com/c/7/0/c70ffa349087c7abbd95cfc3bb36f41056cd2e27.png ", null, "https://latex.artofproblemsolving.com/b/8/2/b8229eaa7fcc15afd947a18d7c921214b5d94748.png ", null, "https://latex.artofproblemsolving.com/4/5/3/4532333f06364eb7662c0ab58ba0c5dcf0a19fb7.png ", null, "https://latex.artofproblemsolving.com/4/e/1/4e1965f8d70832ded66434c75a7bd52b75090af0.png ", null, "https://latex.artofproblemsolving.com/c/7/0/c70ffa349087c7abbd95cfc3bb36f41056cd2e27.png ", null, "https://latex.artofproblemsolving.com/0/6/4/0649ccc04f038e56b5c7455c7c61a2b9978dbeba.png ", null, "https://latex.artofproblemsolving.com/8/d/6/8d6a4f07c69447b0dce99c022d2e03894ae2e80d.png ", null, "https://latex.artofproblemsolving.com/0/5/4/0546d301e30880a11fe1318941451a42661fc632.png ", null, "https://latex.artofproblemsolving.com/3/0/2/302d303ba17879eff7b108e0beb88659440111f1.png ", null, "https://latex.artofproblemsolving.com/4/e/1/4e1965f8d70832ded66434c75a7bd52b75090af0.png ", null, "https://latex.artofproblemsolving.com/5/9/4/594c8b267069448b58fe77ad60497eb30f763a4a.png ", null, "https://latex.artofproblemsolving.com/b/7/1/b7157944d8381c92c42e2e7c3cc2b46ab042a05a.png ", null, "https://latex.artofproblemsolving.com/c/a/2/ca2b59af76a08bce29de9963c003c48ca9732d44.png ", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8794545,"math_prob":1.0000075,"size":1357,"snap":"2023-40-2023-50","text_gpt3_token_len":321,"char_repetition_ratio":0.1345159,"word_repetition_ratio":0.0,"special_character_ratio":0.23507738,"punctuation_ratio":0.07905138,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":1.0000077,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,10,null,10,null,10,null,10,null,10,null,10,null,null,null,null,null,null,null,10,null,null,null,null,null,7,null,10,null,10,null,10,null,null,null,null,null,10,null,10,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-01T04:43:45Z\",\"WARC-Record-ID\":\"<urn:uuid:996f8aee-1af3-416a-906c-14faec6b08bd>\",\"Content-Length\":\"42696\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:81a07f4b-9a0e-4b2f-b2e8-57be200dfe30>\",\"WARC-Concurrent-To\":\"<urn:uuid:71d53b2d-4f14-4fdc-9460-dc0a76bbd831>\",\"WARC-IP-Address\":\"104.26.11.229\",\"WARC-Target-URI\":\"https://artofproblemsolving.com/wiki/index.php/2007_UNCO_Math_Contest_II_Problems/Problem_9\",\"WARC-Payload-Digest\":\"sha1:JPYHCWT45A3AJAQ5TU2IRZWWM5GUIQCI\",\"WARC-Block-Digest\":\"sha1:R6N5P6PAHLSXMH24RCMHALBQ5TWWNICV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510781.66_warc_CC-MAIN-20231001041719-20231001071719-00616.warc.gz\"}"}
https://whatisconvert.com/325-square-feet-in-square-kilometers
[ "# What is 325 Square Feet in Square Kilometers?\n\n## Convert 325 Square Feet to Square Kilometers\n\nTo calculate 325 Square Feet to the corresponding value in Square Kilometers, multiply the quantity in Square Feet by 9.290304E-8 (conversion factor). In this case we should multiply 325 Square Feet by 9.290304E-8 to get the equivalent result in Square Kilometers:\n\n325 Square Feet x 9.290304E-8 = 3.0193488E-5 Square Kilometers\n\n325 Square Feet is equivalent to 3.0193488E-5 Square Kilometers.\n\n## How to convert from Square Feet to Square Kilometers\n\nThe conversion factor from Square Feet to Square Kilometers is 9.290304E-8. To find out how many Square Feet in Square Kilometers, multiply by the conversion factor or use the Area converter above. Three hundred twenty-five Square Feet is equivalent to zero point zero zero zero zero three zero one nine Square Kilometers.", null, "## Definition of Square Foot\n\nThe square foot (plural square feet; abbreviated sq ft, sf, ft2) is an imperial unit and U.S. customary unit (non-SI, non-metric) of area, used mainly in the United States and partially in Bangladesh, Canada, Ghana, Hong Kong, India, Malaysia, Nepal, Pakistan, Singapore and the United Kingdom. It is defined as the area of a square with sides of 1 foot. 1 square foot is equivalent to 144 square inches (Sq In), 1/9 square yards (Sq Yd) or 0.09290304 square meters (symbol: m2). 1 acre is equivalent to 43,560 square feet.\n\n## Definition of Square Kilometer\n\nSquare kilometre (International spelling as used by the International Bureau of Weights and Measures) or square kilometer (American spelling), symbol km2, is a multiple of the square metre, the SI unit of area or surface area. 1 km2 is equal to 1,000,000 square metres (m2) or 100 hectares (ha). It is also approximately equal to 0.3861 square miles or 247.1 acres.\n\n### Using the Square Feet to Square Kilometers converter you can get answers to questions like the following:\n\n• How many Square Kilometers are in 325 Square Feet?\n• 325 Square Feet is equal to how many Square Kilometers?\n• How to convert 325 Square Feet to Square Kilometers?\n• How many is 325 Square Feet in Square Kilometers?\n• What is 325 Square Feet in Square Kilometers?\n• How much is 325 Square Feet in Square Kilometers?\n• How many km2 are in 325 ft2?\n• 325 ft2 is equal to how many km2?\n• How to convert 325 ft2 to km2?\n• How many is 325 ft2 in km2?\n• What is 325 ft2 in km2?\n• How much is 325 ft2 in km2?" ]
[ null, "https://whatisconvert.com/images/325-square-feet-in-square-kilometers", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8690605,"math_prob":0.9987388,"size":2385,"snap":"2020-24-2020-29","text_gpt3_token_len":611,"char_repetition_ratio":0.24653506,"word_repetition_ratio":0.09779951,"special_character_ratio":0.28301886,"punctuation_ratio":0.124223605,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99484575,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-02T20:11:52Z\",\"WARC-Record-ID\":\"<urn:uuid:6acf15b0-7b01-499c-9c30-76740ae16306>\",\"Content-Length\":\"28150\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:34445aab-1b75-4dd0-9f08-073cf0bd012c>\",\"WARC-Concurrent-To\":\"<urn:uuid:14ba9e24-0c16-45c8-8763-ccc34b75b1bc>\",\"WARC-IP-Address\":\"104.31.71.53\",\"WARC-Target-URI\":\"https://whatisconvert.com/325-square-feet-in-square-kilometers\",\"WARC-Payload-Digest\":\"sha1:DMHLPJDBU5CR6DWEPSDYG7L3P33KDO4R\",\"WARC-Block-Digest\":\"sha1:OC5H3FKNEKVZU2JS2X6CERJC3SMPRJY4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655879738.16_warc_CC-MAIN-20200702174127-20200702204127-00344.warc.gz\"}"}
https://odinlake.wordpress.com/programming-interview-questions/
[ "## Programming Interview Questions\n\nI sometimes study programming questions that may show up during an interview. Some of them have funny or surprising solutions, so I thought I’d list them here. Some of the solutions may be my own (in the sense that I didn’t use a reference) and in either case they may be wrong, so be aware. Comments are appreciated as always.\n\n1. Propose a data structure that supports the stack push and pop operations and a third operation find_min, which returns the smallest element in the data structure, all in O(1) worst case time.\n\nNext see if you can modify the structure to also let you identify the second smallest element in O(1) time.\n\nSolution: Maintain two normal stacks S and SM. Pushes and pulls are always performed on S as normal, but in addition if the item pushed or pulled is minimal, also push/pull it to/from SM. The top of SM will always be minimal and thus find_min can be performed in constant time. I was initially tricked as I thought of “delete_min” (which would be impossible) rather than “find_min”.\n\nThe follow up problem can be solved similarly: Let the secondary stack contain pairs of elements (s1, s2) such that whenever (s1, s2) is on top here then s1 is the minimum element and s2 the second smallest. Alternatively maintain three stacks in total where the top of the second is always minimal and the top of the third is always the second smallest.\n\n[stacks.h, stacks.cpp]\n\n2. Write an algorithm to check whether a given unsigned number is a multiple of 3, without using division and modulo operators.\n\nSolution: There are tons of inefficient ways (e.g. multiply by three until you get a bigger number) and probably quite a few ways to get % by means of bit-wise operations. The niftiest solution, however, seems to be based on intentionally overflowing a uint. I’m not a pro on this kind of arithmetic, but my understanding is as follows. Suppose we wish to check for divisibility by d=3. There is a uint M such that “uint(M*d)=1”. If d=3 and uint is 32 bits, then M=0xaaaaaaab; I’m not going to motivate further, just check it yourself. But if our input number “I = k*d+s” where s<d and k<(0xFFFFFFFF/d) (otherwise I is larger than any uint) then “M*I = k*(M*d) + M*s = k + M*s” but this is <0x55555555 exactly when s=0 or equivalently when I is divisible by d. In short C:\n\n```/* Assumes int is 32-bit */\nint divs3(unsigned int n) {\nconst int M = 0xAAAAAAAB;\nreturn (n*M<0x55555555);\n}\n```\n\nSo we have a solution that only requires two relatively simple operations (although the multiplication could be expensive, but I doubt there is an equally nifty way to do it without multiplication). I would like to generalize this to various d>3 but there are some problems. It would be interesting to know if there is a class of numbers for which a similar trick can work – ideas?\n\n3. Find the second smallest element in an array using only “n + log_2 n” comparisons (note: no big-oh here, we may for example not use 2n comparisons).\n\nSolution: I find this solution elegant, that’s why I include it even though it doesn’t seem very usefull in practice. Compare all the elements in pairs and retain the smallest from each pair: n/2 comparisons. The winner (smallest) of each pair must be linked to the loser in some way, e.g. by a linked list. Recurse: “n/2 + n/4 + … <= n” comparisons. Now you have the smallest element – but the second smallest must have been “eliminated” during a comparison with the smallest! This is a collection of less than “log n” numbers and trivially we can find min with “log n” comparisons.\n\nThis solution seems useful only if comparisons are unusually expensive. I say it is not very useful in practice because I have never encountered a situation in which I would want the second smallest element, other than in the case of numbers; and numbers are as far as I can tell always cheap to compare relative to the cost it would take to keep track of all the loosers in the comparisons. Strings we usually want to sort, don’t we?\n\nThis question relates to question 13: to find the k:th smallest element.\n\n4. In linear time for an array of size n, find the majority element if it exists; i.e. an element occuring more than n/2 times.\n\nSolution: Another fairly elegant problem not likely to appear in real life very often. Like in the previous case, divide the elements into pairs; discard any pairs that are not equal and then arbitrarily discard half of each remaining pair. Repeat until one number remains, check if this number is a majority element. The time this takes is O(n+n/2+n/4+…)=O(n) because with each repetition at least half of the list is discarded. Further, suppose X is a majority element, then X continues to be a majority element through each reduction: Discarding unequal pairs discards at most one X for each other element and the remaining list must obviously have more pairs of the type (X, X) than any other kind of pair (so (X,X) is a majority element in the list of pairs).\n\n5. Implement division without using division.\n\nSolution: This shows up time and again, I will give my solution in C. There are probably much niftier ways to do it, but I think this should be a good tradeoff between comprehensible and efficient. If T is to be divided by B:\n\n```int mydiv(int T, int B) {\nif (B>T) return 0;\n\nint d = B;\nint count = 1;\n\nwhile (d*2 <= T) {\nd *= 2;\ncount *= 2;\n}\n\nreturn (count + mydiv(T-d, B));\n}\n```\n\nNote that I write “*2” for readability, the compiler should turn it into “<<1” so actually this method doesn’t use multiplication either (only subtraction, shift and comparisons). The recursion is also easy to get rid of, if undesirable. The time it takes is obviously O((log(T/B))^2): The while loop stops at the i:th step when “B*2^i > T”, i.e. as soon as “i > log(T/B)” and this number must decrease for each level of the recursion (exercise: prove the last statement).\n\nNote: For large numbers this can be done much faster by changing the present “while” loop to a binary search. I.e., shift left/right by 16, 8, 4… to find the correct d in each recursion step.\n\n6. Find or determine non existence of a number in a sorted list of N numbers where the numbers range over M, M >> N and N large enough to span multiple disks. Algorithm to beat O(log n) bonus points for constant time algorithm.\n\nSolution: This has confused many people and in order to not get it wrong I decided to copy it with the exact wording as I found it. At a first glance it seems impossible – a binary search will take time O(log n), but we are asked to beat that and even encouraged to try for constant time(!) One trick could be some argument about hardware I don’t perceive fully, as the problem is presented in an external memory type of model (maybe computation is essentially free and we only need to worry about block reads from the disks, but this doesn’t solve it I think). A more likely approach is to give a randomized algorithm with good expected behaviour for reasonable assumptions about the data.\n\nAssume therefore that the N numbers were choosen uniformly at random from [0,M-1]. Suppose we are looking for a number D=a*M for some non-negative a<1. Then shorely we should start looking at position a*N in the list (If you want to look up “zebra” in an old dictionary, do you start looking in the middle of the book?). Now however comes the difficullt part: How close are we after having picked L[a*N]? This will require tools that you probably need an advanced university course (statistics and ramdonized algorithms or the like) to understand well, but I’ll try to keep it simple.\n\nSince M is very large, the number of elements smaller than (a*M) is essentially a binomially distributed random variable Xa~BIN(N, a). This variable is said to be “sharply concentrated” about its expectation a*N; applying e.g. Chernoff bounds, we can show that the probability that “Xa < a*N – 2*log(N)” is very small, e.g. something like “N^(-c)” for some positive constant c. A better analysis should of course sort out all the cases, but since the probability above is so small let’s just assume we are within a distance of 2*log(N) of the right answer. This has therefore (in constant time with high probability) reduced the problem to only 4*log(N) numbers!\n\nNow do a normal binary search with worst case time O(log(log(N)). Note: Although one may be tempted to recurse with the above method, it doesn’t work because once the interval becomes log(N) the probability of a relatively large deviation is no longer so small.\n\nIn short we end up with an algorithm that terminates with the right answer in time O(log(log(N)) with probability greater than (1 – N^(-c)) for some constant c. This, by the way, is a stronger result than just saying the expectation is O(log(log(N)). (Exercise: Calculat [bound] the expectation). Furthermore, since M>>N note that log(log(N)) << log(log(M)) and even if M is the range of a whooping 256-bit word, this is less than 8. Yes, that’s right: we should need no more than an order of 8 tries to find our result. Make M the range of a (ridiculous) 65536-bit word and it becomes 16 tries. Although a little inprecise, it is not unreasonable to say that our algorithm is O(1) constant time for all practical purposes.\n\nI think this is a nice example to demonstrate the power and signifficance of randomized algorithms and average case analysis.\n\n[my sample code here…]\n\n7. Give a fast way to multiply a number by 7.\n\nSolution: A couple of solutions:\n\n```uint mult7(uint n) { return (n*7); }\nuint mult7(uint n) { return (n+n+n+n+n+n+n); }\nuint mult7(uint n) { return ((n<<3) - n); } //probably the one they want\nuint mult7(uint n) { return ((n<<2) + (n<<1) + n); }\n```\n\n8. You are given a small sorted list of numbers, and a very very long sorted list of numbers – so long that it had to be put on a disk in different blocks. How would you find those short list numbers in the bigger one?\n\nSolution: This smells akin to number 6, doesn’t it? Let N be the size of the smaller list and M be the size of the larger list. If N is really very small, it is hard to see how we could do much better than binary searches. But if it is not so small then it constitutes a sample of the domain of the elements and if we make assumptions about the distribution (uniform) then we can apply the method of #6 to succeed in time O(N log(log(M)) with a probability that goes to 1 as N increases. Again we expect the first element to be at position M/N in the list – it’s silly to start looking in the middle, isn’t it?\n\nBut I guess the expected answer to this question is different, because there is a way to do it that you might miss at a first glance. Obviously we can do N binary searches in time O(N log(M)), but this discards much information after each step. Say instead we do like this: Pick the midpoint of the small list and binary search for it in the large list: Time O(log(M)). Suppose this splits the large list into two pieces of sizes M1, M2: M1+M2=M. We now have two problems with parameters like (M1, N/2) and (M2, N/2) respectively (well except we found the first number already) and we can find two more items of the small list in time O( log(M1) + log(M2) ) <= O( 2*log(M/2) ), in the process splitting the long list into 4 pieces that, similarily, in the worst case have sizes M/4. Recursing in this way we find the “1+2+4+…+(N/2) = N”:th element roughly in log(N) steps, the i:th of which took time O( 2^i log( M/2^i ) ). Let T be the total time.\n\n```T <= log(M) + 2*log(M/2) + 4*log(M/4) + ... + (N/2)*log(M/(N/2))\n<= log(M^N) - log(2^2 * 4^4 * 8^8 ... * (N/2)^(N/2))\n<= N*log(M/N)\n```\n\nNot terribly impressive if N is “small”, it may seem, but obviously better than doing the N searches independently. Again note that this is a worst case that we get only if an evil person gave us a tricky list – if we assume some distribution of the elements we can do much better. Oh, and if “small” means e.g. N=M/1000… Well then we have time O(N), pretty neat eh!\n\nCome to think of it, a cheeky way to answer #6 would be “sure, I can give you ammortized constant time if you give me enough input numbers in sorted order!”.\n\n9. Find the longest increasing sub-sequence in an array of N elements. Or put another way: Remove as few elements as possible from the array so that the remaining items are sorted from small to large.\n\nSolution: Once upon a time I believe I found this one out on my own in an algorithms course, but this time around I had to look it up. A sign that I’m getting old: depressing. Dynamic programming is the solution, of course:\n\nStart from the left; for each potential sequence length (say L in [0,N]), keep track of a sequence with that length and with a smallest possible last element. That is, there may be many sequences of a specific length L, but we only need to remember one that has the smallest possible last element – the others are redundant. Intuitively, a sequence with small last element is best because any element that can “extend” one of the other sequences can extend that one.\n\nSo when we move right in the list of numbers and test a new element X, then for every “best” path (say again of length L) that X can extend we check if the new path (of length L+1) is “better” than the old best path of length L+1. If it is, we replace it. In the end, the answer is the sequence associated with the largest length that is associated with any sequence. Since we have to go through the list of lengths for every new element, the algorithm is O(n^2) in the worst case.\n\n[my sample code here…]\n\n10. Implement Quick-Sort in-place.\n\nSolution: I got it into my mind to try and make the most elegant Quick-Sort C-implementation I could come up with. Here it is:\n\n```int array_qsort(int *a, int n) {\nif (n<=1) return 0;\nint i = 0, j = n-1;\nint pivot = a[j];\n\nwhile (i<j) {\nwhile (i<j && a[i]<=pivot) i++;\na[j] = a[i]; //now i points to empty cell\nwhile (i<j && a[j]>=pivot) j--;\na[i] = a[j]; //now j points to empty cell again\n}\n\na[j] = pivot;\narray_qsort(a, j);\narray_qsort(&a[j+1], n-j-1);\n}\n```\n\n(Actually it is prudent to use a random pivot but I excluded that here – just begin by swapping a random element with the last.) Though simple enough, it took me a while to come up with this code because at first I didn’t want the “i<j” checks in the inner while-loops. Unfortunately I see no pretty way around them as i or j could in the odd case run outside the array otherwise. Btw., by “elegant” I mean a solution that is a good trade-off between (locally) optimal and short understandable code. Several solutions I’ve seen waste a memory operations by moving elements unneccessarily (e.g. moving a[i] to a[j] even if it is smaller than the pivot; though it would save some code, I wanted to avoid that).\n\n11. Test if integer is a power of 2.\n\nSolution:\n\n```x>0 && (x-1)&x == 0, or\nx>0 && x&(-x) == x\n```\n\nboth five operations. Slightly niftier is\n\n```x && !(x & (x - 1))\n```\n\nwith only four operations.\n\n12. Print a spiral of numbers, with 1 in the middle and spiraling outwards with increasing numbers, using constant memory.\n\nSolution: This is just engineering of course, no particular cleverness involved, though I had to keep my tounge checked. The output space is a grid, let’s introduce (x,y) coordinates in the natural directions and let’s say that the spiral should start upwards, that is, that 1 is at (0,0), 2 at (0,1), 3 at (-1,1) and so on. Note that now the coordinates (1,1), (2,2), (3,3)… correspond to completed squares of radi 1,2,3… respectively. But the the number at this position must be 9,25,49… and so on. That is the number at (x,x) for non-negative x is “(2(x+1)-1)^2”. Other numbers can be calculated easily from this by sorting out certain cases. Check the following function for yourself!\n\n```int spiral_seq(int x, int y) {\nif (x==y && x>=0) return ( (2*(x+1)-1) * (2*(x+1)-1) );\nif (y>0 && -y<=x && x<=y) return ( spiral_seq(y-1, y-1) +y-x );\nif (x<0 && x<=y && y<=-x) return ( spiral_seq(x, -x) -x-y );\nif (y<0 && y<=x && x<=-y) return ( spiral_seq(y, y) +x-y );\nif (x>0 && -x<=y && y<=x) return ( spiral_seq(x, -x) +y+x );\nelse fprintf(stderr, \"Error, logical in spiral_seq(%d, %d)\\\\n\",x,y);\n}\n\nint dig = (int)log10((double)max) + 1;\nchar format;\nint x,y,p;\n\nsprintf(format, \"%%.%du \", dig);\n\np = spiral_seq(x,y);\nprintf(format, p);\n}\nfor (x=0; x<dig/4+1; x++) printf(\"\\\\n\");\n}\n}\n```\n\nAnd here is some sample output:\n\n```57 56 55 54 53 52 51 50 81\n58 31 30 29 28 27 26 49 80\n59 32 13 12 11 10 25 48 79\n60 33 14 03 02 09 24 47 78\n61 34 15 04 01 08 23 46 77\n62 35 16 05 06 07 22 45 76\n63 36 17 18 19 20 21 44 75\n64 37 38 39 40 41 42 43 74\n65 66 67 68 69 70 71 72 73\n```\n\n13. Find the k:th smallest element in an array using linear time (worst case) and constant extra memory (may reorder elements of the array).\n\nSolution: This one I had to look up – they go under the name selection algorithms. The idea builds on the quick sort implementation I showed earlier (question 10) but of course avoids sorting elements that are on the “wrong” side of the pivot. Suppose we are looking for the 10:th largest element and find a pivot p that splits the array in two parts, (S, {p}, L) where |S|>10. Well then obviously our target is in S and we can discard L. Even if we discard only 10% of the elements in each step, the time will be linear: O( N + 0.9N + (0.9^2)N + …) = O(N) (I have used this time and again, look up “geometric series” if you’re unsure).\n\nUsing a random pivot it is not hard to get a linear expected time, so the difficullty here is to “improve” that “expected” to a “worst case”. I write “improve” because I understand the worst case optimal algorithms have slightly worse expected case behaviour in general. Hybrids like introspective sort and introspective select try to get the best of two worlds. I will now try to explain a straightforward way of obtaining a worst case linear time algorithm. The idea is to find a guaranteed good pivot. The best pivot would be exactly the k:th smallest element that we are looking for, but to keep things a little simpler, I will settle for approximating the median. We need to show that our approximation discards at least a portion of the elements in each step.\n\nWe need a median finding algorithm but that’s also what we are designing so the answer is recursion! The median is the (N/2):th smallest element and as a base case, we can find this easily by any reasonable sorting algorithm as soon as the array has less than, say, 10 elements. If the array is larger than that we can do as follows:\n1. Make groups of five elements and calculate the median for each group, this is N/5 numbers.\n2. Find the true median of all the (N/5) medians by using this entire algorithm that we are designing recursively (even though it is not finished yet).\n\nOnce we have the true median, M, of the N/5 group medians we use this as a pivot. Why is this a good pivot? N/10 group medians are larger than M, but for each such group median there are also two numbers that must be larger still.. Therefore there are at least 3N/10=0.3N elements that are larger than M, which is not too shabby. Vice versa, of course, there are also 0.3N elements that are smaller than M. Note that I have ignored some rounding issues.\n\nBut with a good pivot, we are free to recurse as mentioned above, and we are done! The two different recursions performed by this algorithm are confusing and we need to be a bit careful with step 2. Say that the algorithm takes time bounded by T(N) when applied to N numbers. Then\n\n```T(N) ≤ O(N) + T(0.2N) + T(0.7N) ≤ O(N)(1 + 0.9 + 0.9^2 + 0.9^3 + ...) ≤ O(N)\n```\n\nSorting out the induction there may not be entirely obvious, but I don’t want to go into details. Just make the assumption that “T(N) ≤ cN+d” for some constants c and d, and the proof should yield. Why did we use the constant 5 by the way? Let’s try three, then pivot is guarranteed to cut of (1/3)N elements and the expression becomes “T(N) ≤ O(N) + T(N/3) + T(2N/3)” but this is not good because the recursive steps take roughly as long time at each level and the algorithm fails to be linear! If we pick 7 for the groups, we get “T(N) ≤ O(N) + T(N/7) + T(2N/7) ≤ O(N)(1 + (3/7) + …)” which seems better so it is not obvious why we should desire a small group size. On the other hand, sorting the groups is rather expensive e.g. c*log(c) for group size c and the improvement during the recursion seems rather marginal in comparison. Nontheless, I won’t try to pursue this further. The strongest result I’m aware of says we can find the k:th smallest element with less than 2.95N comparisons (look up Dor and Zwick: “Selecting the Median”), but at this level of optimization I’d think other issues become more important in practice.\n\n14. Write a small lexical analyzer.\n\nSolution: That’s a bit vague and I’m not sure what it’s supposed to do. Less booring, I decided, would be something that parses simple math expressions.\n\n```double _str_evaluate(char *s, int n) {\nint i=0, j=n-1,k,d,c;\ndouble ans,op1,op2,dec;\nint open, priority, op;\nint test;\n\n//some base cases and spaces\nif (j<i) return 0;\nwhile (s[i]==' ') i++;\nwhile (s[j]==' ') j--;\nif (j<i) return 0;\n\n//parantheses\nif (s[i]=='(' && s[j]==')') {\ntest=-1; open=1;\nfor (k=i+1; k<j && open>0; k++) {\nif (s[k]=='(') open++;\nelse if (s[k]==')') open--;\n}\nif (open==1)\nreturn _str_evaluate(&s[i+1], j-i-1);\n}\n\n//is number?\nfor (k=i,ans=0,c=-1,test=0; k<=j; k++) {\nif (s[k]=='.') {\nif (c==-1) { c=10; continue; }\nelse { test=-1; break; }\n}\nd = s[k]-'0';\nif (d>9 || d<0) { test=-1; break; }\nif (c<0) ans = ans*10 + d;\nelse { ans += d*(1.0/c); c*=10; }\n}\nif (test>=0) return ans;\n\n//find lowest precedence open operator\nopen = 0; priority = 100; op = -1;\nwhile (j>i) {\nif (s[j]==')') open++;\nif (s[j]=='(') open--;\nif (open==0) {\nif (s[j]=='^' && priority>50) {\npriority = 50;\nop = j;\n} else if ((s[j]=='*' || s[j]=='/') && priority>40) {\npriority = 40;\nop = j;\n} else if ((s[j]=='+' || s[j]=='-') && priority>30) {\npriority = 30;\nop = j;\n}\n}\nj--;\n//assert: open>=0\n}\n\n//evaluate\nop1 = _str_evaluate(s, op);\nop2 = _str_evaluate(&s[op+1], n-op-1);\n\nif (s[op]=='^') return pow(op1, op2);\nif (s[op]=='*') return op1*op2;\nif (s[op]=='/') return op1/op2;\nif (s[op]=='+') return op1+op2;\nif (s[op]=='-') return op1-op2;\n\nreturn 0; //FAIL\n}\n\ndouble str_evaluate(char *sz) {\nint n = str_length(sz);\nreturn _str_evaluate(sz, n);\n}\n```\n\nI’ve ignored any error handling aspects so there are evil expressions that make it crash and burn. It does well with normal things like “(3+4.2)-1.2*(4.01-3.2/2)” or “1 + 1/2 + 1/4 + 1/8 + 1/16 + 1/32” etc.\n\n15. Given an array of length N containing integers between 1 and N, determine if it contains any duplicates.\n\nSolution: This is trivial in O(N^2) time, O(1) memeory. We can also do it in O(N*log N) time in-place if we may reorder the array. We can do it with a pigeon-hole technique in time O(N) using an O(N) look-up table. These are all fairly trivial observations, but several sources seem to suggest that we may be asked to do it in “linear time without using any extra memory”. I will give a solution to this that requires some “light” assumptions. Let’s call the array “a=(a(1), a(2), …, a(N))”:\n\nIf we may destroy the data we only need one reserved value to use, that is a single value outside [1,N]. Since the question is posed with the range starting from 1 rather than 0 as would be natural for most programmers, maybe this is what they had in mind. It’s still rather silly if you ask me: Just go through the list and for each a(i) encountered write 0 to a(a(i)) unless it’s 0 already, in which case we would have our answer. This solution doesn’t appeal to me though.\n\nThere could be a really legitimate solution possible, suggestions are welcome. Someone pointed out to me that the array defines a linked list that must be circular if there are no duplicates… The problem is that more precisely, it may define several linked lists that are indeed all circular when the array is without duplicates. Great, so what’s the problem? Let’s consider the suggested algorithm. Start with a(i), go to a(a(i)) and so on. Use Floyd’s cycle finder (next question) to detect when the linked list intersects itself. With some more cleverness we can find the shape of the linked list.\n(i) If it is a P (lollipop shape), one position has multiple incoming links which would mean that there is a duplicate and we are done.\n(ii) If it is an O (circular), then we stop and proceed to try some other element.\nBut here’s the problem, how do we find “another” element? If we try to start from every element the algorithm may become O(N^2) again. We can’t mark any positions, if we could there are simpler solutions. That said, there are certainly many things that could be tried. I’d be happy to learn about a solution!\n\n(i) Given the head of a singly linked list, find out in linear time and using only constant memory, the length of the list – which might contain a cycle. Identify the length and location of the cycle if it exists.\n\n(ii) Given a pointer to some element in a singly linked list, but neither the head or anything else of it, describe how to delete the element. Do it in constant time, and describe any neccessarry contingency.\n\nSolution: (i) This one became really popular in my circles a few years ago – presumably because Google used it as an interview question. It is conveniently solved with Floyd’s cycle finding algorithm [Wikipedia].\n\n(ii) This one I got recently at a phone interview and it took a kick in the butt before I saw it was possible. The idea is not to get hooked on the containing nodes of the LL but to realize that the important thing is the order of the elements. Go to the node we have a pointer to – overwrite that element with the element of the next node, then delete the entire next node by redirecting the “next” pointer of its predecessor (the “current” node). Be careful if asked to delete the last node; this method requires that a node can be flagged as an end node somehow (I often implement linked lists with the last node pointing to NULL, but that wouldn’t work here).\n\n17. Given an array of integers whereof all but one occurs an even number of times, find the one that occurs an odd number of times.\n\nIt’s so simple that it’s silly, except it’s also easy to miss. Just XOR all the numbers together and you will be left with exactly the one number that occurs an odd number of times. You can do this in linear time with a single pass and constant extra memory. With sufficient processors working in parallel you can get it to O(log N) time (XOR N/2 pairs together in parallel, then repeat with N/4 pairs of the previous answers and so on).\n\n18. Suppose I give you the sequence of elements obtained from an in-order traversal of a tree; reconstruct the tree. How about pre-order and post-order?\n\nThis is a trick, the answer is that it is impossible in general. Probably the simplest way of proving that is to consider a sequence of two elements (a, b). This sequence can represent two different trees, and that fact remains true regardless of whether sequence is in-, pre- or post-order.\n\nCuriously, if two sequences are given whereof one is in-order and the other either post- or pre- order, there is a solution that can be explained with relative ease: We know the root element since this is the tail of the post-order or the head of the pre-order sequence. Knowing the head we can use the in-order sequence to partition the remaining elements into those of the left and right sub-trees respectively. Tongue checked, we might from here be able to argue that the reminder follows by recursion.\n\nPerhaps even more surprisingly at this point, pre-order + post-order is not sufficient. Consider (a, b) as pre-order together with (b, a) as post-order; there are again two possible trees that can yield these sequences.\n\n### One Comment to “Programming Interview Questions”\n\n1.", null, "" ]
[ null, "https://2.gravatar.com/avatar/ba76e087e05c9d70eedb490a46fb22ed", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9055456,"math_prob":0.9761503,"size":30188,"snap":"2020-34-2020-40","text_gpt3_token_len":7805,"char_repetition_ratio":0.12374105,"word_repetition_ratio":0.11750774,"special_character_ratio":0.27732873,"punctuation_ratio":0.1095267,"nsfw_num_words":3,"has_unicode_error":false,"math_prob_llama3":0.99543613,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-14T19:17:28Z\",\"WARC-Record-ID\":\"<urn:uuid:0629a189-1d6b-459a-a477-05a6a2cff999>\",\"Content-Length\":\"104616\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:54bbc0ac-00b8-4882-93b5-89027e2a29bf>\",\"WARC-Concurrent-To\":\"<urn:uuid:7a802c1b-2343-4636-b0cd-cf6dd1d5cecd>\",\"WARC-IP-Address\":\"192.0.78.13\",\"WARC-Target-URI\":\"https://odinlake.wordpress.com/programming-interview-questions/\",\"WARC-Payload-Digest\":\"sha1:X3FU2QPT45TNHZGED47XJEDM2O2UIBXT\",\"WARC-Block-Digest\":\"sha1:AMCMVIGCMQ2JIA4WMJL53GAKNBIXESZR\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439739370.8_warc_CC-MAIN-20200814190500-20200814220500-00362.warc.gz\"}"}
https://isquared.digital/visualizations/2023-01-13-barnsley-fern/
[ "# The Barnsley Fern: Ferns Seen as Fractals (not only as plants)\n\nFerns are beautiful plants that exhibit a self-similar structure: the entire plant is similar to a part of itself. This property makes them interesting from a mathematical point of view. The fern pattern can be described as a fractal that can be mathematically generated, thus being reproducible at any scale. We can zoom-in indefinitely and never run out of ferns.\n\nThe generation of a fern fractal might seem like a complicated task, but in fact it is quite simple. It conforms to the simplicity of the fractal geometry: cranking the same formula over and over again.\n\nIn this visualization guide, we will learn how the generation of a fern is mathematically defined coupled with a Python implementation. Then we will see how to utilize this fern generation system to produce and plot different types of ferns using Matplotlib.\n\n# Definition\n\nThe British mathematician Michael Barnsley was the first to describe and formalize the fern fractal. For this reason the fern fractal is called the Barnsley Fern.\n\nThe fern fractal can be generated using four instances (different sets of coefficients) of the following affine transformation:\n\n$f\\left(x_{n+1}, y_{n+1}\\right) = \\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix} * \\begin{bmatrix} x_{n} \\\\ y_{n} \\end{bmatrix} + \\begin{bmatrix} e \\\\ f \\end{bmatrix}$\n\ns.t. each instance is having a certain probability of being chosen. The original Barnsley Fern is generated using the following coefficients and probabilities:\n\nw a b c d e f p\nf1 0 0 0 0.16 0 0 0.01\nf2 0.85 0.04 -0.04 0.85 0 1.60 0.85\nf3 0.20 -0.26 0.23 0.22 0 1.60 0.07\nf4 -0.15 0.28 0.26 0.24 0 0.44 0.07\n\n# Python Implementation\n\nIn this section we will see how to implement in Python the fern fractal generation defined above. First we define the data structures we need as namedtuples:\n\nfrom collections import namedtuple\n\ntransformations = namedtuple(\"transformations\", [\"f1\", \"f2\", \"f3\", \"f4\"])\ncoefficients = namedtuple(\"coefficients\", [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"])\nfern_settings = namedtuple(\"fern_settings\", [\"transformations\", \"probabilities\"])\n\n\nThe namedtuples hold all the coefficients for the affine transformations as well as their assigned probabilities. Consequently, we instantiate the settings we need to generate a Barnsley Fern:\n\nbarnsley_fern_coefficients = transformations(\nf1=coefficients(.0, .0, .0, .16, .0, .0),\nf2=coefficients(.85, .04, -.04, .85, 0, 1.6),\nf3=coefficients(.20, -.26, .23, .22, .0, 1.6),\nf4=coefficients(-.15, .28, .26, .24, .0, .44),\n)\nbarnsley_fern_probabilities = [.01, .85, .07, .07]\nbarnsley_fern = fern_settings(\ntransformations=barnsley_fern_coefficients,\nprobabilities=barnsley_fern_probabilities,\n)\n\n\nIn this way the 4 affine transformations are indexed with indexes between 0 and 3. Finally, we pass the barnsley_fern namedtuple in the following function to generate all the points:\n\nimport numpy as np\n\ndef generate_fern(selected_fern_settings: namedtuple, num_points: int) -> list:\nrng = np.random.default_rng() # Generator object\n\n# generate num_points indexes from 0 to 3 according to the probability\nindexes = rng.choice(\na=len(selected_fern_settings.probabilities),\nsize=num_points,\np=selected_fern_settings.probabilities,\nshuffle=False\n)\n\n# x_0 and y_0 at time step 0\nx, y = .0, .0\nfern_points = []\nfor idx in indexes:\nfern_points.append((x, y)) # save x_{n} and y_{n}\ncoeff = selected_fern_settings.transformations[idx]\n\n# calculate x_{n + 1} and y_{n + 1} using x_{n} and y_{n}\nx, y = coeff.a * x + coeff.b * y + coeff.e, coeff.c * x + coeff.d * y + coeff.f\n\nreturn fern_points\n\n\nAs the affine transformations are already indexed from 0 to 3, we randomly sample num_points indexes between 0 and 3 using the assigned probabilities. For this purpose we use the NumPy choice method from the Generator class.\n\nIn the iteration process that follows, we map the sampled indexes back to the affine transformation they point to and calculate the coordinates. We start from the initial coordinates (0, 0) and calculate the next coordinates using the ones calculated in the previous iteration.\n\nIf we plot the points generated by the function above using Matplotlib, we get a nice figure that resembles a fern:\n\nThe Barnsley Fern Fractal\n\nIf you like this content you can subscribe to the mailing list below to get similar updates from time to time.\n\n# Appendix: Other types of fern fractals\n\nBy playing with the coefficients of the four affine transformation defined above, we can get different interesting results. Some of these results are shown in the figures below.\n\n## Fishbone Fern\n\nThe Fishbone Fern Fractal can be obtained using the following transformations and probabilities:\n\nw a b c d e f p\nf1 0 0 0 0.25 0 -0.4 0.02\nf2 0.95 0.002 -0.002 0.93 -0.002 0.5 0.84\nf3 0.035 -0.11 0.27 0.01 -0.05 0.005 0.07\nf4 -0.04 0.11 0.27 0.01 0.047 0.06 0.07\n\nBy cranking the iterative formula many times we get the following result:\n\nThe Fishbone Fern Fractal\n\n## Fractal Tree\n\nUsing the Barnsley Fern technique we can “mutate” the ferns into fractal trees. If we fit the following coefficients and probabilities\n\nw a b c d e f p\nf1 0 0 0 0.5 0 0 0.04\nf2 0.42 -0.42 0.42 0.42 0 0.2 0.4\nf3 0.42 0.42 -0.42 0.42 0 0.2 0.4\nf4 0.1 0 0 0.1 0 0.2 0.15\n\nwe get an interesting result that resembles a tree as shown below:\n\nA Fractal Tree\n\nUpdated:" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.7765381,"math_prob":0.99125195,"size":5555,"snap":"2022-40-2023-06","text_gpt3_token_len":1720,"char_repetition_ratio":0.1381733,"word_repetition_ratio":0.034602076,"special_character_ratio":0.31143114,"punctuation_ratio":0.18041237,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99772996,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-02-03T13:52:51Z\",\"WARC-Record-ID\":\"<urn:uuid:ddbcde66-e72b-46d0-8542-f0b0b07b4ac1>\",\"Content-Length\":\"35269\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0d36406e-e555-4eee-91d7-0d5295ce1e40>\",\"WARC-Concurrent-To\":\"<urn:uuid:f078fd58-d5b1-4bf6-9024-7f8b08102908>\",\"WARC-IP-Address\":\"185.199.108.153\",\"WARC-Target-URI\":\"https://isquared.digital/visualizations/2023-01-13-barnsley-fern/\",\"WARC-Payload-Digest\":\"sha1:TCJBNWGYVIJQ6L2N74X7COJDF3X5P7YM\",\"WARC-Block-Digest\":\"sha1:37QQYRLWI3YMCT3LCQRJ2CGAKIMDEIJX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764500056.55_warc_CC-MAIN-20230203122526-20230203152526-00675.warc.gz\"}"}
https://www.hackmath.net/en/word-math-problems/perimeter?tag_id=143
[ "# Perimeter + motion problems - math problems\n\n#### Number of problems found: 6\n\n• Gears", null, "The front gear on the bike has 32 teeth and the rear, on the wheel, has 12 teeth. How many times does the rear wheel of the bike turns if you turn the right pedal 30 times? What distance will you go if the circumference of the bicycle wheel is 250 cm?\n• Velocipedes", null, "In the 19th century, bicycles did not have a chain drive, and the pedals were connected directly to the wheel axis. This wheel diameter gradually increased until the so-called high bicycles (velocipedes) with a front wheel diameter of up to 1.5 meters, wh\n• Earth's diameter", null, "The Earth's diameter on the equator is approximately 12750 km. How long does the Gripen flyover the Earth above the equator at 10 km if it is at an average speed of 1500 km / h?\n• Engine pulley", null, "The engine has a 1460 rev / min (RPM). Disc diameter is 350 mm. What will be the disc peripheral speed in RPM? Pulleys on the engine has diameter 80mm, on a disc has diameter 160mm.\n• Average speed", null, "What is the average speed you have to move the way around the world in 80 days? (Path along the equator, round to km/h).\n• Rotation of the Earth", null, "Calculate the circumferential speed of the Earth's surface at a latitude of 61°​​. Consider a globe with a radius of 6378 km.\n\nWe apologize, but in this category are not a lot of examples.\nDo you have an interesting mathematical word problem that you can't solve it? Submit a math problem, and we can try to solve it.\n\nWe will send a solution to your e-mail address. Solved examples are also published here. Please enter the e-mail correctly and check whether you don't have a full mailbox.\n\nPlease do not submit problems from current active competitions such as Mathematical Olympiad, correspondence seminars etc..." ]
[ null, "https://www.hackmath.net/thumb/71/t_29671.jpg", null, "https://www.hackmath.net/thumb/87/t_7987.jpg", null, "https://www.hackmath.net/thumb/30/t_4930.jpg", null, "https://www.hackmath.net/thumb/60/t_3260.jpg", null, "https://www.hackmath.net/thumb/17/t_3917.jpg", null, "https://www.hackmath.net/thumb/21/t_21.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.929021,"math_prob":0.95510554,"size":1601,"snap":"2020-34-2020-40","text_gpt3_token_len":398,"char_repetition_ratio":0.12586099,"word_repetition_ratio":0.13377926,"special_character_ratio":0.25109306,"punctuation_ratio":0.094801225,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9611333,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-23T08:22:20Z\",\"WARC-Record-ID\":\"<urn:uuid:bf5d1644-7ffc-45d0-b136-bbea880eb126>\",\"Content-Length\":\"34145\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:cb05739a-04fd-48e0-9c52-330a54ae2abf>\",\"WARC-Concurrent-To\":\"<urn:uuid:f1ed23ec-33bc-44eb-b5ab-523660decd6b>\",\"WARC-IP-Address\":\"104.24.105.91\",\"WARC-Target-URI\":\"https://www.hackmath.net/en/word-math-problems/perimeter?tag_id=143\",\"WARC-Payload-Digest\":\"sha1:M24D3MGJ6VS5SQAP7HGR4K67ARDIR6IC\",\"WARC-Block-Digest\":\"sha1:FU5IJ77AQTFWPVSILT2352OUSCBK2X77\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400210616.36_warc_CC-MAIN-20200923081833-20200923111833-00280.warc.gz\"}"}
https://www.sanfoundry.com/engineering-metrology-basic-questions-answers/
[ "# Engineering Metrology Questions and Answers – Evaluating Uncertainty in Measurement\n\n«\n»\n\nThis set of Basic Engineering Metrology Questions and Answers focuses on “Evaluating Uncertainty in Measurement”.\n\n1. Which type of distribution approach is not followed by systematic error?\na) U-shaped distribution approach\nb) Rectangular distribution approach\nc) Triangular distribution approach\nd) Normal distribution approach\n\nExplanation: Conventional approach used to evaluate measurement uncertainty is based on random error and systematic error. Systematic error follows Rectangular, Triangular or U-shaped distribution approach.\n\n2. Which approach is accepted as an international procedure in evaluating the uncertainty of measurement?\na) Conventional approach\nb) Modern approach\nc) Experimental approach\nd) Observational approach\n\nExplanation: Modern approach is accepted as an international procedure. It is useful even for those problems where limited observations are possible. It is problem specific and defines the method explicitly.\n\n3. How many methods of evaluation of uncertainty are based upon modern approach?\na) 2 methods namely Type-A and Type-B\nb) 2 methods namely Type-1 and Type-2\nc) 3 methods namely Type-A, Type-B and Type-C\nd) 3 methods namely Type-1, Type-2 and Type-3\n\nExplanation: Modern approach is based on Type A method and Type B method. When observations are taken under same measurement conditions, Type A method is used. In type B method of modern approach, the uncertainty in measurement is evaluated by the judgement of the available information.\n\n4. Which of the following option is correct for given statements about evaluation of uncertainty of measurement?\nStatement 1: Principle of evaluation of uncertainty by modern approach is approximately the same as conventional approach.\nStatement 2: Conventional approach is problem specific.\na) T, F\nb) F, F\nc) F, T\nd) T, T\n\nExplanation: Modern approach defines the method explicitly and is problem specific. In those problems where only limited observations are possible, modern approach is very useful.\n\n5. Which type of approach is followed by random errors?\na) Poisson distribution approach\nb) Binomial distribution approach\nc) Gaussian distribution approach\nd) Polynomial distribution approach\n\nExplanation: Random errors are those which can be caused by little variation in the standard setting of position, operator errors in reading the display of instrument etc. Random error follows the normal frequency or Gaussian distribution approach.\n\n6. What is the main characteristic of random errors used to determine maximum measuring error?\na) Cumulative error\nb) Standard deviation\nc) Variance\nd) Median\n\nExplanation: Random errors are those which are produced due to large number of fluctuating and unpredictable errors that are non controllable in nature. The main characteristic of random errors is standard deviation, used to determine maximum measuring error.\n\n7. What is the relation between maximum error for a measurement method and standard deviation in the case of random errors?\na) Maximum error equal to standard deviation\nb) Maximum error is two times of standard deviation\nc) Maximum error is three times of standard deviation\nd) Maximum error is four times of standard deviation\n\nExplanation: Spread of possible random error values is determined by the maximum error. The maximum error for a measurement method is three times the standard deviation. The maximum error and standard deviation determine the accuracy of measurement.\n\n8. Which of the following error is not a systematic error?\na) Error induced due to stylus pressure\nb) Instrument location errors\nc) Error due to parallax\nd) Error due to play in the instrument’s linkages\n\nExplanation: Systematic errors can be caused due to calibration errors, Stylus pressure, ambient conditions (Variation from ambient temperature, pressure etc), Avoidable errors (due to the effect of misalignment of centre of workpiece and parallax) and incorrect theory.\n\n9. What is the advantage of statistical methods?\na) Increase the value of (Quality/cost)\nb) Increase the value of (Cost/Quality)\nc) Decrease the value of (Cost * Quality)\nd) Increase the value of (Cost * Quality)\n\nExplanation: The value of (Quality/cost) increases with the help of statistical methods which means offer same quality at low cost or good quality at same cost or both i.e. better quality and less cost. Convention approach which is based upon random errors for evaluating the uncertainty of measurement follow the statistical methods.\n\n10. What is true about random errors?\na) Sign of error can be predicted\nb) Probability of occurrence of same absolute value is not equal for negative and positive errors\nc) Constant in magnitude\nd) Arithmetic mean in a measurement series approaches zero as measurement number increases", null, "" ]
[ null, "https://www.sanfoundry.com/wp-content/uploads/2017/01/Manish2.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8435464,"math_prob":0.8817186,"size":5497,"snap":"2020-34-2020-40","text_gpt3_token_len":1095,"char_repetition_ratio":0.15601675,"word_repetition_ratio":0.040865384,"special_character_ratio":0.1859196,"punctuation_ratio":0.09003215,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97796416,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-29T01:24:01Z\",\"WARC-Record-ID\":\"<urn:uuid:b9acd301-2993-41d4-a680-b5b1af31c966>\",\"Content-Length\":\"104292\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ee5f01ae-136c-4118-9578-90054580faed>\",\"WARC-Concurrent-To\":\"<urn:uuid:6755694d-b9ce-4594-81c1-8e6194e20456>\",\"WARC-IP-Address\":\"104.25.131.119\",\"WARC-Target-URI\":\"https://www.sanfoundry.com/engineering-metrology-basic-questions-answers/\",\"WARC-Payload-Digest\":\"sha1:2FIRY5OE7MNDDT7N4MU7JWHA6H3EJQPR\",\"WARC-Block-Digest\":\"sha1:NR4ZKLODCB3DET3FYHKIAUCZPKYB4Q46\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600401617641.86_warc_CC-MAIN-20200928234043-20200929024043-00734.warc.gz\"}"}
https://codereview.stackexchange.com/questions/178262/non-overflowing-avg-calculation-with-integer-arithmetic
[ "# Non-overflowing avg calculation with integer arithmetic\n\nI have multiple long values and I want to calculate their average value using integer arithmetic, without precision loss and using java rounding rules for division, i.e. when N is 10 and sum is +/- 29, then 29/10 == 2 and -29/10 == -2, not -3.\n\nThe code should handle situations when the sum of all elements overflows the type.\n\nThe resulting type should be the same as the elements' type, not double.\n\nIt is ok to return bad result if N exceeds the maximum supported value for the element type\n\nThe code should not use a bigger type to store the sum, because there can be no bigger type, when elements are of type long in java or intmax_t in c++. Using double can lead to precision loss; arbitrary precision integers like BigInteger are too slow for this task.\n\nI found a solution that best suits me: How can I compute the average of a large array of integers without running into overflow?. In short: they divide each element before summing and therefore avoid the overflow.\n\nAs the first replier said, I adapted it for negative values. There was a divisor overflow check: y >= N - b, I replaced it with the type overflow check: when the sign of the remainder sum changes, I increment or decrement the current avg. For some reason, it works even when the sign changes not because of an overflow.\n\nThere's also Precise and safe calculation method for the average of large integer arrays, but I found it later and I didn't have time to check. On first glance, they don't check the cumulated_remainder overflow in case of many elements.\n\nI chose to use 8-bit integers for the test implementation, because they're easier to count mentally. Also, it is possible to check all value combinations in short arrays in reasonable time.\n\nIn some places I use the addition assignment operator += instead of assignment to avoid unnecessary casts.\n\navg_slow() is using BigInteger to produce the expected results for comparison.\n\nstatic byte avg(final byte[] vals) {\nfinal int n = vals.length;\nbyte avg = 0, remsum = 0, remrem = 0;\nfor (int i = 0; i < n; i++) {\nfinal byte val = vals[i];\navg += val / n;\nfinal byte oldremsum = remsum;\nbyte rem = 0;\nrem += val % n;\nremsum += rem;\n\nif (oldremsum < 0) {\nif (remsum >= 0 && rem < 0) {\navg--;\nremsum += n;\n}\n} else if (oldremsum > 0 && remsum < 0 && rem > 0) {\navg++;\nremsum -= n;\n}\n}\navg += remsum / n;\nremrem += remsum % n;\nif (avg < 0 && remrem > 0) {\navg++;\n} else if (avg > 0 && remrem < 0) {\navg--;\n}\nreturn avg;\n}\n\nstatic void calcAndCompare(final byte[] vals) {\nfinal byte avgex = avg_slow(vals);\nfinal byte avgact = avg(vals);\nif (avgact != avgex) {\nSystem.out.println(\"ex:\" + avgex + \" act:\" + avgact + \" \" + Arrays.toString(vals));\nSystem.exit(1);\n}\n}\n\nstatic void test129() {\nfinal byte[] vals = new byte;\nArrays.fill(vals, (byte) -128);\ncalcAndCompare(vals);\n}\n\nstatic void test100() {\nfinal byte[] vals = new byte;\nvals = -1;\nvals = 100;\ncalcAndCompare(vals);\n}\n\nstatic void testMaxN() {\nbyte b = 1;\nwhile ((b <<= 1) > 0);\nb--;\nfinal byte[] vals = new byte[(int)(b > Short.MAX_VALUE ? Short.MAX_VALUE : b)];\n\nArrays.fill(vals, b);\ncalcAndCompare(vals);\n\nb++;\n\nArrays.fill(vals, b);\ncalcAndCompare(vals);\n}\n\nstatic void test67() {\n\nbyte b = 1;\nwhile ((b <<= 1) > 0);\nb--;\n\nfinal byte[] vals = new byte;\n\nArrays.fill(vals, (byte) -110);\ncalcAndCompare(vals);\n\nArrays.fill(vals, (byte) 110);\ncalcAndCompare(vals);\n\ndouble d = b;\nd++;\nfor (int i = 0; i < vals.length; i++) {\nvals[i] = (byte) ((Math.random() * 2 * d) - d);\n}\ncalcAndCompare(vals);\n}\n\nstatic void testAllCombinations(final int depth, final byte... vals) {\nif (depth == vals.length) {\ncalcAndCompare(vals);\nreturn;\n}\nfor (byte b1 = Byte.MIN_VALUE;; b1++) {\nvals[depth] = b1;\ntestAllCombinations(depth + 1, vals);\nif (b1 == Byte.MAX_VALUE) {\nbreak;\n}\n}\n}\n\npublic static void main(final String[] args) {\n\ntest100();\ntestMaxN();\ntest129();\n\ntest67();\n\ntestAllCombinations(0, new byte);\ntestAllCombinations(0, new byte);\n}\n\nstatic byte avg_slow(final byte[] vals) {\nif (false) {\nreturn avg(vals);\n}\nfinal int n = vals.length;\nBigInteger sum = BigInteger.ZERO;\nfor (int i = 0; i < n; i++) {\nfinal byte val = vals[i];\n}\nbyte res = 0;\nres += sum.divide(BigInteger.valueOf(n)).longValue();\nreturn res;\n}\n\n• Indeed. If n > 128 then val / n == 0 and val % n == n, therefore remsum += val % n can overflow. – Martin R Oct 19 '17 at 9:04\n• @MartinR fixed by remsum >= 0 – basin Oct 19 '17 at 9:08\n• Unless I made an error, it still fails for a 1000-element array filled with 127. – Martin R Oct 19 '17 at 9:12\n• I wonder if the pair of avg and remsum can unambiguously describe the avg in case of very big N – basin Oct 19 '17 at 9:28\n• Those problems arise because you chose a very small data type, so that adding two remainders (which are in the range -N+1...N-1) might result in an overflow. I assume that your algorithm works correctly if N is less that half of the maximal integer value. For 32-bit int or 64-bit long that would not be a substantial restriction. – Martin R Oct 19 '17 at 9:33\n\nThis is Java, not C. You don't have to declare all the variables at the start of the method. There are 20 lines between the declaration of remrem and the first use. Keeping variables to the smallest scope possible aids readability.\n\nAlso, it's not obligatory to declare variables to be equal to the \"default\" value. Observe:\n\n byte ... remrem = 0;\n...\nremrem += remsum % n;\n\n\nand\n\n byte rem = 0;\nrem += val % n;\n\n\nBoth of those could be simplified to a simple initialisation to the desired value and made final.\n\nArguably an extension of minimising scope is avoiding unnecessary variables.\n\n for (int i = 0; i < n; i++) {\nfinal byte val = vals[i];\n\n\ncould perfectly well be\n\n for (byte val : vals) {\n\n\nsince i is not used elsewhere.\n\n if (oldremsum < 0) {\nif (remsum >= 0 && rem < 0) {\navg--;\nremsum += n;\n}\n} else if (oldremsum > 0 && remsum < 0 && rem > 0) {\navg++;\nremsum -= n;\n}\n\n\nI understand (for the most part) why this is written as it is, but the asymmetry slowed me down slightly. (The bit I still don't understand is why one half uses >= and the other half uses <). Would it be preferable to make the test symmetric using basic properties of twos-complement numbers?\n\n if ((oldremsum ^ remsum) < 0 && (oldremsum ^ rem) >= 0) {\n// Sign of remsum has changed when adding a number of the same sign,\n// so there has been overflow.\nif (rem < 0) {\navg--;\nremsum += n;\n}\nelse {\navg++;\nremsum -= n;\n}\n}" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.6018822,"math_prob":0.9929414,"size":4403,"snap":"2020-45-2020-50","text_gpt3_token_len":1240,"char_repetition_ratio":0.122982495,"word_repetition_ratio":0.08181818,"special_character_ratio":0.32591414,"punctuation_ratio":0.18390805,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9946243,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-11-28T20:45:37Z\",\"WARC-Record-ID\":\"<urn:uuid:b147af8a-cf20-470d-b8a4-1c26f71d9c20>\",\"Content-Length\":\"164184\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5432fce5-aea2-48ca-b4bf-8a8f94d79acb>\",\"WARC-Concurrent-To\":\"<urn:uuid:cc76c188-5a93-4b71-af44-24833d6f85f0>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://codereview.stackexchange.com/questions/178262/non-overflowing-avg-calculation-with-integer-arithmetic\",\"WARC-Payload-Digest\":\"sha1:GXHJJ776U4G4O45FGNJMJCJVW6EW4AAZ\",\"WARC-Block-Digest\":\"sha1:HJ3LZFCEKCVOKAA57SDM5TQPT2PMFUG7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141195745.90_warc_CC-MAIN-20201128184858-20201128214858-00333.warc.gz\"}"}
https://www.tradespoon.com/blog/ebook/historical-implied-volatility/
[ "Tradespoon’s technology bases predictive analytics on Statistical Analysis in order to serve our traders. In this section, we look at Historical Volatility versus Implied Volatility, and why it is important in Statistical Analysis. We also review how Historical Volatility and Implied Volatility are affected by Standard Deviation, Bell Shaped Curve and Probability Analysis.\n\nHistorical volatility\nHistorical Volatility can be defined as the realized Volatility of a financial instrument over a given time period. Generally, this measure is calculated by determining the average deviation from the average price of a financial instrument in the given time period. Historical Volatility shows you the measure of underlying asset changes in the past.\n\nImplied volatility\nImplied Volatility is computed using a model and can be defined as the estimated volatility of a security’s price. It is determined by the underlying options data that will expire in the future. This means that the Implied Volatility shows you a glance into the future.\n\nNote the Bell Shaped Curve graph in Figure 24A for rolling two die. Historical Volatility, or Historical Statistical Analysis, will show that you will get a seven almost 70% of the time and you will get either a six or an eight 40% of the time. When predicting, you will know that six, seven or eight will come out more often. In that same way, you can also trade options. Certain strike prices by certain expiration dates will come out more often than the others.", null, "Furthering this concept: based on the 1 Standard Deviation for options in the Probability Calculator, you can see that certain Strike Prices such as the µ depicted here will come out 68% of the time. Based on Historical Data or Implied Volatility, this means that a certain stock will move to a certain Strike Price by the expiration date 68% of the time. 1 Standard Deviation of 68% Probability for stock reaching Strike Price µ by certain date.\n\nTradespoon’s Probability Calculator provides Support and Resistance based on Standard Deviation Analysis, as well as the Trend which gives you the directional bias. The top part of the Probability Calculator is based on Implied Volatility and the bottom part is based on Historical Volatility analysis. In Figure 24C, the Support is \\$49.76 and \\$51.94 and the Trend is predicted as 9 and 8.", null, "" ]
[ null, "http://www.tradespoon.com/blog/wp-content/uploads/2017/03/Screen-Shot-2017-03-31-at-4.55.56-PM.png", null, "http://www.tradespoon.com/blog/wp-content/uploads/2017/03/24c.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9323691,"math_prob":0.88991266,"size":2339,"snap":"2019-51-2020-05","text_gpt3_token_len":479,"char_repetition_ratio":0.15503211,"word_repetition_ratio":0.005277045,"special_character_ratio":0.19410004,"punctuation_ratio":0.08490566,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9759696,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,5,null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-18T02:53:30Z\",\"WARC-Record-ID\":\"<urn:uuid:a35e3c7c-ab57-40cb-8d04-a3ff0f2d7575>\",\"Content-Length\":\"49402\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:858b9031-e570-440e-aecf-8510eaafb51d>\",\"WARC-Concurrent-To\":\"<urn:uuid:547c5cc7-247f-4c27-8e26-aac61a024d92>\",\"WARC-IP-Address\":\"104.26.8.100\",\"WARC-Target-URI\":\"https://www.tradespoon.com/blog/ebook/historical-implied-volatility/\",\"WARC-Payload-Digest\":\"sha1:BBVNSRNVMLIYWXYSZRPF55Q7K6XBPB2Z\",\"WARC-Block-Digest\":\"sha1:U2CBJ3JCHDWH4E5F4YCSHSD3BEOB6AWO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579250591763.20_warc_CC-MAIN-20200118023429-20200118051429-00440.warc.gz\"}"}
https://www.php.net/manual/pt_BR/language.oop5.references.php
[ "PHP 7.4.12 Released!\n\n## Objetos e Referências\n\nUm dos pontos fortes frequentemente mencionado da POO no PHP 5, é que \"objetos são passados por referências por padrão\". Isto não é completamente verdade. Esta seção retifica esse pensamento comum usando alguns exemplos.\n\nUma referência do PHP é um sinônimo, que permite duas variáveis diferentes escreverem para o mesmo valor. A partir do PHP 5, uma variável objeto não contém mais o próprio objeto como valor. Ela contém um identificador do objeto que permite que os acessadores do objeto encontrem o objeto real. Quando um objeto é enviado por argumento, retornado ou atribuído a outra variável, as variáveis diferentes não são sinônimos: elas armazenam uma cópia do identificador, que aponta para o mesmo objeto.\n\nExemplo #1 Referências e Objetos\n\n``` <?phpclass A {    public \\$foo = 1;}\\$a = new A;\\$b = \\$a;     // \\$a e \\$b são cópias do mesmo identificador             // (\\$a) = (\\$b) = <id>\\$b->foo = 2;echo \\$a->foo.\"\\n\";\\$c = new A;\\$d = &\\$c;    // \\$c e \\$d são referências             // (\\$c,\\$d) = <id>\\$d->foo = 2;echo \\$c->foo.\"\\n\";\\$e = new A;function foo(\\$obj) {    // (\\$obj) = (\\$e) = <id>    \\$obj->foo = 2;}foo(\\$e);echo \\$e->foo.\"\\n\";?> ```\n\nO exemplo acima irá imprimir:\n\n```2\n2\n2\n```", null, "add a note\n\n### User Contributed Notes 18 notes\n\n289\nmiklcct at gmail dot com\n10 years ago\n``` Notes on reference:A reference is not a pointer. However, an object handle IS a pointer. Example:<?phpclass Foo {  private static \\$used;  private \\$id;  public function __construct() {    \\$id = \\$used++;  }  public function __clone() {    \\$id = \\$used++;  }}\\$a = new Foo; // \\$a is a pointer pointing to Foo object 0\\$b = \\$a; // \\$b is a pointer pointing to Foo object 0, however, \\$b is a copy of \\$a\\$c = &\\$a; // \\$c and \\$a are now references of a pointer pointing to Foo object 0\\$a = new Foo; // \\$a and \\$c are now references of a pointer pointing to Foo object 1, \\$b is still a pointer pointing to Foo object 0unset(\\$a); // A reference with reference count 1 is automatically converted back to a value. Now \\$c is a pointer to Foo object 1\\$a = &\\$b; // \\$a and \\$b are now references of a pointer pointing to Foo object 0\\$a = NULL; // \\$a and \\$b now become a reference to NULL. Foo object 0 can be garbage collected nowunset(\\$b); // \\$b no longer exists and \\$a is now NULL\\$a = clone \\$c; // \\$a is now a pointer to Foo object 2, \\$c remains a pointer to Foo object 1unset(\\$c); // Foo object 1 can be garbage collected now.\\$c = \\$a; // \\$c and \\$a are pointers pointing to Foo object 2unset(\\$a); // Foo object 2 is still pointed by \\$c\\$a = &\\$c; // Foo object 2 has 1 pointers pointing to it only, that pointer has 2 references: \\$a and \\$c;const ABC = TRUE;if(ABC) {  \\$a = NULL; // Foo object 2 can be garbage collected now because \\$a and \\$c are now a reference to the same NULL value} else {  unset(\\$a); // Foo object 2 is still pointed to \\$c} ```\n214\nAnonymous\n9 years ago\n``` There seems to be some confusion here. The distinction between pointers and references is not particularly helpful.The behavior in some of the \"comprehensive\" examples already posted can be explained in simpler unifying terms. Hayley's code, for example, is doing EXACTLY what you should expect it should. (Using >= 5.3)First principle:A pointer stores a memory address to access an object. Any time an object is assigned, a pointer is generated. (I haven't delved TOO deeply into the Zend engine yet, but as far as I can see, this applies)2nd principle, and source of the most confusion:Passing a variable to a function is done by default as a value pass, ie, you are working with a copy. \"But objects are passed by reference!\" A common misconception both here and in the Java world. I never said a copy OF WHAT. The default passing is done by value. Always. WHAT is being copied and passed, however, is the pointer. When using the \"->\", you will of course be accessing the same internals as the original variable in the caller function. Just using \"=\" will only play with copies.3rd principle:\"&\" automatically and permanently sets another variable name/pointer to the same memory address as something else until you decouple them. It is correct to use the term \"alias\" here. Think of it as joining two pointers at the hip until forcibly separated with \"unset()\". This functionality exists both in the same scope and when an argument is passed to a function. Often the passed argument is called a \"reference,\" due to certain distinctions between \"passing by value\" and \"passing by reference\" that were clearer in C and C++.Just remember: pointers to objects, not objects themselves, are passed to functions. These pointers are COPIES of the original unless you use \"&\" in your parameter list to actually pass the originals. Only when you dig into the internals of an object will the originals change.Example:<?php//The two are meant to be the same\\$a = \"Clark Kent\"; //a==Clark Kent\\$b = &\\$a; //The two will now share the same fate.\\$b=\"Superman\"; // \\$a==\"Superman\" too.echo \\$a; echo \\$a=\"Clark Kent\"; // \\$b==\"Clark Kent\" too.unset(\\$b); // \\$b divorced from \\$a\\$b=\"Bizarro\";echo \\$a; // \\$a==\"Clark Kent\" still, since \\$b is a free agent pointer now.//The two are NOT meant to be the same.\\$c=\"King\";\\$d=\"Pretender to the Throne\";echo \\$c.\"\\n\"; // \\$c==\"King\"echo \\$d.\"\\n\"; // \\$d==\"Pretender to the Throne\"swapByValue(\\$c, \\$d);echo \\$c.\"\\n\"; // \\$c==\"King\"echo \\$d.\"\\n\"; // \\$d==\"Pretender to the Throne\"swapByRef(\\$c, \\$d);echo \\$c.\"\\n\"; // \\$c==\"Pretender to the Throne\"echo \\$d.\"\\n\"; // \\$d==\"King\"function swapByValue(\\$x, \\$y){\\$temp=\\$x;\\$x=\\$y;\\$y=\\$temp;//All this beautiful work will disappear//because it was done on COPIES of pointers.//The originals pointers still point as they did.}function swapByRef(&\\$x, &\\$y){ \\$temp=\\$x; \\$x=\\$y; \\$y=\\$temp; //Note the parameter list: now we switched 'em REAL good.}?> ```\n41\nAaron Bond\n11 years ago\n``` I've bumped into a behavior that helped clarify the difference between objects and identifiers for me.When we hand off an object variable, we get an identifier to that object's value.  This means that if I were to mutate the object from a passed variable, ALL variables originating from that instance of the object will change.  HOWEVER, if I set that object variable to new instance, it replaces the identifier itself with a new identifier and leaves the old instance in tact.Take the following example:<?phpclass A {    public \\$foo = 1;}  class B {    public function foo(A \\$bar)    {        \\$bar->foo = 42;    }        public function bar(A \\$bar)    {        \\$bar = new A;    }}\\$f = new A;\\$g = new B;echo \\$f->foo . \"\\n\";\\$g->foo(\\$f);echo \\$f->foo . \"\\n\";\\$g->bar(\\$f);echo \\$f->foo . \"\\n\";?>If object variables were always references, we'd expect the following output:1421However, we get:14242The reason for this is simple.  In the bar function of the B class, we replace the identifier you passed in, which identified the same instance of the A class as your \\$f variable, with a brand new A class identifier.  Creating a new instance of A doesn't mutate \\$f because \\$f wasn't passed as a reference.To get the reference behavior, one would have to enter the following for class B:<?phpclass B {    public function foo(A \\$bar)    {        \\$bar->foo = 42;    }        public function bar(A &\\$bar)    {        \\$bar = new A;    }}?>The foo function doesn't require a reference, because it is MUTATING an object instance that \\$bar identifies.  But bar will be REPLACING the object instance.  If only an identifier is passed, the variable identifier will be overwritten but the object instance will be left in place. ```\n19\nkristof at viewranger dot com\n8 years ago\n``` I hope this clarifies references a bit more:<?phpclass A {    public \\$foo = 1;}  \\$a = new A;\\$b = \\$a;\\$a->foo = 2;\\$a = NULL;echo \\$b->foo.\"\\n\"; // 2\\$c = new A;\\$d = &\\$c;\\$c->foo = 2;\\$c = NULL;echo \\$d->foo.\"\\n\"; // Notice:  Trying to get property of non-object...?> ```\nwassimamal121 at hotmail dot com\n5 years ago\n``` The example given by PHP manual is pretty clever and simple.The example begins by explaining how things go when two aliases referring to the same objects are changed, just rethink the first part of the example <?phpclass A {    public \\$foo = 1;}  function go(\\$obj) {  \\$obj->foo = 2;}function bo(\\$obj) {\\$obj=new A;}function chan(\\$p){\\$p=44;}function chanref(&\\$p){\\$p=44;} /**************manipulating simple variable******************/\\$h=2;\\$k=\\$h;\\$h=4; echo '\\$k='.\\$k.\"<br/>\";//\\$k refers to a memory cell containing the value 2//\\$k is created and referes to another cell in the RAM//\\$k=\\$h implies take the content of the cell to which \\$h refers //and put it in the cell to which \\$k refers to//\\$h=4 implies change the content of the cell to which \\$h refers to//dosn't imply changing the content of the cell to which \\$k refers to \\$h=2;\\$k=&\\$h;\\$h=4; echo '\\$k='.\\$k.\"<br/>\";//here \\$k refers to the same memory cell as \\$h \\$v=2;chan(\\$v); echo '\\$v='.\\$v.\"<br/>\";//the value of \\$v doesn't change because the function takes // as argument an alias  refering to a value 2, in the function we //change only the value to which this alias refers to\\$u=2;chanref(\\$u); echo '\\$u='.\\$u.\"<br/>\";//here the value changes because we pass a adress of the //memory cell to which \\$u refers to, the function is manipulating//the content of this memory cell /***************manipaliting objects************************/\\$a = new A;//create an object by allocating some cells in memory, \\$a refers //to this cells\\$b = \\$a; //\\$b refers to the same cells, it's not like simple variables//which are created then, we copy the content\\$b->foo = 2;echo \\$a->foo.\"<br/>\";//you can access the same object using both \\$a or \\$b \\$c = new A;\\$d = &\\$c;\\$d->foo = 2;echo \\$c->foo.\"<br/>\";//\\$d and \\$c don't just refers to the same memory space, //but they are the same \\$e = new A;go(\\$e);//we pass a copy of a pointer echo \\$e->foo.\"<br/>\";bo(\\$e);echo \\$e->foo.\"<br/>\";//if you think it's 1 sorry I failed to explain//remember you passed just a pointer, when new is called//the pointer is discoupled  ?> ```\ngevorgmelkoumyan at gmail dot com\n1 year ago\n``` I think this example should clarify the difference between PHP references (aliases) and pointers:<?phpclass A {    public \\$var = 42;}\\$a = new A; // \\$a points to the object with id=1echo 'A: ' . \\$a->var . PHP_EOL; // A: 42 \\$b = \\$a; // \\$b points to the object with id=1echo 'B: ' . \\$b->var . PHP_EOL; // B: 42\\$b->var = 5;echo 'B: ' . \\$b->var . PHP_EOL; // B: 5echo 'A: ' . \\$a->var . PHP_EOL; // A: 5\\$b = new A; // now \\$b points to the object with id=2, but \\$a still points to the 1st object echo 'B: ' . \\$b->var . PHP_EOL; // B: 42echo 'A: ' . \\$a->var . PHP_EOL; // A: 5?> ```\n10\nmjung at poczta dot onet dot pl\n11 years ago\n``` Ultimate explanation to object references:NOTE: wording 'points to' could be easily replaced with 'refers ' and is used loosly.<?php\\$a1 = new A(1);  // \\$a1 == handle1-1 to A(1)\\$a2 = \\$a1;     // \\$a2 == handle1-2 to A(1) - assigned by value (copy)\\$a3 = &\\$a1;  // \\$a3 points to \\$a1 (handle1-1)\\$a3 = null;      // makes \\$a1==null, \\$a3 (still) points to \\$a1, \\$a2 == handle1-2 (same object instance A(1))\\$a2 = null;      // makes \\$a2 == null\\$a1 = new A(2); //makes \\$a1 == handle2-1 to new object and \\$a3 (still) points to \\$a1 => handle2-1 (new object), so value of \\$a1 and \\$a3 is the new object and \\$a2 == null//By reference:\\$a4 = &new A(4);  //\\$a4 points to handle4-1 to A(4)\\$a5 = \\$a4;   // \\$a5 == handle4-2 to A(4) (copy)\\$a6 = &\\$a4;  //\\$a6 points to (handle4-1), not to \\$a4 (reference to reference references the referenced object handle4-1 not the reference itself)\\$a4 = &new A(40); // \\$a4 points to handle40-1, \\$a5 == handle4-2 and \\$a6 still points to handle4-1 to A(4)\\$a6 = null;  // sets handle4-1 to null; \\$a5 == handle4-2 = A(4); \\$a4 points to handle40-1; \\$a6 points to null\\$a6 =&\\$a4; // \\$a6 points to handle40-1\\$a7 = &\\$a6; //\\$a7 points to handle40-1\\$a8 = &\\$a7; //\\$a8 points to handle40-1\\$a5 = \\$a7;  //\\$a5 == handle40-2 (copy)\\$a6 = null; //makes handle40-1 null, all variables pointing to (hanlde40-1 ==null) are null, except (\\$a5 == handle40-2 = A(40))?>Hope this helps. ```\nIvan Bertona\n12 years ago\n``` A point that in my opinion is not stressed enough in the manual page is that in PHP5, passing an object as an argument of a function call with no use of the & operator means passing BY VALUE an unique identifier for that object (intended as instance of a class), which will be stored in another variable that has function scope.This behaviour is the same used in Java, where indeed there is no notion of passing arguments by reference. On the other hand, in PHP you can pass a value by reference (in PHP we refer to references as \"aliases\"), and this poses a threat if you are not aware of what you are really doing. Please consider these two classes:<?phpclass A {    function __toString() {        return \"Class A\";    }}    class B{    function __toString() {        return \"Class B\";    }}?>In the first test case we make two objects out of the classes A and B, then swap the variables using a temp one and the normal assignment operator (=).<?php\\$a = new A();\\$b = new B();    \\$temp = \\$a;\\$a = \\$b;\\$b = \\$temp;    print('\\$a: ' . \\$a . \"\\n\");print('\\$b: ' . \\$b . \"\\n\");?>As expected the script will output:\\$a: Class B\\$b: Class ANow consider the following snippet. It is similar to the former but the assignment \\$a = &\\$b makes \\$a an ALIAS of \\$b.<?php\\$a = new A();\\$b = new B();    \\$temp = \\$a;\\$a = &\\$b;\\$b = \\$temp;    print('\\$a: ' . \\$a . \"\\n\");print('\\$b: ' . \\$b . \"\\n\");?>This script will output:\\$a: Class A\\$b: Class AThat is, modifying \\$b reflects the same assignment on \\$a... The two variables end pointing to the same object, and the other one is lost. To sum up is a good practice NOT using aliasing when handling PHP5 objects, unless your are really really sure of what you are doing. ```\nHayley Watson\n10 years ago\n``` Using &\\$this can result in some weird and counter-intuitive behaviour - it starts lying to you.<?phpclass Bar{    public \\$prop = 42;}class Foo{    public \\$prop = 17;    function boom()    {        \\$bar = &\\$this;        echo \"\\\\$bar is an alias of \\\\$this, a Foo.\\n\";        echo '\\$this is a ', get_class(\\$this), '; \\$bar is a ', get_class(\\$bar), \"\\n\";        echo \"Are they the same object? \", (\\$bar === \\$this ? \"Yes\\n\" : \"No\\n\");        echo \"Are they equal? \", (\\$bar === \\$this ? \"Yes\\n\" : \"No\\n\");        echo '\\$this says its prop value is ';        echo \\$this->prop;        echo ' and \\$bar says it is ';        echo \\$bar->prop;        echo \"\\n\";        echo \"\\n\";        \\$bar = new Bar;        echo \"\\\\$bar has been made into a new Bar.\\n\";        echo '\\$this is a ', get_class(\\$this), '; \\$bar is a ', get_class(\\$bar), \"\\n\";        echo \"Are they the same object? \", (\\$bar === \\$this ? \"Yes\\n\" : \"No\\n\");        echo \"Are they equal? \", (\\$bar === \\$this ? \"Yes\\n\" : \"No\\n\");        echo '\\$this says its prop value is ';        echo \\$this->prop;        echo ' and \\$bar says it is ';        echo \\$bar->prop;        echo \"\\n\";    }}\\$t = new Foo;\\$t->boom();?>In the above \\$this claims to be a Bar (in fact it claims to be the very same object that \\$bar is), while still having all the properties and methods of a Foo.Fortunately it doesn't persist beyond the method where you committed the faux pas.<?phpecho get_class(\\$t), \"\\t\", \\$t->prop;?> ```\nwbcarts at juno dot com\n12 years ago\n``` A BIT DILUTED... but it's alright!In the PHP example above, the function foo(\\$obj), will actually create a \\$foo property to \"any object\" passed to it - which brings some confusion to me:  \\$obj = new stdClass();  foo(\\$obj);    // tags on a \\$foo property to the object                // why is this method here?Furthermore, in OOP, it is not a good idea for \"global functions\" to operate on an object's properties... and it is not a good idea for your class objects to let them. To illustrate the point, the example should be:<?phpclass A {  protected \\$foo = 1;  public function getFoo() {    return \\$this->foo;  }  public function setFoo(\\$val) {    if(\\$val > 0 && \\$val < 10) {      \\$this->foo = \\$val;    }  }  public function __toString() {    return \"A [foo=\\$this->foo]\";  }}\\$a = new A();\\$b = \\$a;                        // \\$a and \\$b are copies of the same identifier                                // (\\$a) = (\\$b) = <id>\\$b->setFoo(2);echo \\$a->getFoo() . '<br>';\\$c = new A();\\$d = &\\$c;                       // \\$c and \\$d are references                                // (\\$c,\\$d) = <id>\\$d->setFoo(2);echo \\$c . '<br>';\\$e = new A();\\$e->setFoo(16);                 // will be ignoredecho \\$e;?> - - - 2 A [foo=2] A [foo=1] - - -Because the global function foo() has been deleted, class A is more defined, robust and will handle all foo operations... and only for objects of type A. I can now take it for granted and see clearly that your are talking about \"A\" objects and their references. But it still reminds me too much of cloning and object comparisons, which to me borders on machine-like programming and not object-oriented programming, which is a totally different way to think. ```\nAnonymous\n8 years ago\n``` this example could help:<?phpclass A {    public \\$testA = 1;}  class B {    public \\$testB = \"class B\";}  \\$a = new A;\\$b = \\$a;     \\$b->testA = 2;\\$c = new B;\\$a = \\$c;\\$a->testB = \"Changed Class B\";echo \"<br/> object a: \"; var_dump(\\$a);echo \"<br/> object b: \"; var_dump(\\$b);echo \"<br/> object c: \"; var_dump(\\$c);// by reference \\$aa = new A;\\$bb = &\\$aa;     \\$bb->testA = 2;\\$cc = new B;\\$aa = \\$cc;\\$aa->testB = \"Changed Class B\";echo \"<br/> object aa: \"; var_dump(\\$aa);echo \"<br/> object bb: \"; var_dump(\\$bb);echo \"<br/> object cc: \"; var_dump(\\$cc);?> ```\nJon Whitener\n8 years ago\n``` The use of clone may get you the behavior you expect when passing an object to a function, as shown below using DateTime objects as examples.<?phpdate_default_timezone_set( \"America/Detroit\" );\\$a = new DateTime;echo \"a = \" . \\$a->format('Y-m-j') . \"\\n\";// This might not give what you expect...\\$b = upDate( \\$a ); // a and b both updatedecho \"a = \" . \\$a->format('Y-m-j') . \", b = \" . \\$b->format('Y-m-j') . \"\\n\";\\$a->modify( \"+ 1 day\" ); // a and b both modifiedecho \"a = \" . \\$a->format('Y-m-j') . \", b = \" . \\$b->format('Y-m-j') . \"\\n\"; // This might be what you want...\\$c = upDateClone( \\$a ); // only c updated, a left aloneecho \"a = \" . \\$a->format('Y-m-j') . \", c = \" . \\$c->format('Y-m-j') . \"\\n\";function upDate( \\$datetime ) {    \\$datetime->modify( \"+ 1 day\" );    return \\$datetime;}function upDateClone( \\$datetime ) {    \\$dt = clone \\$datetime;    \\$dt->modify( \"+ 1 day\" );    return \\$dt;}?>The above would output something like:a = 2012-08-15a = 2012-08-16, b = 2012-08-16a = 2012-08-17, b = 2012-08-17a = 2012-08-17, c = 2012-08-18 ```\nrnealxp at yahoo dot com\n5 months ago\n``` Concise reminders of the behaviors of object assignments, with and without using the \"&\" operator...<?phpclass clsA{    public \\$propA = 2;}class clsB{    public \\$propB = 3;}//------------\\$a = new clsA();\\$c = \\$a; //Both of these vars now refer to the same object-instance (an assignment-by-reference).\\$c->propA = 22; //Use one of the vars to change the instance's property.echo \\$c->propA . \"\\n\"; //output: 22echo \\$a->propA . \"\\n\"; //output: 22//------------\\$b = new clsB();\\$a = \\$b; //Before this assignment, both \\$c and \\$a referred to the same object instance; this is no longer the case after \\$a is switched to reference the instance of clsB.echo \\$c->propA . \"\\n\"; //output: 22 (this works because \\$c is still a reference to the object instance of type clsA)echo \\$c->propB . \"\\n\"; //output: \"Undefined property: clsA::\\$propB\" (did not work because \\$c is not a reference to the object instance of type clsB)//------------//Start over and use the \"&\" operator...\\$a = new clsA();\\$b = new clsB();\\$c = &\\$a; //<--\\$c will refer to whatever \\$a currently and \"futuristically\" refers to (also a type of assignment-by-reference); in C-language, you would think of this as copying a pointer.echo \\$c->propA . \"\\n\"; //output: 2\\$a = \\$b; //This assignment causes \\$c to refer to a new/different object.echo \\$c->propA . \"\\n\"; //output: \"Undefined property: clsB::\\$propA\" (does not work since \\$c no longer refers to the object instance of type clsA)echo \\$c->propB . \"\\n\"; //output: 3 (works since \\$c now refers to the object instance of type clsB)//------------?> ```\nJoe F\n1 year ago\n``` I am planning to serialize and unserialize objects as a means of storage, and my application can conveniently group large numbers of objects inside of a single object to serialize. However, this presented some questions that I needed to answer:Let's say the parent object I plan to serialize is \"A\" and the objects I store in it will be A(a-z). If I pass A(b) to A(c), this happens by reference. So if A(c) takes actions that effect the values of A(b), this will also update the original A(b) stored in A. Great!However, what happens when I serialize A, where A(c) has a reference to A(b), and then I unserialize? Will A(c) have a new unique copy of A(b), or will it still reference the A(b) stored in A?The answer is, PHP 5.5 and PHP 7 both track whether something is a reference to an object it's already \"recreated\" during the unserialize process, see this example:<?phpclass foo {    protected \\$stored_object;    protected \\$stored_object2;    protected \\$stored_value;        public function __construct(\\$name, \\$stored_value) {        \\$this->store_value(\\$stored_value);        echo 'Constructed: '.\\$name.' => '.\\$stored_value.'<br/>';    }        public function store_object(foo \\$object) {        \\$this->stored_object = \\$object;    }        public function store_object2(foo \\$object) {        \\$this->stored_object2 = \\$object;    }        public function store_value(\\$value) {        \\$this->stored_value = \\$value;    }        public function stored_method(\\$method, array \\$parameters) {        echo 'Call stored method: '.\\$method.'{ <br/>';        call_user_func_array(array(\\$this->stored_object, \\$method), \\$parameters);        echo '} <br/>';    }        public function stored_method2(\\$method, array \\$parameters) {        echo 'Call stored method 2: '.\\$method.'{ <br/>';        call_user_func_array(array(\\$this->stored_object2, \\$method), \\$parameters);        echo '} <br/>';    }        public function echo_value() {        echo 'Value: '.\\$this->stored_value.'<br/>';    }}\\$foo = new foo('foo', 'Hello!'); // Constructed: foo => Hello!\\$new_foo = new foo('new_foo', 'New Foo 2!'); // Constructed: new_foo => New Foo 2!\\$third_foo = new foo('third_foo', 'Final Foo!'); // Constructed: third_foo => Final Foo!\\$foo->store_object(\\$new_foo); \\$foo->store_object2(\\$third_foo);\\$foo->stored_method('store_object', array(\\$third_foo)); //Call stored method: store_object{ }\\$serialized = serialize(\\$foo);unset(\\$foo);unset(\\$new_foo);unset(\\$third_foo);\\$unserialized_foo = unserialize(\\$serialized);//Below, I update the object represented as A(c) but I update it via the A object\\$unserialized_foo->stored_method2('store_value', array('Super Last Foo!')); // Call stored method 2: store_value{}\\$unserialized_foo->echo_value(); // Value: Hello!\\$unserialized_foo->stored_method('echo_value', array());//Call stored method: echo_value{ //Value: New Foo 2!//}// Last, I check the value of A(c) as it was stored in A(b) to see if updating A(c) via A also updates A(b)'s copy/reference:\\$unserialized_foo->stored_method('stored_method', array('echo_value', array()));//Call stored method: stored_method{ //Call stored method: echo_value{ //Value: Super Last Foo!//}//}?>Per the last line, A(b)'s \"copy\" of A(c) is still a reference to the original A(b) as stored in A, even after unserializing. ```\n-1\ncesoid at gmail dot com\n7 years ago\n``` Comparing an alias to a pointer is like comparing a spoken word to the neurochemistry of the speaker. You know that the speaker can use two different words to refer to the same thing, but what's going on in their brain to make this work is something you don't want to have to think about every time they speak. (If you're programming in assembly or, less so, in C++, you're out of luck there.)Likewise, PHP *the language* and a given php interpretor are not the same thing, and this post and most of these comments leave that out in the explanation. An alias/reference is a part of the language, a pointer is a part of how the computer makes the reference work. You often have little guarantee that an interpreter will continue working the same way internally.From a functional point of view the internals of the interpreter *do* matter for optimization, but *don't* matter in terms of the end result of the program. A higher level programming language such as PHP is supposed to try to hide such details from the programmer so that they can write clearer, more manageable code, and do it quickly.Unfortunately, years ago, using pass-by-reference a lot actually was very useful in terms of optimizing. Fortunately, that ended years ago, so now we no longer need to perform a reference assignment and hope that we remember not to change one variable when the other one is supposed to stay the same. By the time you read this the php that is sending these words to you may be running on a server that uses some kind of new exotic technology for which the word \"pointer\" no longer accurately describes anything, because the server stores both the program state and instructions intermingled in non-sequential atoms bonded into molecules which work by randomly bouncing off each other at high speeds, thereby exchanging atoms and crossbreeding their instructions and information in such a way as to, in aggregate, successfully run php 5 code. But the code itself will still have references that work the same way they did before, and you will therefore not have to think about whether the machine I just described makes any sense at all. ```\n-4\nRob Marscher\n9 years ago\n``` Here's an example I created that helped me understand the difference between passing objects by reference and by value in php 5.<?phpclass A {    public \\$foo = 'empty';}class B {    public \\$foo = 'empty';    public \\$bar = 'hello';}function normalAssignment(\\$obj) {    \\$obj->foo = 'changed';    \\$obj = new B;}function referenceAssignment(&\\$obj) {    \\$obj->foo = 'changed';    \\$obj = new B;}\\$a = new A;normalAssignment(\\$a);echo get_class(\\$a), \"\\n\";echo \"foo = {\\$a->foo}\\n\";referenceAssignment(\\$a);echo get_class(\\$a), \"\\n\";echo \"foo = {\\$a->foo}\\n\";echo \"bar = {\\$a->bar}\\n\";/*prints:Afoo = changedBfoo = emptybar = hello*/?> ```\n-5\nlazybones_senior\n12 years ago\n``` WHOA... KEEP IT SIMPLE!In regards to secure_admin's note: You've used OOP to simplify PHP's ability to create and use object references. Now use PHP's static keyword to simplify your OOP.<?phpclass DataModelControl {  protected static \\$data = 256; // default value;   protected \\$name;  public function __construct(\\$dmcName) {    \\$this->name = \\$dmcName;  }  public static function setData(\\$dmcData) {    if(is_numeric(\\$dmcData)) {      self::\\$data = \\$dmcData;    }  }  public function __toString() {    return \"DataModelControl [name=\\$this->name, data=\" . self::\\$data . \"]\";  }   }# create several instances of DataModelControl...\\$dmc1 = new DataModelControl('dmc1');\\$dmc2 = new DataModelControl('dmc2');\\$dmc3 = new DataModelControl('dmc3');echo \\$dmc1 . '<br>';echo \\$dmc2 . '<br>';echo \\$dmc3 . '<br><br>';# To change data, use any DataModelControl object...\\$dmc2->setData(512);# Or, call setData() directly from the class...DataModelControl::setData(1024);echo \\$dmc1 . '<br>';echo \\$dmc2 . '<br>';echo \\$dmc3 . '<br><br>';?> DataModelControl [name=dmc1, data=256] DataModelControl [name=dmc2, data=256] DataModelControl [name=dmc3, data=256] DataModelControl [name=dmc1, data=1024] DataModelControl [name=dmc2, data=1024] DataModelControl [name=dmc3, data=1024]... even better! Now, PHP creates one copy of \\$data, that is shared amongst all DataModelControl objects. ```\n-7\nakam at akameng dot com\n7 years ago\n``` Object is being referenced even after the original object deleted, so be careful when copying objects into your array. <?php\\$result = json_decode(' {\"1\":1377809496,\"2\":1377813096}');\\$copy1['object'] = \\$result;\\$copy2['object'] = \\$result;unset(\\$result);//now lets change \\$copy1['object'] to 'test';\\$copy1['object']->{\"1\"} = 'test';echo (\\$copy1 === \\$copy2) ? \"Yes\" : \"No\";print_r(\\$copy2);/*Array(    [API] => stdClass Object        (            => test            => 1377813096        ))*/?> ```", null, "" ]
[ null, "https://www.php.net/images/[email protected]", null, "https://www.php.net/images/[email protected]", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5459398,"math_prob":0.8496873,"size":2567,"snap":"2020-45-2020-50","text_gpt3_token_len":661,"char_repetition_ratio":0.1779165,"word_repetition_ratio":0.044444446,"special_character_ratio":0.29139072,"punctuation_ratio":0.1904762,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.963007,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-31T23:02:49Z\",\"WARC-Record-ID\":\"<urn:uuid:bf03d9de-de3c-47ac-8489-972764e8fc45>\",\"Content-Length\":\"130092\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ca6d2a19-9c5b-4792-8c7e-60162afb420b>\",\"WARC-Concurrent-To\":\"<urn:uuid:e65c540b-9b16-41ea-9850-6325f80baae6>\",\"WARC-IP-Address\":\"185.85.0.29\",\"WARC-Target-URI\":\"https://www.php.net/manual/pt_BR/language.oop5.references.php\",\"WARC-Payload-Digest\":\"sha1:M6UWSE7J2RN7IZMEU2AWU6HNK7OHFWBP\",\"WARC-Block-Digest\":\"sha1:OTZ4FMZYZJPX6RYSG2UJ4VEZB3NK3XNK\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107922463.87_warc_CC-MAIN-20201031211812-20201101001812-00419.warc.gz\"}"}
https://www.gradesaver.com/textbooks/math/algebra/algebra-2-1st-edition/chapter-4-quadratic-functions-and-factoring-4-2-graph-quadratic-function-in-vertex-or-intercept-form-4-2-exercises-skill-practice-page-249/26
[ "Algebra 2 (1st Edition)\n\n$$h(x) =4x^2 -20x-24$$\nWe are asked to put this equation in standard form. Thus, we first use the FOIL method. Next, we simplify until the equation is put in the form $y=ax^2+bx+c$. Doing this, we obtain: $$h(x) =4(x^2 -6x+x-6) \\\\ h(x)=4(x^2-5x-6) \\\\ h(x) =4x^2 -20x-24$$" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.827032,"math_prob":1.0000037,"size":297,"snap":"2019-43-2019-47","text_gpt3_token_len":116,"char_repetition_ratio":0.12627986,"word_repetition_ratio":0.0,"special_character_ratio":0.42087543,"punctuation_ratio":0.09210526,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":1.0000081,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-17T13:32:40Z\",\"WARC-Record-ID\":\"<urn:uuid:a27a981b-1143-4510-882b-102c710a71b9>\",\"Content-Length\":\"133255\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6f5bc42d-1097-43cd-9024-072683c9e206>\",\"WARC-Concurrent-To\":\"<urn:uuid:a2ab5e31-48e0-4118-b7f4-1f599b7ddf78>\",\"WARC-IP-Address\":\"3.90.134.5\",\"WARC-Target-URI\":\"https://www.gradesaver.com/textbooks/math/algebra/algebra-2-1st-edition/chapter-4-quadratic-functions-and-factoring-4-2-graph-quadratic-function-in-vertex-or-intercept-form-4-2-exercises-skill-practice-page-249/26\",\"WARC-Payload-Digest\":\"sha1:AY7UODWHPICUPS7RDINMUL6DRUQ6DEKQ\",\"WARC-Block-Digest\":\"sha1:YBCZHABTCLZNG3VFQ2U3JSJA2OGF4GUX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986675316.51_warc_CC-MAIN-20191017122657-20191017150157-00491.warc.gz\"}"}
https://socratic.org/questions/the-height-in-feet-of-a-golf-ball-hit-into-the-air-is-given-by-h-16t-2-64t-where-3
[ "# The height in feet of a golf ball hit into the air is given by h= -16t^2 + 64t, where t is the number of seconds elapsed since the ball was hit. For how many seconds is the ball more than 48 feet up in the air?\n\nAug 2, 2016\n\nBall is above 48 feet when $t \\in \\left(1 , 3\\right)$ so for as near as makes no difference ball will spend 2 seconds above 48feet.\n\n#### Explanation:\n\nWe have an expression for $h \\left(t\\right)$ so we set up an inequality:\n\n$48 < - 16 {t}^{2} + 64 t$\n\nSubtract 48 from both sides:\n\n$0 < - 16 {t}^{2} + 64 t - 48$\n\nDivide both sides by 16:\n\n$0 < - {t}^{2} + 4 t - 3$\n\nThis is a quadratic function and as such will have 2 roots, ie times where the function is equal to zero. This means that the time spent above zero, ie the time above $48 f t$ will be the time in between the roots, so we solve:\n\n$- {t}^{2} + 4 t - 3 = 0$\n\n$\\left(- t + 1\\right) \\left(t - 3\\right) = 0$\n\nFor left hand side to be equal to zero, one of the terms in brackets must equal zero, so:\n\n$- t + 1 = 0 \\mathmr{and} t - 3 = 0$\n\n$t = 1 \\mathmr{and} t = 3$\n\nWe conclude that the golf ball is above 48 feet if $1 < t < 3$" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.89773273,"math_prob":0.9999882,"size":788,"snap":"2020-24-2020-29","text_gpt3_token_len":200,"char_repetition_ratio":0.113520406,"word_repetition_ratio":0.0,"special_character_ratio":0.2538071,"punctuation_ratio":0.07647059,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999746,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-12T06:33:28Z\",\"WARC-Record-ID\":\"<urn:uuid:1ef5a8d7-51b1-4c9a-9ae7-17b4a1ae6088>\",\"Content-Length\":\"35485\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4f61c883-272e-4579-b852-f06df69c2442>\",\"WARC-Concurrent-To\":\"<urn:uuid:c9460277-a551-4a46-8a37-1006f0f0d2da>\",\"WARC-IP-Address\":\"216.239.32.21\",\"WARC-Target-URI\":\"https://socratic.org/questions/the-height-in-feet-of-a-golf-ball-hit-into-the-air-is-given-by-h-16t-2-64t-where-3\",\"WARC-Payload-Digest\":\"sha1:PJUHRA76PVA3I37VA6BIOZS5UW34DK2W\",\"WARC-Block-Digest\":\"sha1:75NVJD5Z7ACCKWGC5NPVO4INNIXNZ6EJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593657131734.89_warc_CC-MAIN-20200712051058-20200712081058-00490.warc.gz\"}"}
https://www.kseebsolutions.com/kseeb-solutions-for-class-8-maths-chapter-6-additional-questions/
[ "# KSEEB Solutions for Class 8 Maths Chapter 6 Theorems on Triangles Additional Questions\n\nStudents can Download Maths Chapter 6 Theorems on Triangles Additional Questions and Answers, Notes Pdf, KSEEB Solutions for Class 8 Maths helps you to revise the complete Karnataka State Board Syllabus and score more marks in your examinations.\n\n## Karnataka State Syllabus Class 8 Maths Chapter 6 Theorems on Triangles Additional Questions\n\nQuestion 1.\nFill up the blanks to make the following statements true\na. Sum of the angles of a triangle in 180°\nb. An exterior angle of a triangle is equal to the sum of interior opposite angles.\nc. An exteior angle of a triangle is always more than either of the interior opposite angles.\nd. A triangle can not have more than one right angles.\ne. A triangle can not have more than one obtuse angle.", null, "Question 2.\nChoose the correct answer from the given alternatives.\na. In a triangle ABC, ∠A = 80° and AB = BAC then ∠B is __________\nA. 50°\nB. 60°\nC. 40°\nD. 70°\nSolution:\nA. 50°\n\nb. In right-angled triangle, ∠A is right angle and ∠B = 35° then ∠C is _______\nA. 65°\nB. 55°\nC. 75°\nD. 45°\nSolution:\nB. 55°\n\nc. In ∆ABC, ∠B = ∠C = 45°, then the triangle is ________\nA. Right-angled\nB. Acute angled\nC. Obtuse angled\nD. Equilateral triangle\nSolution:\nA. Right-angled\n\nd. In an equilateral triangle, each exterior angle is ________\nA. 60°\nB. 90°\nC. 120°\nD. 150°\nSolution:\nC. 120°\n\ne. Sum of the three exterior angles of a triangle is __________\nA. two right angles\nB. three right angles\nC. one right angle\nD. four right angles\nSolution:\nD. Four right angles", null, "Question 3.\nIn a triangle ABC, ∠B = 70° find ∠A + ∠C\nSolution:\n∠A + ∠B + ∠C = 180° [Sum of the angles of a triangle is 180°]\n∠A + 70 + ∠C = 180°\n∠A + ∠C = 180° – 70\n∠A + ∠C = 110°\n\nQuestion 4.\nIn a triangle ABC, ∠A =110° and AB = AC find ∠B and ∠C\nSolution:\nAB = AC\n∴ ∠C = ∠B [Base angles of an isosceles triangle]\n∠A + ∠B + ∠C = 180° [Sum of the angles of a triangle is 180°]\n110° + ∠B + ∠B = 180°\n2∠B = 180 – 110\n2∠B = 70°\n∠B = $$\\frac{70}{2}$$\n∠B = 35°\n∠B = ∠C = 35°", null, "Question 5.\nIf three angles of a triangle are in the ratio 2 : 3 : 5 determine three angles.\nSolution:\nLet the common ratio be x The three angles are 2x, 3x and 5x 2x + 3x + 5x = 180° [Sum of the angles of triangle is 180°]\n10x = 180°\nx = $$\\frac{180}{10}$$\n2x = 2 ×18 = 36°\n3x = 3 × 18 = 54°\n5x = 5 × 18 = 90°\n\nQuestion 6.\nThe angles of a triangle are arranged in ascending order of magnitude. If the difference between consecuttive angles is 15° find the three angles.\nSolution:\nLet the first angle be x then the second angle is x + 15 and third angle is x + 30.\nx + x + 15 + x + 30 = 180° [Sum of the angles]\n3x + 45 = 180\n3x = 180 – 45\n3x = 135\nx = $$\\frac{135}{3}$$ = 45°\nFirst angle = x = 45°\nSecond angle = x + 15 = 45 + 15 = 60°\nThird angle = x + 30 = 45 + 30 = 75°\n\nQuestion 7.\nThe sum of two angles of a triangle is equal to its third angle. Determine the measure of third angle.\nSolution:\nLet the sum of two angles be x and the third angle be y\nx + y = 180° [Sum of the angles of the triangle]\ny + y = 180° [∴ sum of two angles = third angle]\n2y = 180°\ny = $$\\frac{180}{2}$$\ny = 90°\n∴ The third angle is 90°", null, "Question 8.\nIn a triangle ABC if 2∠A = 3∠B = 6∠C determine ∠A , ∠B and ∠C\nSolution:", null, "∠A + ∠B + ∠C = 180° [Sum of the angles of a triangle]", null, "", null, "Question 9.\nThe angles of a triangle are x – 40°, x – 20 and $$\\frac{1}{2}$$ x + 15° find the value of x\nSolution:\nx – 40 + x – 20 + $$\\frac{1}{2}$$ x + 15 = 180° [Sum of the angles of a triangle]\nx + x + $$\\frac{1}{2}$$ x – 60 + 15 = 1 80°\nx + x + $$\\frac{1}{2}$$ x – 45 = 180°\n2x + $$\\frac{1}{2}$$ x = 180 + 45\n$$\\frac{4 x+x}{2}$$ = 225\n5x = 225 x 2\n5x = 450\nx = $$\\frac{450}{5}$$\nx = 90°", null, "Question 10.\nIn ∆ABC ∠A – ∠B = 15° and ∠B – ∠C = 30° find ∆ABC ∠A , ∠B and ∠C\nSolution:\n∠A – ∠B = 15°\n∴ ∠A = 15 + ∠B\n∠B – ∠C = 30\n∴ ∠B = 30 + ∠C\n∠A + ∠B + ∠C = 180° [Sum of the angle of a triangle]\n15 + ∠B + ∠B + ∠C = 180° (∴ ∠A = 15 + ∠B)\n15 + 2∠B + ∠C = 180°\n15 + 2[30 + ∠C + ∠C = 180° (∴ ∠B = 30 + ∠C)\n15 + 60 + 2∠C] + ∠C = 180°\n75 + 3∠C = 180°\n3∠C = 180 – 75\n3∠C = 105°\n∠C = $$\\frac{105^{\\circ}}{3}$$\n∠C = 35°\nNow ∠B = 30 + ∠C\n∠B = 30 + 35\n∠B = 65°\n∠A = 15 + ∠B\n∠A = 15 + 65\n∠A = 180°", null, "Question 11.\nThe sum of two angles of a triangle 80° and their difference is 20° find the angles of the triangle.\nSolution:\nLet the angles be x and y", null, "x = $$\\frac{100}{2}$$ ; x = 50°\nx + y = 80°\n50 + y = 80°\ny = 80 – 50\ny = 30°\nLet the third angle be z\nx + y + z = 180° [Sum of the angles]\n50 + 30 + z = 180°\n80 + z = 180°\nz = 180 – 80\nz = 100°\n\nQuestion 12.\nIn a triangle ABC, ∠B = 60°, ∠C = 80°. Suppose the bisectors of ∠B and ∠C meet at L find ∠BLC.\nSolution:", null, "BL bisects ∠B", null, "∠LBC + ∠BLC + ∠LCB = 180° (Sum of the angles of a triangle)\n30 + ∠BLC + 40° = 180°\n70 + ∠BLC = 180°\n∠BLC = 180 – 70\n∠BLC = 110°", null, "Question 13.\nIn a triangle, each of the smaller angles is half of the largest angle. Find the angles.\nSolution:\nLet the smallest angle be x then the largest angle is 2x.\nx + x + 2x = 180° [Sum of the angles of triangle]\n4x = 180°\nx = $$\\frac{180}{4}$$\nx = 45°\n2x = 2 × 45° = 90°\n∴ The angles are 45°, 45° and 90°\n\nQuestion 14.\nIn a triangle each of the bigger angle is twice the third angle find the angles.\nSolution:\nLet the third angle be x. then the bigger angles is 2x 2x + 2x + x = 180° [Sum of the angles of triangle]\n5x = 180°\nx = $$\\frac{180}{5}$$\nx = 36°\n2x = 2 × 36° = 72°\n∴ The angles are 72°, 72° and 36°\n\nQuestion 15.\nIn a triangle ABC, ∠B = 50° and ∠A = 60°. Suppose BC is extended D. Find ∠ACD\nSolution\n∠ACD = ∠ ABC + ∠BAC [Exterior angle = sum of interior opposite angles]", null, "∠ACD = 50 + 60\n∠ACD = 110°\n\nQuestion 16.\nIn an isosceles triangle, the vertex angle is twice the sum of the base angles. Find the angles of the triangle.\nSolution:", null, "In ∆ABC, AB = BC\n∴ ∠B = ∠C\n∠Base angles of an isosceles triangle]\nGiven ∠A = 2(∠B + ∠C)\n∠A +∠B + ∠C = 180°\n[Sum of the angles of a triangle]\n2(∠B + ∠C) + ∠B + ∠C = 180°\n[Substituted for ∠A ]\n2∠B + 2∠C + ∠B + ∠C = 180°\n2∠B + 2∠B + ∠B + ∠B = 180° [∴ ∠B = ∠C]\n6∠B = 180° ∠B = $$\\frac{180}{6}$$ = 30°\n∠B = 30°, ∠C = 30° and ∠A = 2(∠B + ∠C)\n= 2 (30 + 30) = 2 (60) = 120°", null, "Question 17.\nFind the sum of all the angles at the five vertices of the adjoining star.", null, "Solution:\nSince all the sides of the star are equal to each other the Afes AGL, CDB, EFD, GHF and KHL are isosceles triangles. Let each base angle equal to ‘x’.\nIn the figure, BDFHL is a pentagon & its sides are extended in order. ∴ The sum of exterior angles = 360°\n∠DBC + ∠FDE + ∠GFH + ∠KHL + ∠BLA = 360°\nx + x + x + x + x = 360°\n5x = 360°\nx = $$\\frac{360^{\\circ}}{5}$$ = 72°\nIn ∆ABL,\n∠A + ∠ABL + ∠ALB = 180°\n∠A + x + x = 180°\n∠A + 72 + 72 = 180°\n∠A + 144 = 180°\n∠A = 180° – 144 ∠A = 36°\n∠C, ∠E, ∠G and ∠K = 36°\n∴ Sum of all the angles at the five vertices = 36° × 5 = 180°", null, "" ]
[ null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null, "https://live.staticflickr.com/65535/50067055448_1fb3a1b236_o.png", null, "https://live.staticflickr.com/65535/50067608251_356cc8f964_o.png", null, "https://live.staticflickr.com/65535/50067867897_1163b52931_o.png", null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null, "https://live.staticflickr.com/65535/50067608116_7d385bc9b1_o.png", null, "https://live.staticflickr.com/65535/50067867842_79588bdde8_o.png", null, "https://live.staticflickr.com/65535/50067867802_c514140788_o.png", null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null, "https://live.staticflickr.com/65535/50067608011_3f4321a5c8_o.png", null, "https://live.staticflickr.com/65535/50067055063_86ed50d815_o.png", null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null, "https://live.staticflickr.com/65535/50067607936_2b495ca8dd_o.png", null, "https://www.kseebsolutions.com/wp-content/uploads/2019/11/KSEEB-Solutions.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.766086,"math_prob":1.0000049,"size":6671,"snap":"2020-45-2020-50","text_gpt3_token_len":2842,"char_repetition_ratio":0.23533823,"word_repetition_ratio":0.118140735,"special_character_ratio":0.4491081,"punctuation_ratio":0.09109875,"nsfw_num_words":1,"has_unicode_error":false,"math_prob_llama3":1.0000049,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,1,null,1,null,1,null,null,null,null,null,1,null,1,null,1,null,null,null,1,null,1,null,null,null,1,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-25T14:30:08Z\",\"WARC-Record-ID\":\"<urn:uuid:45243ec7-4bad-4303-a4a8-e677183562cc>\",\"Content-Length\":\"54469\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4a7d49f9-c4e5-475f-afde-0b93f43f9400>\",\"WARC-Concurrent-To\":\"<urn:uuid:58fbad84-765c-4add-9ad9-c9b822717942>\",\"WARC-IP-Address\":\"128.199.22.39\",\"WARC-Target-URI\":\"https://www.kseebsolutions.com/kseeb-solutions-for-class-8-maths-chapter-6-additional-questions/\",\"WARC-Payload-Digest\":\"sha1:Z2BVVBWMVXXQOAL7GZWASND4VC6PRPVY\",\"WARC-Block-Digest\":\"sha1:QDIWKNOUY63TTJ7TNYRCTRNQ6LQOR4P5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107889173.38_warc_CC-MAIN-20201025125131-20201025155131-00262.warc.gz\"}"}
https://www.aqua-calc.com/calculate/mass-molar-concentration/substance/sodium-blank-hydrogen-blank-carbonate
[ "# Concentration of Sodium hydrogen carbonate\n\n## sodium hydrogen carbonate: mass and molar concentration\n\n### Molar concentration per milliliter\n\n 0.01 mmol/ml 10 µmol/ml 10 000 nmol/ml 10 000 000 pmol/ml\n\n### Molar concentration per deciliter\n\n 1 mmol/dl 1 000 µmol/dl 1 000 000 nmol/dl 1 000 000 000 pmol/dl\n\n### Molar concentration per liter\n\n 10 mmol/l 10 000 µmol/l 10 000 000 nmol/l 10 000 000 000 pmol/l\n\n### Mass concentration per milliliter\n\n 0 g/ml 0.84 mg/ml 840.07 µg/ml 840 070 ng/ml 840 070 000 pg/ml\n\n### Mass concentration per deciliter\n\n 0.08 g/dl 84.01 mg/dl 84 007 µg/dl 84 007 000 ng/dl 84 007 000 000 pg/dl\n\n### Mass concentration per liter\n\n 0.84 g/l 840.07 mg/l 840 070 µg/l 840 070 000 ng/l 840 070 000 000 pg/l\n\n### Equivalent molar concentration per milliliter\n\n 0.01 meq/ml 10 µeq/ml 10 000 neq/ml 10 000 000 peq/ml\n\n### Equivalent molar concentration per deciliter\n\n 1 meq/dl 1 000 µeq/dl 1 000 000 neq/dl 1 000 000 000 peq/dl\n\n### Equivalent molar concentration per liter\n\n 10 meq/l 10 000 µeq/l 10 000 000 neq/l 10 000 000 000 peq/l\n• The units of  amount of substance (e.g. mole) per milliliter,  liter and deciliter are SI units of measurements of molar concentrations.\n• The units of molar concentration per deciliter:\n• millimole per deciliter [mm/dl],  micromole per deciliter [µm/dl],  nanomole per deciliter [nm/dl]  and  picomole per deciliter [pm/dl].\n• The units of molar concentration per milliliter:\n• millimole per milliliter [mm/ml],  micromole per milliliter [µm/ml],  nanomole per milliliter [nm/ml]  and  picomole per milliliter [pm/ml].\n• The units of molar concentration per liter:\n• millimole per liter [mm/l],  micromole per liter [µm/l],  nanomole per liter [nm/l]  and  picomole per liter [pm/l].\n• The units of  mass  per milliliter,  liter and deciliter are non-SI units of measurements of mass concentrations still used in many countries.\n• The units of mass concentration per deciliter:\n• gram per deciliter [g/dl],  milligram per deciliter [mg/dl],  microgram per deciliter [µg/dl],  nanogram per deciliter [ng/dl]  and  picogram per deciliter [pg/dl].\n• The units of mass concentration per milliliter:\n• gram per milliliter [g/ml],  milligram per milliliter [mg/ml],  microgram per milliliter [µg/ml],  nanogram per milliliter [ng/ml]  and  picogram per milliliter [pg/ml].\n• The units of mass concentration per liter:\n• gram per liter [g/l],  milligram per liter [mg/l],  microgram per liter [µg/l],  nanogram per liter [ng/l]  and  picogram per liter [pg/l].\n• The  equivalent  per milliliter,  liter and deciliter are obsolete, non-SI units of measurements of molar concentrations still used in many countries. An equivalent is the number of moles of an ion in a solution, multiplied by the valence of that ion.\n• The units of equivalent concentration per deciliter:\n• milliequivalent per deciliter [meq/dl],  microequivalent per deciliter [µeq/dl],  nanoequivalent per deciliter [neq/dl]  and  picoequivalent per deciliter [peq/dl].\n• The units of equivalent concentration per milliliter:\n• milliequivalent per milliliter [meq/ml],  microequivalent per milliliter [µeq/ml],  nanoequivalent per milliliter [neq/ml]  and  picoequivalent per milliliter [peq/ml].\n• The units of equivalent concentration per liter:\n• milliequivalent per liter [meq/l],  microequivalent per liter [µeq/l],  nanoequivalent per liter [neq/l]  and  picoequivalent per liter [peq/l].\n\n#### Foods, Nutrients and Calories\n\nFrozen mocha coffee drink weigh(s) 262 grams per metric cup or 8.7 ounces per US cup, and contain(s) 66 calories per 100 grams (≈3.53 ounces)  [ weight to volume | volume to weight | price | density ]\n\n100 foods that contain Tocotrienol, delta.  List of these foods starting with the highest contents of Tocotrienol, delta and the lowest contents of Tocotrienol, delta\n\n#### Gravels, Substances and Oils\n\nSubstrate, Eco-Complete weighs 1 538 kg/m³ (96.0142 lb/ft³) with specific gravity of 1.538 relative to pure water.  Calculate how much of this gravel is required to attain a specific depth in a cylindricalquarter cylindrical  or in a rectangular shaped aquarium or pond  [ weight to volume | volume to weight | price ]\n\nCobaltic oxide [Co2O3] weighs 5 180 kg/m³ (323.37684 lb/ft³)  [ weight to volume | volume to weight | price | mole to volume and weight | mass and molar concentration | density ]\n\nVolume to weightweight to volume and cost conversions for Refrigerant R-502, liquid (R502) with temperature in the range of -51.12°C (-60.016°F) to 60°C (140°F)\n\n#### Weights and Measurements\n\nThe kilogram per US tablespoon density measurement unit is used to measure volume in US tablespoons in order to estimate weight or mass in kilograms\n\nMomentum is a vector quantity of motion of a body that is given by the product of its mass and velocity.\n\nyF to GF conversion table, yF to GF unit converter or convert between all units of capacitance measurement.\n\n#### Calculators\n\nPPI Calculator: Pixels Per Inch, image resolution and pixel density" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.81681347,"math_prob":0.9714017,"size":1550,"snap":"2021-31-2021-39","text_gpt3_token_len":385,"char_repetition_ratio":0.12742561,"word_repetition_ratio":0.07782101,"special_character_ratio":0.25741935,"punctuation_ratio":0.083333336,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9922624,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-27T06:57:20Z\",\"WARC-Record-ID\":\"<urn:uuid:61739fdc-b8de-478a-972f-dd4c433b7c25>\",\"Content-Length\":\"40491\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f6fe1e55-cdb4-4d80-ac82-fe524ca09093>\",\"WARC-Concurrent-To\":\"<urn:uuid:ccbdb0ca-4f7f-4afd-878c-aec0d6943c52>\",\"WARC-IP-Address\":\"69.46.0.75\",\"WARC-Target-URI\":\"https://www.aqua-calc.com/calculate/mass-molar-concentration/substance/sodium-blank-hydrogen-blank-carbonate\",\"WARC-Payload-Digest\":\"sha1:TOQWGOGQDQCZNIY2TGQZEBSL4FMKCYFG\",\"WARC-Block-Digest\":\"sha1:HUMCHMJS35N32MD27FAU64H6WGWH2PZU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780058373.45_warc_CC-MAIN-20210927060117-20210927090117-00086.warc.gz\"}"}
https://bigdata-world.net/python-delete-variable/
[ "# Python Delete Variable\n\n## What is a Variable in Python?\n\nA Python variable is a held memory area to store esteems. As such, a variable in a python program offers data to the PC for preparing.\n\n### Python Variable Types\n\nEvery value in Python has a datatype. Different data types in Python are Numbers, List, Tuple, Strings, Dictionary, etc. Variables in Python can be declared by any name or even alphabets like a, aa, abc, etc.\n\nIn this tutorial, we will learn,\n\n• Instructions to Declare and utilize a Variable\n• Re-proclaim a Variable\n• Neighborhood and Global Variables\n• Erase a variable\n\n## How to Declare and use a Variable\n\nLet see an example. We will define variable in Python and declare it as “a” and print it.\n\n```a=100\nprint (a)```\n\n## Re-declare a Variable\n\nYou can re-proclaim Python factors even after you have announced once\n\nHere we have Python pronounce variable instated to f=0.\n\nAfterward, we re-dole out the variable f to esteem “guru99”", null, "Python 2 Example\n\n```# Declare a variable and initialize it\nf = 0\nprint f\n# re-declaring the variable works\nf = 'guru99'\nprint f```\n\nPython 3 Example\n\n```# Declare a variable and initialize it\nf = 0\nprint(f)\n# re-declaring the variable works\nf = 'guru99'\nprint(f)```\n\n## Python String Concatenation and Variable\n\nWe should see whether you can link distinctive data types like string and number together. For instance, we will connect “Master” with the number “99”.\n\nIn contrast to Java, which links number with string without pronouncing number as string, while at the same time announcing factors in Python requires proclaiming the number as string else it will show a TypeError", null, "For the following code, you will get undefined output –\n\n```a=\"Guru\"\nb = 99\nprint a+b\n```\n\nOnce the integer is declared as string, it can concatenate both “Guru” + str(“99”)= “Guru99” in the output.\n\n```a=\"Guru\"\nb = 99\nprint(a+str(b))```\n\n## Python Variable Types: Local & Global\n\nThere are two kinds of factors in Python, Global variable and Local variable. At the point when you need to utilize a similar variable for rest of your program or module you announce it as a global variable, while on the off chance that you need to utilize the variable in a particular capacity or technique, you utilize a nearby factor while Python variable affirmation.\n\nHow about we comprehend this Python variable sorts with the contrast among nearby and global factors in the underneath program.\n\n1. Allow us to characterize variable in Python where the variable “f” is global in scope and is appointed worth 101 which is imprinted in yield\n2. Variable f is again announced in capacity and assumes local scope. It is allocated esteem “I am learning Python.” which is printed out as a yield. This Python proclaim variable is not quite the same as the global variable “f” characterized prior\n3. When the capacity bring is finished, the neighborhood variable f is devastated. At line 12, when we once more, print the estimation of “f” is it shows the estimation of global variable f=101\n\nPython 2 Example\n\n```# Declare a variable and initialize it\nf = 101\nprint f\n# Global vs. local variables in functions\ndef someFunction():\n# global f\nf = 'I am learning Python'\nprint f\nsomeFunction()\nprint f```\n\nPython 3 Example\n\n```# Declare a variable and initialize it\nf = 101\nprint(f)\n# Global vs. local variables in functions\ndef someFunction():\n# global f\nf = 'I am learning Python'\nprint(f)\nsomeFunction()\nprint(f)```\n\nWhile Python variable assertion utilizing the keyword global, you can reference the global variable inside a capacity.\n\n1. Variable “f” is global in scope and is appointed worth 101 which is imprinted in yield\n2. Variable f is proclaimed utilizing the keyword global. This is NOT a local variable, yet a similar global variable announced before. Subsequently when we print its worth, the yield is 101\n3. We changed the estimation of “f” inside the capacity. When the capacity bring is finished, the changed estimation of the variable “f” perseveres. At line 12, when we once more, print the estimation of “f” is it shows the worth “changing global variable”", null, "Python 2 Example\n\n```f = 101;\nprint f\n# Global vs.local variables in functions\ndef someFunction():\nglobal f\nprint f\nf = \"changing global variable\"\nsomeFunction()\nprint f```\n\nPython 3 Example\n\n```f = 101;\nprint(f)\n# Global vs.local variables in functions\ndef someFunction():\nglobal f\nprint(f)\nf = \"changing global variable\"\nsomeFunction()\nprint(f)```\n\n## Delete a variable\n\nYou can likewise erase Python factors utilizing the command del “variable name”.\n\nIn the beneath illustration of Python erase variable, we erased variable f, and when we continue to print it, we get mistake “variable name isn’t characterized” which implies you have erased the variable.", null, "Example of Python delete variable or Python clear variable :\n\n```f = 11;\nprint(f)\ndel f\nprint(f)```\n\n## Summary:\n\n• Factors are alluded to “encompass” or “containers” where information can be kept up and referred to. Like some other programming language Python likewise utilizes a variable to store the information.\n• Factors can be announced by any name or even letter sets like a, aa, abc, and so on\n• Factors can be re-announced even after you have proclaimed them for once\n• In Python you can’t link string with number straightforwardly, you need to pronounce them as a different variable, and from that point onward, you can connect number with string\n• Python constants can be perceived as sorts of factors that hold the worth which can not be changed. Normally Python constants are referred to from different records. Python characterize steady is proclaimed in another or separate document which contains capacities, modules, and so forth\n• Kinds of factors in Python or Python variable sorts : Local and Global\n• Pronounce neighborhood variable when you need to utilize it for current capacity\n• Announce Global variable when you need to utilize a similar variable for rest of the program\n• To erase a variable, it utilizes watchword “del”." ]
[ null, "https://www.guru99.com/images/Pythonnew/Python5.1.png", null, "https://www.guru99.com/images/Pythonnew/Python5.2.png", null, "https://www.guru99.com/images/Pythonnew/Python5.4.png", null, "https://www.guru99.com/images/Pythonnew/Python5.5.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8472798,"math_prob":0.939114,"size":5927,"snap":"2021-43-2021-49","text_gpt3_token_len":1315,"char_repetition_ratio":0.18504137,"word_repetition_ratio":0.17313433,"special_character_ratio":0.22338451,"punctuation_ratio":0.081708446,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9615816,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-27T04:04:40Z\",\"WARC-Record-ID\":\"<urn:uuid:95173c84-f512-4c3f-9a56-869e89193109>\",\"Content-Length\":\"32774\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d77ad53f-c63e-4be7-9141-a474cfe031f5>\",\"WARC-Concurrent-To\":\"<urn:uuid:5db345aa-18bc-4343-91e9-116ba99098fa>\",\"WARC-IP-Address\":\"172.67.166.53\",\"WARC-Target-URI\":\"https://bigdata-world.net/python-delete-variable/\",\"WARC-Payload-Digest\":\"sha1:TJM4AO3SQGKVL6FK6GPZTVS5K4G2WXMN\",\"WARC-Block-Digest\":\"sha1:XONB7DH5ITE2JFQZJA4UHKMV3VEEABVL\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323588053.38_warc_CC-MAIN-20211027022823-20211027052823-00657.warc.gz\"}"}
https://www.convzone.com/quaternary-to-decimal/
[ "Have to deal with several conversions between Quaternary and Decimal numeral systems? Then this site is made for you! Use our super handy online tool to convert your data.Welcome!\n\n# Quaternary to Decimal converter\n\nConverting...\nPlease wait until the conversion process completes.\nSuccess!\nError!{{ error }}\n\n## How to convert Quaternary to Decimal\n\nQuaternary is the base-4 numeral system. It uses the digits 0, 1, 2 and 3 to represent any real number. Four is the largest number within the subitizing range and one of two numbers that is both a square and a highly composite number, making quaternary a convenient choice for a base at this scale. Despite being twice as large, its radix economy is equal to that of binary.\n\nThe decimal numeral system is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu-Arabic numeral system. For writing numbers, the decimal system uses ten decimal digits, a decimal mark, and, for negative numbers, a minus sign \"-\". The decimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; the decimal separator is the dot \".\" in many countries.\n\nFollow these steps to convert a quaternary number into decimal form:\n1. Write the powers of 4 (1, 4, 16, 64, 256, and so on) beside the quaternary digits from bottom to top.\n2. Multiply each digit by it's power." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.8190218,"math_prob":0.99493307,"size":1157,"snap":"2020-34-2020-40","text_gpt3_token_len":313,"char_repetition_ratio":0.15437987,"word_repetition_ratio":0.0,"special_character_ratio":0.28522038,"punctuation_ratio":0.152,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99026895,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-05T13:26:23Z\",\"WARC-Record-ID\":\"<urn:uuid:02348231-af42-40c0-b82c-50bafa5eefe2>\",\"Content-Length\":\"24099\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:997d20d6-a6e9-4bb7-8ab7-1b33040fb560>\",\"WARC-Concurrent-To\":\"<urn:uuid:495b63ad-23a0-4581-a09e-12f3ed27625d>\",\"WARC-IP-Address\":\"69.64.49.211\",\"WARC-Target-URI\":\"https://www.convzone.com/quaternary-to-decimal/\",\"WARC-Payload-Digest\":\"sha1:AEHPPVPCTYQJG4A77FMWP3WTVOMZAYKD\",\"WARC-Block-Digest\":\"sha1:WPLWEYLBQ5FW6WMXDYAMEKKTNZXR56J5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439735958.84_warc_CC-MAIN-20200805124104-20200805154104-00270.warc.gz\"}"}
https://ejournal.undiksha.ac.id/index.php/JJPGSD/article/view/3794
[ "### PENGARUH STRATEGI REACT DAN MOTIVASI BELAJAR TERHADAP HASIL BELAJAR MATEMATIKA SISWA KELAS V\n\nI Dewa Putu Yudiprasetya ., Prof. Dr. Ni Ketut Suarni,MS ., Ni Wayan Rati, S.Pd., M.Pd. .\n\n#### Abstract\n\nKata Kunci : strategi REACT, hasil belajar matematika, motivasi belajar\n\nThis study aimed to determine: (1) the differences of mathematics learning outcomes between students who learned using REACT strategy and students who learned conventionally, (2) the interaction effect between students who learnedREACT strategy and motivation toward mathematics learning outcomes, (3)differences of mathematics learning outcomes between students who learned with REACT strategy and conventionally on students' high motivation, (4) differences of mathematics learning outcomes between students who learned with REACT strategy and conventionally on students’ low motivation. This research is a quasi experimental study with a 2x2 factorial design. The population of this research is all students in class V on IX Buleleng district in academic year 2013/2014, amounting to 210 people. The sample of this study are the students of class V SD No. 1 Astina, amounting to 34 people and the students of class VB SD No. 1 Banjar Jawa amounting to 32 people. The data of mathematics learning outcomes were collected by multiple choice test instruments and the data of students' motivation were collected by questionnaires. The data collected were analyzed using descriptive statistics and ANOVA analysis of two paths. The results showed that: (1) there are differences of mathematics learning outcomes between students who learned with REACT strategy with conventional learning with a significance value of 0.002, (2) there is an interaction effect between REACT strategy and motivation toward mathematics learning outcomes of students with a significance value of 0.041, (3) there are differences in mathematics learning outcomes between students who learned with REACT strategy with conventional learning on students'high motivation with a value of F of 19.64, and (4) there are differences in mathematics learning outcomes between students who learned with REACT strategy with conventional learning onstudents’ low motivation with a value of F of 5.29. So, REACT strategy and motivation to learn mathematics influence on student learning outcomes.\nkeyword : REACT strategy, mathematic learning outcomes, motivation to learn\n\n#### Full Text:\n\nPDF\n\nDOI: http://dx.doi.org/10.23887/jjpgsd.v2i1.3794\n\n### Refbacks\n\n• There are currently no refbacks.\n\nJurnal ini diterbitkan oleh :", null, "Universitas Pendidikan Ganesha", null, "", null, "" ]
[ null, "https://ejournal.undiksha.ac.id/public/site/images/aditra/logo_undiksha_baru1.png", null, "https://i.creativecommons.org/l/by-sa/4.0/88x31.png", null, "https://i.creativecommons.org/l/by-sa/4.0/88x31.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5947811,"math_prob":0.7371976,"size":7083,"snap":"2019-43-2019-47","text_gpt3_token_len":1640,"char_repetition_ratio":0.17714366,"word_repetition_ratio":0.75686675,"special_character_ratio":0.1831145,"punctuation_ratio":0.09009009,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95355326,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-20T19:28:50Z\",\"WARC-Record-ID\":\"<urn:uuid:4f6a34ac-df4b-4328-992a-e1e0f1c41238>\",\"Content-Length\":\"30266\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6c005325-b46c-4683-80d4-876c26546b29>\",\"WARC-Concurrent-To\":\"<urn:uuid:e36b06c0-072e-4bd4-b667-424016c131af>\",\"WARC-IP-Address\":\"119.252.170.182\",\"WARC-Target-URI\":\"https://ejournal.undiksha.ac.id/index.php/JJPGSD/article/view/3794\",\"WARC-Payload-Digest\":\"sha1:I4Y4AADNMV4ZEN5GIMAZ4TP65ZU2ZTSZ\",\"WARC-Block-Digest\":\"sha1:BKDQLHDSYKFHVWQHBZ6V7AS5RS7WHLNU\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496670601.75_warc_CC-MAIN-20191120185646-20191120213646-00103.warc.gz\"}"}
https://www.mygolfspy.jp/how-we-test-putters/
[ "", null, "## Strokes Gained 18  (SG18)\n\nWe have adopted a new and improved system for scoring putter performance.  This system is the most accurate way to test player putter efficiency.  Rather than measuring radial accuracy, we are measuring the actual putts required to put the ball into the hole.\n\nWe compare our test putters using the Strokes Gained Putting system developed by Columbia Business School professor, Mark Broadie.\n\nWhile this system may have been developed by a college mathematician, it is actually very simple. We assessed the individual putters using the following process:\n\n• Testers putted five times from 5, 10, and 20 feet, each time continuing to putt until the ball went in the cup.\n• The average number of putts from each distance for each putter was then calculated.\n\n(Total Putts for Cohort)/(50 \"Holes\" at each distance)= Ave. Number of Putts/\"Hole\"\n\n• The average of all putters at each distance was then calculated in a similar fashion.\n• The strokes gained at a given distance was then calculated by subtracting the putter cohort average from the tester average for an individual putter.\n\n(Average Putts for Individual Putter) - (Average for All Putters) = Strokes Gained vs. Average\n\n• This means that a putter with a positive score scored better than the average, while a negative scoring putter scored worse.\n• To calculate the final score, we added up the individual strokes gained for the three hole distances, then multiplied them by six to give us a strokes gained score that would reflect using the putter for an eighteen hole round of golf.\n\n## Testing Parameters\n\n• Number of Testers: 20\n• Testing Handicap Range: +3-18\n• Testing Location: MyGolfSpy Test Facility\n• Ball Used: Bridgestone 330-RX\n• Distances Assessed: Five, Ten, and Twenty Feet\n• “Holes Completed” at each Distance: 6\n• Total Putts in Test: 9,000" ]
[ null, "https://www.mygolfspy.com/wp-content/uploads/2016/07/sg-putting-2016.jpg", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.9404613,"math_prob":0.88638663,"size":1828,"snap":"2023-40-2023-50","text_gpt3_token_len":422,"char_repetition_ratio":0.13377193,"word_repetition_ratio":0.0,"special_character_ratio":0.21827133,"punctuation_ratio":0.10030395,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9728088,"pos_list":[0,1,2],"im_url_duplicate_count":[null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-25T20:09:16Z\",\"WARC-Record-ID\":\"<urn:uuid:7738be0b-db8d-4c45-8fae-f1db1d814086>\",\"Content-Length\":\"102503\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:54b60844-eff9-4e7d-a232-b250c4eabf41>\",\"WARC-Concurrent-To\":\"<urn:uuid:ab8a1114-ec00-4ee9-97e0-ad411c8d48d9>\",\"WARC-IP-Address\":\"52.199.16.232\",\"WARC-Target-URI\":\"https://www.mygolfspy.jp/how-we-test-putters/\",\"WARC-Payload-Digest\":\"sha1:LWZR5JVL65CXI7Y7LA3XFDNY5JOA25ZC\",\"WARC-Block-Digest\":\"sha1:V3TMHWIF3WBUWBYNI745G5WGOP3ORO4B\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510085.26_warc_CC-MAIN-20230925183615-20230925213615-00013.warc.gz\"}"}
http://zgns.bottin-malin.fr/multiplication-of-integers-class-7.html
[ "# Multiplication Of Integers Class 7\n\nSolved: (10 Pts) Let N Be A Natural Number And Consider Th\n\nSeptember 2015 – Mrs Hamano's Math Classes\n\nNCERT Solutions for Class 7 Maths Chapter 1 Integers in PDF Form\n\nmaths practice worksheets for class 7\n\nIntegers Games Math Integer Games For Grade Fresh Grade 7 Learning\n\nAnswer CS 8803 GA HW 3 Name 6 Problem 4 Integer multiplication using\n\nAdding Integers Math Worksheets Grade 8 Core Worksheet Multiplying\n\nMath Worksheets Modeling Integers Worksheet Multiplication Number\n\nInteger Multiplication Using Tiles and Number Lines\n\nmaths practice worksheets for class 7\n\nUntitled\n\nHow to Multiply Fractions With Whole Numbers: 9 Steps\n\nyear 3 maths word problems worksheets – primalvape co\n\nIntegers: Addition, Subtraction, Division, Multiplication an by\n\nRational Numbers - NCERT Class 7 Maths Maths NCERT Solution free\n\nClass 7 CBSE maths Integers\n\nMath Integers Word Problems With Answers Video For Lesson Word\n\nIntegers Worksheets Grade 8 Integer Worksheets Grade 7 Integers\n\nintegers math worksheets – odmartlifestyle com\n\nHow to Multiply Fractions: 7 Amazing Activities to Try Out\n\nGrade 8 Math Fractions Help To Fraction Cool Worksheets Alberta\n\nintegers problems – shamsularifeen com\n\nInteger - Wikipedia\n\nIntegers Unit: Add, Subtract Divide, Multiplying Integers + Word Problems\n\nMind-map of Integers class 7 | short notes and Mind-map of Integers\n\nHappyclass - Integers, Mathematics, CLASS 7 - NCERT CBSE\n\nIntegers Worksheets With Answers Math Grade Math Word Problems\n\nwhat are properties of integers with examples of class 7 ncert\n\nNegative Number Worksheets | Free - CommonCoreSheets\n\nDivision of Integers - Mathematics for Class 7 (Video - 4) (Hindi\n\nRational Numbers | short notes on rational number class 7 | grade7th\n\nGrade Math Practice Worksheets 6 Multiplication Class Maths Integers\n\nNCERT Solutions for Class 7 Maths Chapter 1 Integers - Free PDF\n\nAlgebraic expressions pdf printable worksheets with integers\n\nThe Rise and Decline of Stock (Multiplying / Dividing Integers\n\nCollection of Math integer worksheets | Download them and try to solve\n\nC# Sharp Exercises: Compute multiplication table of a given integer\n\ninteger practice worksheets for 7th grade\n\nStudy Guide Unit 1: Variables, Expressions, and Integers\n\nNCERT Solutions for Class 7 Maths Integers\n\n7th Grade - Math in Demand\n\nNCERT Class 7 Solutions: Integers (Chapter 1) Exercise 1 4 Part 3\n\nPDF) SNBP INTERNATIONAL SCHOOL -RAHATANI | Santosh Patel - Academia edu\n\nFractions And Decimals Worksheets Grade 7 Full Size Of Math Percents\n\nROSS GRAY SCHOO NE S ETTER\n\nSOL's Covered: Topics: Integers (Add, Subtract, Multiply, & Divide\n\nHow to Multiply Fractions With Whole Numbers: 9 Steps\n\nFree worksheets for linear equations (grades 6-9, pre-algebra\n\nNCERT Solutions for Class 7 Maths Chapter 1 Integers in PDF Form\n\n39 mental math grade 2 day 8 mental math pinterest math math, math\n\nmultiplying dividing integers worksheet – invisalignexpressbraces com\n\nNCERT Solutions For Class 7 Maths Chapter 1 Integers Ex 1 2\n\nNCERT Solutions for Class 7 Maths Chapter 1 Integers - Free PDF\n\nIntegers || class null || NCERT || doubtnut\n\nArithmetic Practice Worksheets Arithmetic Reasoning Worksheets Maths\n\nक्लास _हॉलिडे होम वर्क\n\ninteger practice worksheets for 7th grade\n\nInteger Operations Pre-assessment\n\nGrade 7th Grade Math Integers Worksheets : Criabooks 7th Grade Math\n\nMultiplication of Integers - Mathematics for Class 7 (Video - 3\n\nGrade 7 Math Key Multiplying Integers Worksheet Advanced Worksheets\n\nFillable Online basd k12 wi Skill Multiplying Integers - basd k12 wi\n\nAdding Integers Math Worksheets Grade 8 Core Worksheet Multiplying\n\nMrs Wensley's Classes: 04/26/17\n\nNegative Number Worksheets | Free - CommonCoreSheets\n\nSubtraction of negative integers - Maths for Class 7 for CBSE, ICSE\n\nPrintable Decimal Worksheets Multiplying Decimals Grade 7\n\nMathematics Class-VII - Math with JM - home\n\n6 multiplication of integers worksheets, maths practice worksheets\n\nIntegers class 7 pdf\n\nIntegers Worksheets | Dynamically Created Integers Worksheets\n\nwhat is rational number in maths – papakambing com\n\nGrade 7 Maths Worksheets With Answers Free Integer Word Problems\n\nUntitled\n\nNCERT Solutions for Class 7 Maths Chapter 1 Integers in PDF Form\n\nIntegers Worksheets | Dynamically Created Integers Worksheets\n\nMultiplying Integers Rules Math On Day My Other Standard Class\n\nMultiplying Integers Worksheet - holidayfu com\n\nProperties of integers\n\nIntegers\n\ndivision worksheets grade 7\n\nmultiplying dividing integers worksheets – trungcollection com\n\nInteger Worksheets\n\nMath 7 term 1 - MR MASIGAN\n\nInteger Worksheets\n\nmultiplying dividing integers worksheets – trungcollection com\n\nWorksheets Grade 6 Mathematics Math 8 Printable Unique\n\nGrade 7 Maths Worksheets With Answers Free Integer Word Problems\n\nNCERT Class 7 Solutions: Integers (Chapter 1) Exercise 1 4 Part 2\n\nabsolute value of integers worksheets – atrevetehoy com\n\nUntitled\n\ninteger problems worksheets – primalvape co\n\nYear 7 Maths Worksheets Printable Grade 7 Math Printable Worksheets\n\nMultiplying And Dividing Integers Worksheet Pdf The best worksheets\n\nIntegers Class 7 Notes Maths Chapter 1 - Learn CBSE\n\nHardin Middle School Math Cheat Sheets\n\nFree Integer Worksheets Worksheets Multiplication Integer Printable\n\nMultiplying and Dividing Integers Grade 8 Nelson Lesson 6 1 and 6 2 2 5 13\n\ninteger word problems worksheet – atrevetehoy com\n\nIntegers RS Aggarwal Class 7 Math Solutions Exercise 1B | CBSE Maths" ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.5873259,"math_prob":0.6325556,"size":5423,"snap":"2019-35-2019-39","text_gpt3_token_len":1301,"char_repetition_ratio":0.25465953,"word_repetition_ratio":0.17569193,"special_character_ratio":0.19620137,"punctuation_ratio":0.037304454,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99856657,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-16T02:53:55Z\",\"WARC-Record-ID\":\"<urn:uuid:823e642f-e383-48ac-99c2-f806b0b271cc>\",\"Content-Length\":\"117354\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f003997d-70bd-4746-b71a-1f16f56938a9>\",\"WARC-Concurrent-To\":\"<urn:uuid:7767c14a-0ae1-4db1-bdb1-6bbe728da6ab>\",\"WARC-IP-Address\":\"104.27.152.147\",\"WARC-Target-URI\":\"http://zgns.bottin-malin.fr/multiplication-of-integers-class-7.html\",\"WARC-Payload-Digest\":\"sha1:JXJQO5XJFAEHTEI64YO6BDNZC54EUCZK\",\"WARC-Block-Digest\":\"sha1:JCLNNWXIL4I6ADKQC2BB6M3YC2LCIIDW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514572471.35_warc_CC-MAIN-20190916015552-20190916041552-00078.warc.gz\"}"}
https://casejournals.com/qa/question-what-is-an-independent-variable-in-an-experiment.html
[ "", null, "# Question: What Is An Independent Variable In An Experiment?\n\n## What is difference between dependent and independent variable?\n\nThe independent variable is the cause.\n\nIts value is independent of other variables in your study.\n\nThe dependent variable is the effect.\n\nIts value depends on changes in the independent variable..\n\n## Why is it called an independent variable?\n\nIndependent variables are variables that are manipulated or are changed by researchers and whose effects are measured and compared. … The independent variables are called as such because independent variables predict or forecast the values of the dependent variable in the model.\n\n## How do you know if a variable is independent?\n\nYou can tell if two random variables are independent by looking at their individual probabilities. If those probabilities don’t change when the events meet, then those variables are independent. Another way of saying this is that if the two variables are correlated, then they are not independent.\n\n## What is an example of an independent variable in an experiment?\n\nIt is a variable that stands alone and isn’t changed by the other variables you are trying to measure. For example, someone’s age might be an independent variable. Other factors (such as what they eat, how much they go to school, how much television they watch) aren’t going to change a person’s age.\n\n## What is an independent variable easy definition?\n\nAn independent variable is a variable that represents a quantity that is being manipulated in an experiment. A dependent variable represents a quantity whose value depends on those manipulations.\n\n## What is the dependent variable in an experiment?\n\nThe dependent variable is the variable that is being measured or tested in an experiment. … In a psychology experiment, researchers are looking at how changes in the independent variable cause changes in the dependent variable.\n\n## What are the 3 types of variables?\n\nA variable is any factor, trait, or condition that can exist in differing amounts or types. An experiment usually has three kinds of variables: independent, dependent, and controlled.\n\n## Can time be a dependent variable?\n\nTime is always the independent variable. The other variable is the dependent variable (in our example: time is the independent variable and distance is the dependent variable).\n\n## Can gender be an independent variable?\n\nAn independent variable is used in statistics to predict or explain a dependent variable. For example, Age and Gender might be used as independent variables to predict the age of death or life expectancy (dependent variables).\n\n## What is variable in research with example?\n\nCategorical variablesType of variableWhat does the data represent?ExamplesNominal variablesGroups with no rank or order between them.Species names Colors BrandsOrdinal variablesGroups that are ranked in a specific order.Finishing place in a race Rating scale responses in a survey*1 more row•Nov 21, 2019\n\n## How do you find the independent variable in an experiment?\n\nThis makes it easy for you to quickly see which variable is independent and which is dependent when looking at a graph or chart. The independent variable always goes on the x-axis, or the horizontal axis. The dependent variable goes on the y-axis, or vertical axis.\n\n## What are levels of an independent variable?\n\ntime to hit brakes) Levels of an Independent Variable. If an experiment compares an experimental treatment with a control treatment, then the independent variable (type of treatment) has two levels: experimental and control.\n\n## How do you identify a manipulated variable?\n\nA manipulated variable is the independent variable in an experiment. It’s called “manipulated” because it’s the one you can change. In other words, you can decide ahead of time to increase it or decrease it. In an experiment you should only have one manipulated variable at a time.\n\n## What is an example of an independent variable in psychology?\n\nThe independent variable is the variable that is controlled and manipulated by the experimenter. For example, in an experiment on the impact of sleep deprivation on test performance, sleep deprivation would be the independent variable.\n\n## What is an example of an experimental variable?\n\nExamples of common experimental variables are: disease. compound. genotype.\n\n## How do you manipulate independent variables?\n\nAgain, to manipulate an independent variable means to change its level systematically so that different groups of participants are exposed to different levels of that variable, or the same group of participants is exposed to different levels at different times.\n\n## How do you control participant variables?\n\nParticipant variables can be controlled using random allocation to the conditions of the independent variable." ]
[ null, "https://mc.yandex.ru/watch/75831997", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.90053326,"math_prob":0.9062574,"size":5496,"snap":"2021-21-2021-25","text_gpt3_token_len":1017,"char_repetition_ratio":0.3058995,"word_repetition_ratio":0.17376295,"special_character_ratio":0.18595342,"punctuation_ratio":0.10330579,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9780181,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-22T17:39:31Z\",\"WARC-Record-ID\":\"<urn:uuid:556a9a3a-8f43-4153-afcf-4bc751e00165>\",\"Content-Length\":\"42826\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c8169c34-e3f5-4980-8a94-fab45f9b7fc1>\",\"WARC-Concurrent-To\":\"<urn:uuid:72f332a3-4f56-4f06-8758-1d0a2d8c467f>\",\"WARC-IP-Address\":\"104.21.57.236\",\"WARC-Target-URI\":\"https://casejournals.com/qa/question-what-is-an-independent-variable-in-an-experiment.html\",\"WARC-Payload-Digest\":\"sha1:XKZWSZ732SPVVWP3KJQS7UUOUARWY7Y4\",\"WARC-Block-Digest\":\"sha1:DYYSD4BQXFUW467TV26SXDODQF5IQZ6O\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623488519183.85_warc_CC-MAIN-20210622155328-20210622185328-00292.warc.gz\"}"}
http://excel.bigresource.com/Macro-for-putting-index-reference-numbers-in-numerical-sequence--H3nol5Mx.html
[ "# Macro For Putting Index Reference Numbers In Numerical Sequence?\n\nNov 12, 2012\n\nI have a document that is a subject index for book that has terms that reference page numbers. The structure is for example: Employment, 587, 592, 553, 605, 233 The term is always following by comma and then space and listing of page numbers that subject reference applies. In many cases the page number references are out of sequence and I need them to be in numerical sequence. i.e. Employment, 233, 553, 587, 592, 605 There are many subject terms in index and need to check and fix sequence of page references for each.\n\n## Macro Instruction To Copy Down Sequence Of Numbers\n\nDec 24, 2013\n\nI'm use to highlighting two cells, find the plus, and copying a list of numbers down about 10 rows. Is there a macro instruction or VB instruction that will do the same?\n\nExample,\n\nBefore:\n\nG1010\nG1011\n\nAfter:\n\nG1010\nG1011\nG1012\nG1013\nG1014\nG1015\nG1016\nG1017\nG1018\nG1019\nG1010\nG1011\n\n## Putting Index Column - VLookup Does Not Pick Up Dates?\n\nApr 5, 2014\n\ndoes it not like dates? i have columns of data and i wish to search it for each month and then print a months worth. here is part of the data. maybe vlookup does not like dates? i tried putting an index column on the left, 1,2,3,4... but it still would not pick up \"Jun\"\n\n## Sequence Based On Column A Index\n\nSep 18, 2006\n\nI am stuck on what should be a simple formula. I have a spreadsheet that is sorted by \"target\" number in column A, basically 1,2,3,4. I am trying to create a formula that will increase the number in column B by one based on column A. So when the value in column A changes column B will reset to 1. Also I need this sequence number to be preceded by zeros up to 0999. So 1 would be 0001 and 895 would be 0895.\n\n## Drag Sequence Having Sheet Reference?\n\nOct 4, 2013\n\nI would like this formula to increase down the column as follows:\n\n=Temp_Data!A1\n=Temp_Data!A5\n=Temp_Data!A9\n\nSequence is addidng 4 each time... Dragging results with:\n\n=Temp_Data!A1\n=Temp_Data!A5\n=Temp_Data!A9\n=Temp_Data!A4\n=Temp_Data!A8\n=Temp_Data!A12\n\nI have seen the following work for others:\n\n=INDEX(A:A, (ROW()*2)-1)\n\nCan a macro be created to store the number as a variable and loop a certain amount of times adding four to that variable every time?\n\n## How To Automate Sequence Of Numbers\n\nJul 25, 2014\n\nI'm trying to automate a sequence.\n\nI was gonna explain it but I couldn't make myself clear so I took a screenshot:\n\nsequence.PNG\n\nfolder_type is what the user types, (for example, the letter \"A\"), and folder_code is a sequence that should auto-generate according to what was manually inserted in the folder_type field.\n\nWhat formula could I use for this process?\n\n## Identify Numbers In Sequence\n\nAug 23, 2007\n\nI have a task to identify all the numbers in sequence in a worksheet, how do I do that?\n\nEx:\nColumn A\n1\n2\n3\n4\n5\n7\n9\n10\n11\n12\n13\n14\n15\n16\n20\n21\n22\n\nDesired output 1-5,7,9,10-16,20-22.\n\n## Average Numbers In Sequence\n\nOct 21, 2005\n\nI have cells O1 to O300 numbers in random sequences of no more than 10\n\nI need to average the 5 highest numbers in each sequence eg:\n\nO P\n1 2 16 (result)\n2 20\n3 4\n4 6\n5 14\n6 12\n7 8\n8 10\n9 16\n10 18\n11 blank cell\n12 15 9 (result)\n13 3\n14 6\n15 12\n16 9\n17 blank cell\n18 blank cell\n19 4 23 (result)\n20 16\n21 20\n22 40\n23 8\n24 11\n25 28\n26 blank cell\n\ndown to 300 rows, the sequence of numbers can be from 1 to 10 but never\nmore than 10\n\nI got a function : =IF(COUNT(O1:O10>=10,AVERAGE(LARGE(O1:O10,{1,2,3,4,5})),\"\n\") but that works only for 10 numbers and not for less\n\n## Highlight Numbers In Sequence\n\nDec 19, 2008\n\nThere are 350 numbers in a column, 7 digits in each cell. I want to see which cells have 3 or more consecutive numbers. Only looking at the last 3 digits. Example. 1960657. 1960658. 1960659. 1960660. Has 4 consecutive numbers.\nConditional formatting ? or other?\n\n## Filling In Numbers In Sequence\n\nJul 29, 2009\n\nI am trying to \"auto fill\" a column with numbers in sequential order. (1,2,3,4,5...) I typed in 1,2,3... in the first cells and clicked on the black corner dot to drag the sequence down. It keeps putting in 1,2,3,1,2,3,1,2,3..... I have also went into the advanced options and clicked the \"enable fill handle and cell drag-and-drop\" and also Alert before overwriting cells\" and it still fills in 1,2,3,1,2,3....\n\n## Count Numbers In Sequence ....\n\nDec 8, 2006\n\nI have a list of random numbers in column A the number range is from 0 to 20,000. What I am trying to do is to count the sequential numbers after each random number....sorry this is not really explained well so I willl use a numeric example.\n\nA\n23\n24\n25\n33\n34\n60\n77\n80\n\nAbove is what I have in column A you can see that my number range starts a 23 so I would like to count the sequential numbers that occur from 23 in this case it would be count(23,24,25) giving the answer 3 I would like this answer to be inserted into column B next to 23 and the numbers that were counted in this formula then be deleted as rows (i.e. where the number 24 and 25 was counted then the rows containing these numbers are deleted), The macro moves then to count the next number.\n\nIn the case of just a single number then a value of 1 is entered into the column next to the number indicating that there was only one number in that sequence.\n\n## Writing A Macro For Work That Can Loop Through Reference Numbers\n\nMay 13, 2014\n\nI have attached a screencap of an example source table that I am trying to write a macro to manipulate each day. Starting conditions are that I have data in column A and B. Column A would be reference numbers that may be on one line, or more likely, on multiple lines repeating with varying counts. Column B is the weight associated with each line. I would need a macro that could loop through column A, determine if the ref number has changed, and then calculate/populate column C. Column C is the % of the total weight for the unique reference number. I have illustrated this in the table using column D. This is taking me incredible manual effort to complete right now and I do know VBA, I just don't know how to loop a variable range in this case.\n\n## Searching For Sequence Of Numbers Down A Column?\n\nJun 6, 2014\n\nI was wondering whether it was possible to search for a sequence of numbers.\n\nFor example, if this is down a column:\n\nA1: 5\nA2: 4\nA3: 5\nA4: 6\nA5: 9\n\nIs it possible to have a find function to search for the sequence of numbers \"4 + 5\" and consequently highlight cells A2 and A3?\n\n## Tell Larger Sequence Of Repeated Numbers In Row?\n\nNov 25, 2012\n\nI have a table that receives the number sequence 1 and sequence number 0.\n\nI need to calculate the highest sequence numbers that repeat in Secunia lines.\n\nA\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\n\nResult\n\n1\n1\n1\n0\n0\n1\n0\n1\n0\n1\n1\n0\n3\n\n[code].....\n\nSee for example the last line.\n\n1 1 0 0 1 0 1 1 1 1 1 0 = 5\n\nI have a sequence number 1, where it repeats 5 times segudamente.that is greater than other sequences.\n\n## Arranging Numbers In Numerical Order\n\nMay 26, 2012\n\nI'm looking for a formula that will rearrange a row of numbers in numerical order and by their last digit also in a numerical order, I hope it's clear enough !!!\n\n2 1235781114162022273139667197110113128136139153225250328428508576772 3\n4 2011025011131712227723113153145225166613657672797812832842850839139 5\n\n## How To Convert Numerical Numbers To Words\n\nJun 20, 2014\n\nhow to convert numerical numbers to words in MS excel & MS world\n\n## RANK Duplicate Numbers Without Missing In Sequence?\n\nJul 18, 2014\n\nAttempting to do a spreadsheet for my golf club, to record scores, etc...\n\nManaged to get it to pretty much what I want despite some very extreme looking formulae! So for some scores such as 56,56,57,57,54,54, Rank would just give me 3,3,5,5,1,1, so I have put a second column next to 56,56,57,57,54,54 where I input scores to seperate ties (better back nine scores), so in the above I would have for example 30,29 next to the two 56s, 27,29 next to the two 57s, and 27,28 next to the two 54s, so the rank would return 4,3,5,6,1,2. I have gone three stages further, so if, the back nine score was also tied, I have a column for the last 6 hole score, the last 3 hole score and even the last hole score. This is some serious formulae at this point. However, I now want the OPTION to rank the original data as 2,2,3,3,1,1 if I don't put any data in the back nine column.\n\nThis is so that I can input doubles scores on the same spreadsheet as singles scores, so if two people shoot the same score in singles I can input the back 9 scores etc to decide who comes out ahead, but in doubles I would just leave the back nine score blank, and then two people would share 1st in the rank, but then I need two 2nd ranks NOT 3rd ranks as it currently is.\n\nJust so you can see how complex it is the current forumlae in the rank is here is an example:\n\n=IF(O7=\"\",\"\",IF(K\\$2=\"MEDAL\",RANK(O7,O\\$7:O\\$255,1)\n+SUMPRODUCT(--(O7=O\\$7:O\\$255),--(P7>P\\$7:P\\$255))\n+SUMPRODUCT(--(O7=O\\$7:O\\$255),--(P7=P\\$7:P\\$255),--(Q7>Q\\$7:Q\\$255))\n\n[Code] .....\n\nThere are other things in there to sort out a few other issues as well, but I cant see the wood for the trees so to speak, to get it todo what I want!\n\nI have also attached a sample from my spreadsheet to better demonstrate what I want!\n\n## Confirming If Multiple Rows Of Numbers Run In Sequence\n\nJun 24, 2009\n\nI'd like Excel to run a check to see if a row of numbers runs in sequence.\n\n*As in row 4, the numbers dont have to incriment each time\n*As in row 2, there may be gaps in the data\n*As in row 6, the data cant increase and then decrease. Each subsequent number must be the same or high than the previous\n*There could be varying amounts of numbers per row, hence the results being in column R\n\nAs an added bonus it'd be nice to see where an error occurs, but just knowing theres an error (column R) is the primary goal.\n\n## Find Lookup Sequence Of Numbers In Rows\n\nJun 27, 2012\n\nBasically I'm trying to look up a series of numbers against a separate row of numbers and look for a match regardless or number order.\n\nFor example\n\nIf you look at the above picture I'm trying to do a query of some sort that will look up the numbers in A8:G8 in then search each row in the above table ie look for the numbers in B1:J1, B2:J2,B3:J3 etc I need to be able to search each row and look for the sequence of numbers regardless of order, if there is or inst a match for all numbers it should look at the next row and so on (maybe multiple matches). If there is a match then it should display the Name located in column \"A\" into cell G8. In this example to Jarrad row contains the numbers located in A8:G8. If there is no match it should display \"None\".\n\nI'm trying to find any easy way to do this as I have over 500 rows I'm trying to query. The number's in A8:G8 in this example could also be more or less, ie here I have included 6 numbers but this could be 3 or 9 etc.\n\n## Place In Sequence Increasing The Numbers Of One I Creak In A Cell\n\nDec 13, 2008\n\nI would like to place in sequence increasing the numbers of one I creak in a cell.\nIn the formula I determine it I creak and the corresponding frame number to the placed ones.\nThe problem is that he is accumulated only the greater and not sequencia it.\n\n1803456781101112\n1134567810111280\n\nbut,80-80\n\nFunction ordenar2(Myrange As Range, num As Integer) As String\nDim Myorder As Double\nDim X2 As String\nDim n As Integer\nn = 1\nDo While n\n\n## Lottery Search Query: Correct Sequence Of Numbers\n\nOct 10, 2006\n\nI am setting up a spreadsheet with two columns. The first column will contain a persons name the second column will contain four numbers.\n\nName Numbers\nJoe 1,3,12,24\nJohn 4,12,23,24\nJill 6,14,19,26\n\nI need to be able to search to find the following: the correct sequence of numbers e.g. if 1,3,12,24 were pulled out then that search is easy. If I was looking for someone who had the numbers 1,12,24 then I have a problem. I was thinking about putting the four numbers in to four separate columns but my Excel knowledge is poor.\n\n## Find Most Common (x5) Numbers Within Numerical String Range?\n\nApr 2, 2014\n\nI have a range of cells containing a string of numbers separated by ';' e.g.\n\nCOLUMN A COLUMN B\nIDENTIFIER_011122;1942;2011;1869;2642;2729;2731;2655;2678;2341;2347;2354;2332;2506;1809\nIDENTIFIER_021122;1942;2011;1869;2642;2729;2731;2655;2678;2207;2209;2217;2220;1880;2506;1809\nIDENTIFIER_031122;1942;2011;1869;2642;2729;2731;2732;2648;2255;2207;2217;2220;2387;1880;2506;1809\nIDENTIFIER_041122;1942;2011;1869;2642;2729;2731;2732;2678;2207;2209;2217;2220;1880;2506;1809\nIDENTIFIER_051122;1942;1971;2011;1869;2642;2729;2731;2648;2678;2342;2354;2355;2207;2209;2217;2220;2398;1880;2506;1809\nIDENTIFIER_061122;1942;2011;2169;1869;2642;2729;2731;2732;2678;2341;2343;2347;2354;2207;2209;2217;2220;1880;2506;1809\nIDENTIFIER_071122;1942;2095;1869;2573;2587;2648;2655;2673;2207;2209;2220;1880;1809\nIDENTIFIER_081122;1942;2095;1870;2642;2648;2673;2678;2341;1880;2506;1809\n\nI am looking to find the top 5 most common/repeated numbers within this range. I have found a formula to work out the largest number within the range:\n\n=MAX(IFERROR(0+TRIM(MID(SUBSTITUTE(\";\"&B3,\";\",REPT(\" \",LEN(B3))),(ROW(A\\$1:A\\$200)*LEN(B3))-1,LEN(B3))),0)) (REF http://www.excelforum.com/excel-gene...e-numbers.html)\n\nHow to modify it to work with e.g. the mode function.\n\nI know I could separate all the numbers out using 'text to columns' but I will need to work this out regularly on large quantities of data ...\n\n## Formula To Extract Numbers From Alpha Numerical Entry\n\nJan 8, 2014\n\nI have a sheet with thousands of rows of ID's which are made up of a series of letters, numbers, underscores and or spaces. Within the sheet there are numerous duplicates so I need to able extract the numerical element, which is the key data to be able to identify the duplicates.\n\nThe numbers I need to extract are mainly 6 and 7 digits long however don't always sit in the same place within the ID. I don't need the 3 digit number sequences, just the 6 & 7 number sequences\n\ne.g\n\nAB_123_456789_Jones\nCD_131_7654321_Smith\nAB_123_Jones_456789\n\nI've found a formula that strips out all the numbers, however it also included the 3 digit numbers which I don't want. I've also used Text To Columns to break up the ID across a number of columns however that leaves me with 2 and sometimes 3 columns where a 6 digit ID appears\n\nIs there a simple way to extract the number if it's a certain length? i.e. 6 or 7 digits long\n\n## Placing Numbers In Sequence Down Rows And Duplicating If Information Matches?\n\nMar 7, 2013\n\nI have 2 columns,\n\ncolumn A has a series of 8 digit numbers (some will match some will not) sorting in A-z order from lowest to highest value.\n\nColumn B is blank at the moment.\n\nWhat I want\n\nIn column B i need to add numbers starting at 1 and moving down in sequence.\n\nIf more than one rows have the same number in column A they get the same numbe rin Column B\n\nIt's really a pain or have to hand type in the numbers and I can't figure out a easy way to do this.\n\nAttached example.\n\nTab 1 = Origanl Data\nTab 2 = results i'm lookin for.\n\n## Summing Sequence Of Numbers Seperated By Comma Within Single Cell\n\nMar 24, 2009\n\nI'm a basic excel user really and cannot find a function that will allow me to complete the following:\n\nCELL A1 includes the following sequence of numbers: 1,2,1,0,2,3\nI would like to know how to put a formula/function into CELL B1 that sums up the sequence of numbers in CELL A1 (i.e 1+2+1+0+2+3)\n\n## Putting Input Into A Macro\n\nApr 24, 2007\n\nI would like to write a macro that would start by asking me something along the lines of, \"Enter student # you want to print a report about.\" The # I enter would need to be stored as a variable in the VB code, and then my code would need to use the variable to do some search and replace operations. (Replace all instances of 10 (the default student number) with the variable I have specified).\n\nI don't really know how to even start going about this. How do I get Excel to ask me for a variable, and then use that variable in code?\n\n## Macro Putting In The Formula As Text Instead Of Results\n\nMay 28, 2008\n\nMy macro contains a VLookup formula that is giving me the text of the formula instead of the results. A portion of the macro is, as follows:\n\nSheets(\"Survey Results\").Select\nRange(\"c1\").Value = \"Resolving Group\"\nRange(\"c2\").Select\nActiveCell.FormulaR1C1 = \"=VLOOKUP(RC[-1],'Survey Invitation'!C[-2]:C[-1],2,FALSE)\"\nRange(\"C2\").Select\nSelection.AutoFill Destination:=Range(\"C2:C900\"), Type:=xlFillDefault\nRange(\"C2:C900\").Select\nRange(\"C2\").Select\n\nThe VLookup statement appears in place of the result when the macro is run. This is Excel 2007 and it runs to the end without error.\n\n## Index Row Reference Not Filling Down?\n\nJul 22, 2014\n\nI have a workbook where one worksheet is referencing cells from another worksheet. I need every third cell to pull from every single cell on the other sheet.\n\nI have found on other threads that =INDEX('WORKSHEET!B:B, 1*(ROW(\\$B\\$4:\\$B\\$4)+1)) worked. However when I filled down it wont increase the row reference.\n\nie.\n\n=INDEX('WORKSHEET!B:B, 1*(ROW(\\$B\\$4:\\$B\\$4)+1))\n=INDEX('WORKSHEET!B:B, 1*(ROW(\\$B\\$4:\\$B\\$4)+2))\n=INDEX('WORKSHEET!B:B, 1*(ROW(\\$B\\$4:\\$B\\$4)+3))\n\n[ATTACH]334142[/ATTACH\n\nThe other threads mentioned it should fill down fine, but not working for me.\n\n## 3d Reference In An INDEX Formula\n\nAug 12, 2009\n\ni'm trying to search throgh multiple sheets using an INDEX formula.\n\n=INDEX('12.31.09:11.15.09'!\\$AF\\$14:\\$AG\\$75,MATCH(E\\$2,'12.31.09:11.15.09'!\\$AC\\$14:\\$AC\\$75,0),MATCH(\\$B61,' 12.31.09:11.15.09'!\\$AF\\$12:\\$AG\\$12,0))\n\nIn short, these are timesheets; in a separate sheet i'm using the above formula to find how many hrs were worked on all the other sheets for a given job# within a given date range. (in the above example, i'm only searching in timesheets between 11/15 and 12/31, but I will ultimately change that to include the entire year '12.31.09:01.15.09'). E2 is a referenced job number; B61 is a referenced date.\n\nI'm getting a !VALUE error.\nCan a 3d reference work inside an INDEX formula?\n\n## Can Lookup Or Index Be Used To Reference To Different Cells\n\nJul 14, 2009\n\nCan they be used to reference data based on data inserted into more than one cell? I have attached an example as its kind of confusing to explain." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.87407666,"math_prob":0.8446662,"size":17538,"snap":"2020-10-2020-16","text_gpt3_token_len":5256,"char_repetition_ratio":0.14953804,"word_repetition_ratio":0.017043592,"special_character_ratio":0.33093855,"punctuation_ratio":0.1533593,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9637123,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-02-25T12:22:15Z\",\"WARC-Record-ID\":\"<urn:uuid:f7a75464-b524-4079-a9be-4e2c4d9d22c4>\",\"Content-Length\":\"49624\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4a2b7172-c601-439e-852c-521f08060aa1>\",\"WARC-Concurrent-To\":\"<urn:uuid:6ccdc76a-86bf-4f3a-9222-4e2106ddffe3>\",\"WARC-IP-Address\":\"130.211.100.39\",\"WARC-Target-URI\":\"http://excel.bigresource.com/Macro-for-putting-index-reference-numbers-in-numerical-sequence--H3nol5Mx.html\",\"WARC-Payload-Digest\":\"sha1:5UBRDP63UOXL63ADUJ5GTEGWDCRL37XT\",\"WARC-Block-Digest\":\"sha1:XK274GPRSILGXFBPGF66IPPDCRGP7BA2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-10/CC-MAIN-2020-10_segments_1581875146066.89_warc_CC-MAIN-20200225110721-20200225140721-00150.warc.gz\"}"}
https://www.education.com/worksheet/article/relate-tables-graphs-and-equations/
[ "# Relate Tables, Graphs, and Equations\n\nStudents analyze relationships between two variables using equations, tables, and graphs in this sixth-grade algebra worksheet! Each problem in this two-page math worksheet describes a real-world scenario and provides a simple equation that models the scenario. Students will practice using the equation provided to complete a table and sketch a graph for each scenario. This Relate Tables, Graphs, and Equations worksheet is a great way to help learners build confidence understanding linear equations." ]
[ null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.86892563,"math_prob":0.9845204,"size":503,"snap":"2022-27-2022-33","text_gpt3_token_len":87,"char_repetition_ratio":0.14028056,"word_repetition_ratio":0.0,"special_character_ratio":0.16500995,"punctuation_ratio":0.0952381,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99936146,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-06-26T17:38:50Z\",\"WARC-Record-ID\":\"<urn:uuid:34efd7c2-638d-4771-ba5e-58c8b35e4e03>\",\"Content-Length\":\"86858\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:756531eb-8e25-4383-bf81-fba97cf8280d>\",\"WARC-Concurrent-To\":\"<urn:uuid:dc63328a-2aa6-487a-a611-9e63b12b3020>\",\"WARC-IP-Address\":\"104.18.13.139\",\"WARC-Target-URI\":\"https://www.education.com/worksheet/article/relate-tables-graphs-and-equations/\",\"WARC-Payload-Digest\":\"sha1:MX3FHQNSXM3QHIBYYD7JBDJHHYLK7X37\",\"WARC-Block-Digest\":\"sha1:SG5J2BUZ22KJUS626CUHFKURWD6JPLYV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103271763.15_warc_CC-MAIN-20220626161834-20220626191834-00669.warc.gz\"}"}
https://percent.info/plus/90/how-to-calculate-727000-plus-90-percent.html
[ "727000 plus 90 percent\n\nHere we will teach you how to calculate seven hundred twenty-seven thousand plus ninety percent (727000 plus 90 percent) using two different methods. We call these methods the number method and the decimal method.\n\nWe start by showing you the illustration below so you can see what 727000 + 90% looks like, visualize what we are calculating, and see what 727000 plus 90 percent means.", null, "The dark blue in the illustration is 727000, the light blue is 90% of 727000, and the sum of the dark blue and the light blue is 727000 plus 90 percent.\n\nCalculate 727000 plus 90 percent using the number method\nFor many people, this method may be the most obvious method of calculating 727000 plus 90%, as it entails calculating 90% of 727000 and then adding that result to 727000. Here is the formula, the math, and the answer.\n\n((Number × Percent/100)) + Number\n((727000 × 90/100)) + 727000\n654300 + 727000\n= 1381300\n\nRemember, the answer in green above is the sum of the dark blue plus the light blue in our illustration.\n\nCalculate 727000 plus 90 percent using the decimal method\nHere you convert 90% to a decimal plus 1 and then multiply it by 727000. We think this is the fastest way to calculate 90 percent plus 727000. Once again, here is the formula, the math, and the answer:\n\n(1 + (Percent/100)) × Number\n(1 + (90/100)) × 727000\n1.9 × 727000\n= 1381300\n\nNumber Plus Percent\nGo here if you need to calculate any other number plus any other percent.\n\n728000 plus 90 percent\nHere is the next percent tutorial on our list that may be of interest." ]
[ null, "https://percent.info/images/plus/plus-90-percent.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.819793,"math_prob":0.99741536,"size":1529,"snap":"2021-31-2021-39","text_gpt3_token_len":396,"char_repetition_ratio":0.18819672,"word_repetition_ratio":0.05860806,"special_character_ratio":0.3407456,"punctuation_ratio":0.084745765,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9997521,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-07-31T11:05:54Z\",\"WARC-Record-ID\":\"<urn:uuid:5e1c562e-ad7b-4180-bfe1-f761c9788975>\",\"Content-Length\":\"5731\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e8d9383a-a121-4dca-bfa3-a10055aaf0cc>\",\"WARC-Concurrent-To\":\"<urn:uuid:ad8ea337-1c18-454b-a04f-1db2072cbdf9>\",\"WARC-IP-Address\":\"99.86.230.76\",\"WARC-Target-URI\":\"https://percent.info/plus/90/how-to-calculate-727000-plus-90-percent.html\",\"WARC-Payload-Digest\":\"sha1:VEP2HRRTXMHBDEEVMDNQL5YJWAFBU3U7\",\"WARC-Block-Digest\":\"sha1:FB5NI4S5IWEJ6AMLO7CNPOKT3NIDCZBR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046154089.6_warc_CC-MAIN-20210731105716-20210731135716-00383.warc.gz\"}"}
https://puredocs.bitbucket.io/pure.html
[ "# The Pure Manual¶\n\nVersion 0.66, March 04, 2017\n\nAlbert Gräf <[email protected]>\n\nCopyright (c) 2009-2017 by Albert Gräf. This document is available under the GNU Free Documentation License. Also see the Copying section for licensing information of the software.\n\nThis manual describes the Pure programming language and how to invoke the Pure interpreter program. To read the manual inside the interpreter, just type help at the command prompt. See the Online Help section for details.\n\nThere is a companion to this manual, the Pure Library Manual which contains the description of the standard library operations. More information about Pure and the latest sources can be found under the following URLs:\n\nInformation about how to install Pure can be found in the document Installing Pure (and LLVM).\n\n## Introduction¶\n\nPure is a functional programming language based on term rewriting. This means that all your programs are essentially just collections of symbolic equations which the interpreter uses to reduce expressions to their simplest (“normal”) form. This makes for a rather powerful and flexible programming model featuring dynamic typing and general polymorphism. In addition, Pure programs are compiled to efficient native code on the fly, using the LLVM compiler framework, so programs are executed reasonably fast and interfacing to C is very easy. If you have the necessary 3rd party compilers installed then you can even inline functions written in C and a number of other languages and call them just like any other Pure function. The ease with which you can interface to 3rd party software makes Pure useful for a wide range of applications from symbolic algebra and scientific programming to database, web and multimedia applications.\n\nThe Pure language is implemented by the Pure interpreter program. Just like other programming language interpreters, the Pure interpreter provides an interactive environment in which you can type definitions and expressions, which are executed as you type them at the interpreter’s command prompt. However, despite its name the Pure interpreter never really “interprets” any Pure code. Rather, it acts as a frontend to the Pure compiler, which takes care of incrementally compiling Pure code to native (machine) code. This has the benefit that the compiled code runs much faster than the usual kinds of “bytecode” that you find in traditional programming language interpreters.\n\nYou can use the interpreter interactively as a sophisticated kind of “desktop calculator” program. Simply run the program from the shell as follows:\n\n```\\$ pure\n\n__ \\ | | __| _ \\ Pure 0.66 (x86_64-unknown-linux-gnu)\n| | | | | __/ Copyright (c) 2008-2017 by Albert Graef\n.__/ \\__,_|_| \\___| (Type 'help' for help, 'help copying'\n\n>\n```\n\nThe interpreter prints its sign-on message and leaves you at its “> ” command prompt, where you can start typing definitions and expressions to be evaluated:\n\n```> 17/12+23;\n24.4166666666667\n> fact n = if n>0 then n*fact (n-1) else 1;\n> map fact (1..10);\n[1,2,6,24,120,720,5040,40320,362880,3628800]\n```\n\nTyping the quit command or the end-of-file character (Ctrl-d on Unix systems) at the beginning of the command line exits the interpreter and takes you back to the shell.\n\nThe interpreter can actually be invoked in a number of different ways. Instead of typing definitions and evaluating expressions in an interactive fashion as shown above, you can also put the same code in an (ASCII or UTF-8) text file called a Pure program or script which can then be executed by the interpreter in “batch mode”, or compiled to a standalone executable which can be run directly from the command line. As an aid for writing script files, a bunch of syntax highlighting files and programming modes for various popular text editors are included in the Pure sources.\n\nMore information about invoking the Pure interpreter can be found in the Invoking Pure section below. This is followed by a description of the Pure language in Pure Overview and subsequent sections, including an extensive Examples section which can serve as a mini-tutorial on Pure. The interactive facilities of the Pure interpreter are discussed in the Interactive Usage section, while the Batch Compilation section explains how to translate Pure programs to native executables and a number of other object file formats. The Caveats and Notes section discusses useful tips and tricks, as well as various pitfalls and how to avoid them. The manual concludes with some authorship and licensing information and pointers to related software.\n\nThis manual is not intended as a general introduction to functional programming, so at least some familiarity with this programming style is assumed. If Pure is your first functional language then you might want to look at the Functional Programming wikipedia article to see what it is all about and find pointers to current literature on the subject. In any case we hope that you’ll find Pure helpful in exploring functional programming, as it is fairly easy to learn but a very powerful language.\n\nAs already mentioned, Pure uses term rewriting as its underlying computational model, which goes well beyond functional programming in some ways. Term rewriting has long been used in computer algebra systems, and Michael O’Donnell pioneered its use as a programming language already in the 1980s. But until recently implementations have not really been efficient enough to be useful as general-purpose programming languages; Pure strives to change that. A good introduction to the theory of the term rewriting calculus and its applications is the book by Baader and Nipkow.\n\n### Typographical Conventions¶\n\nProgram examples are always set in typewriter font. Here’s how a typical code sample may look like:\n\n```fact n = if n>0 then n*fact(n-1) else 1;\n```\n\nThese can either be saved to a file and then loaded into the interpreter, or you can also just type them directly in the interpreter. If some lines start with the interpreter prompt “> ”, this indicates an example interaction with the interpreter. Everything following the prompt (excluding the “> ” itself) is meant to be typed exactly as written. Lines lacking the “> ” prefix show results printed by the interpreter. Example:\n\n```> fact n = if n>0 then n*fact(n-1) else 1;\n> map fact (1..10);\n[1,2,6,24,120,720,5040,40320,362880,3628800]\n```\n\nSimilarly, lines starting with the “\\$ ” prompt indicate shell interactions. For instance,\n\n```\\$ pure\n```\n\nindicates that you should type the command pure on your system’s command line.\n\nThe grammar notation in this manual uses an extended form of BNF (Backus-Naur form), which looks as follows:\n\n```expression ::= \"{\" expr_list (\";\" expr_list)* [\";\"] \"}\"\nexpr_list ::= expression (',' expression)*\n```\n\nParentheses are used to group syntactical elements, while brackets denote optional elements. We also use the regular expression operators * and + to denote repetitions (as usual, * denotes zero or more, + one or more repetitions of the preceding element). Terminals (literal elements such as keywords and delimiters) are enclosed in double or single quotes.\n\nThese EBNF rules are used for both lexical and syntactical elements, but note that the former are concerned with entities formed from single characters and thus tokens are meant to be typed exactly as written, whereas the latter deal with larger syntactical structures where whitespace between tokens is generally insignificant.\n\n## Invoking Pure¶\n\nThe Pure interpreter can be invoked from the shell in one of two different ways:\n\n```pure [options ...] [-x] script [args ...]\npure [options ...] [-b|-c|-i] [script ...] [-- args ...]\n```\n\nUse pure -h to get help about the command line options. Just the pure command without any command line parameters invokes the interpreter in interactive mode, see Running Interactively below for details.\n\nThe first form above is used if the interpreter is invoked on exactly one script file, which is loaded and executed, after which the interpreter exits. Any arguments following the script name are not processed by the interpreter, but are passed to the executing script by means of the argv variable. This is also known as script mode, and is commonly used if a script is to be run as a standalone program. Script mode can also be indicated explicitly with the -x option, but this is optional unless you want to combine it with one of the -b, -c and -i options discussed below. If the -x option is present, it must be followed by the name of a script to be executed. Also note that in script mode, all interpreter options need to be specified before the script name; all remaining arguments (including options) are simply passed to the executing script.\n\nThe second form is used if there may be any number of scripts which are to be executed in batch mode (-b, -c) or interactive mode (-i), respectively. In this case all options on the command line will be processed by the interpreter, up to the -- option (if any), which stops option processing and indicates that the remaining arguments should be passed in the argv variable. Any non-option arguments (before the -- option, if any) are interpreted as scripts which should be loaded by the interpreter. If no scripts are specified, or if the -i option is present, the interpreter starts in interactive mode (after loading the given scripts, if any). Otherwise, if one of the -b and -c options is specified, the given scripts are run in batch mode, after which the interpreter exits. (In the case of -c, the interpreter then also dumps the program as a native executable, performing batch compilation, see Compiling Scripts below.)\n\nBatch mode is also entered if the interpreter is invoked with one of the --ctags and --etags options. However, in this case the given scripts are not executed at all, but only parsed in order to produce a vi or emacs tags file, see Tagging Scripts below.\n\nHere are some common ways to invoke the interpreter:\n\npure\nRuns the interpreter interactively, without any script. Only the prelude gets loaded.\npure -g\nRuns the interpreter interactively, with debugging support.\npure -b script ...\nRuns the given scripts in batch mode.\npure -i script ...\nRuns the given scripts in batch mode as above, but then enters the interactive command loop. (Add -g to also get debugging support, and -q to suppress the sign-on message.)\npure script [arg ...]\nRuns the given script with the given parameters. The script name and command line arguments are available in the global argv variable.\npure -c script [-o prog]\nBatch compilation: Runs the given script, compiling it to a native executable prog (a.out by default).\npure --etags script ... [-T TAGS]\nParses the given scripts and produces an emacs tags file. (Use --ctags to create a vi tags file instead. In either case, the actual name of the tags file can be set with the -T option.)\n\nThe following commands provide helpful information about the interpreter, after which the interpreter exits immediately:\n\npure --help\nPrint a short help message describing the command line syntax and available options. This can also be abbreviated as pure -h.\npure --version\nPrint version information.\n\nDepending on your local setup, there may be additional ways to run the Pure interpreter. In particular, if you have Emacs Pure mode installed, then you can just open a script in Emacs and run it with the C-c C-k keyboard command. For Emacs aficionados, this is probably the most convenient way to execute a Pure script interactively in the interpreter. Pure mode actually turns Emacs into a full IDE (integrated development environment) for Pure, which offers a lot of convenient features such as syntax highlighting, automatic indentation, online help and different ways to interact with the Pure interpreter.\n\n### Options¶\n\nThe interpreter accepts various options which are described in more detail below.\n\n-b\n\nBatch mode (execute the given scripts and exit).\n\n-c\n\nBatch compilation (compile the given scripts to a native binary).\n\n--ctags\n--etags\n\nCreate a tags file in ctags (vi) or etags (emacs) format.\n\n--disable optname\n\nDisable source option (conditional compilation).\n\n--eager-jit\n\nEnable eager JIT compilation. This requires LLVM 2.7 or later, otherwise this flag will be ignored.\n\n--enable optname\n\nEnable source option (conditional compilation).\n\n--escape char\n\nInteractive commands are prefixed with the specified character. Permitted prefixes are: !\\$%&*,:<>@\\|.\n\n-fPIC\n-fpic\n\nCreate position-independent code (batch compilation).\n\n-g\n\nEnable symbolic debugging.\n\n-h\n--help\n\nPrint help message and exit.\n\n-i\n\nInteractive mode (read commands from stdin after sourcing the given scripts, if any).\n\n-I directory\n\nAdd a directory to be searched for included source scripts.\n\n-L directory\n\nAdd a directory to be searched for dynamic libraries.\n\n-l libname\n\nLibrary to be linked in batch compilation.\n\n-mopt=val\n\nAdd llc machine options in batch compilation.\n\n--main name\n\nName of main entry point in batch compilation.\n\n--noediting\n\nDisable command-line editing.\n\n-n\n--noprelude\n\n--norc\n\nDo not run the interactive startup files.\n\n-o filename\n\nOutput filename for batch compilation.\n\n-q\n\nQuiet startup (suppresses sign-on message in interactive mode).\n\n-T filename\n\nTags file to be written by --ctags or --etags.\n\n--texmacs\n\nRun Pure inside TeXmacs.\n\n-u\n\nDo not strip unused functions in batch compilation.\n\n-v[level]\n\nSet verbosity level.\n\n--version\n\nPrint version information and exit.\n\n-w\n\nEnable compiler warnings.\n\n-x\n\nScript mode (execute a script with the given command line arguments).\n\n--\n\nStop option processing and pass the remaining command line arguments in the argv variable.\n\nBesides these, the interpreter also understands a number of other command line switches for setting various compilation options; please see Compilation Options below for details.\n\nNote\n\nOption parsing follows the usual (Unix) conventions, but is somewhat more rigid than the GNU getopt conventions. In particular, it is not possible to combine short options, and there are no abbreviations for “long” options. Mixing options and other command line parameters is generally possible, but note that all option processing stops right after -x and -- (or the first non-option parameter in script mode), passing the remaining parameters to the executing script in the Pure argv variable.\n\nAs usual, if an option takes a required argument, the argument may be written either as a separate command line parameter immediately following the option (as in -I directory or --enable optname), or directly after the option (-Idirectory or --enable=optname; note the equals sign in the case of a long option). Options with optional arguments work in the same fashion, but in this case the argument, if present, must be written directly behind the option.\n\n### Overview of Operation¶\n\nIf any source scripts are specified on the command line, they are loaded and executed, after which the interpreter exits. Otherwise the interpreter enters the interactive read-eval-print loop, see Running Interactively below. You can also use the -i option to enter the interactive loop (continue reading from stdin) even after processing some source scripts.\n\nOptions and source files are processed in the order in which they are given on the command line. Processing of options and source files ends when either the -- or the -x option is encountered, or after the first script (non-option) argument in script mode (i.e., if none of the options -b, -i, --ctags and --etags is present). In either case, any remaining parameters are passed to the executing script by means of the global argc and argv variables, denoting the number of arguments and the list of the actual parameter strings, respectively. In script mode this also includes the script name as argv!0.\n\nScript mode is useful, in particular, to turn Pure scripts into executable programs by including a “shebang” like the following as the first line in your main script. (This trick only works with Unix shells, though.)\n\n```#!/usr/local/bin/pure\n```\n\nThe following variables are always predefined by the interpreter:\n\nvariable argc\nvariable argv\n\nThe number of extra command line arguments and the arguments themselves as a list of strings; see above. These are useful if a script is usually run non-interactively and takes its input from the command line.\n\nvariable compiling\n\nA flag indicating whether the program is executed in a batch compilation (-c option), see Compiling Scripts below.\n\nvariable version\nvariable sysinfo\n\nThe version string of the Pure interpreter and a string identifying the host system. These are useful if parts of your script depend on the particular version of the interpreter and the system it runs on. (An alternative way to deal with version and system dependencies is to use conditional compilation; see Conditional Compilation.)\n\nIf available, the prelude script prelude.pure is loaded by the interpreter prior to any other definitions, unless the -n or --noprelude option is specified. The prelude is searched for in the directory specified with the PURELIB environment variable. If the PURELIB variable is not set, a system-specific default is used. Relative pathnames of other source scripts specified on the command line are interpreted relative to the current working directory. In addition, the executed program may load other scripts and libraries via a using declaration in the source, which are searched for in a number of locations, including the directories named with the -I and -L options; see the Declarations and C Interface sections for details.\n\n### Compiling Scripts¶\n\nThe interpreter compiles scripts, as well as definitions that you enter interactively, automatically. This is done in an incremental fashion, as the code is needed, and is therefore known as JIT (just in time) compilation. Thus the interpreter never really “interprets” the source program or some intermediate representation, it just acts as a frontend to the compiler, taking care of compiling source code to native machine code before it gets executed.\n\nPure’s LLVM backend does “lazy JIT compilation” by default, meaning that each function (global or local) is compiled no sooner than it is run for the first time. With the --eager-jit option, however, it will also compile all other (global or local) functions that may be called by the compiled function. (The PURE_EAGER_JIT environment variable, when set to any value, has the same effect, so that you do not have to specify the --eager-jit option each time you run the interpreter.) Eager JIT compilation may be more efficient in some cases (since bigger chunks of compilation work can be done in one go) and less efficient in others (e.g., eager JITing may compile large chunks of code which aren’t actually called later, except in rare circumstances).\n\nNote that the eager JIT mode is only available with LLVM 2.7 or later; otherwise this option will be ignored.\n\nIt is also possible to compile your scripts to native code beforehand, using the -c batch compilation option. This option forces the interpreter to batch mode (unless -i is specified as well, which overrides -c). Any scripts specified on the command line are then executed as usual, but after execution the interpreter takes a snapshot of the program and compiles it to one of several supported output formats, LLVM assembler (.ll) or bitcode (.bc), native assembler (.s) or object (.o), or a native executable, depending on the output filename specified with -o. If the output filename ends in the .ll extension, an LLVM assembler file is created which can then be processed with the LLVM toolchain. If the output filename is just ‘-‘, the assembler file is written to standard output, which is useful if you want to pass the generated code to the LLVM tools in a pipeline. If the output filename ends in the .bc extension, an LLVM bitcode file is created instead.\n\nThe .ll and .bc formats are supported natively by the Pure interpreter, no external tools are required to generate these. If the target is an .s, .o or executable file, the Pure interpreter creates a temporary bitcode file on which it invokes the LLVM tools opt and llc to create a native assembler or object file, and then uses the C/C++ compiler to link the resulting program (if requested). You can also specify additional libraries to be linked into the executable with the -l option. If the output filename is omitted, it defaults to a.out (a.exe on Windows).\n\nThe C/C++ compiler invoked by the batch compiler is normally gcc by default, but you can change this with the CC and CXX environment variables. The LLVM tools opt and llc are usually located on the PATH or in a system-specific directory determined at installation time. It is also possible to use custom versions of these programs with the batch compiler, by placing them into the Pure library directory, as specified at installation time or by the PURELIB environment variable. (Note that this lets you use the batch compiler on systems which don’t have the LLVM toolchain installed. In fact, you could even deploy a stand-alone version of the interpreter together with the requisite LLVM tools on systems which don’t have LLVM installed at all, by linking both the Pure runtime and the opt and llc programs statically against LLVM.)\n\nThe -c option provides a convenient way to quickly turn a Pure script into a standalone executable which can be invoked directly from the shell. One advantage of compiling your script is that this eliminates the JIT compilation time and thus considerably reduces the startup time of the program. Another reason to prefer a standalone executable is that it lets you deploy the program on systems without a full Pure installation (usually only the runtime library is required on the target system). On the other hand, compiled scripts also have some limitations, mostly concerning the use of the built-in eval function. Please see the Batch Compilation section for details.\n\nThe -v64 (or -v0100) verbosity option can be used to have the interpreter print the commands it executes during compilation, see Verbosity and Debugging Options below. When creating an object file, this also prints the suggested linker command (including all the dynamic modules loaded by the script, which also have to be linked in to create a working executable), to which you only have to add the options describing the desired output file.\n\n### Tagging Scripts¶\n\nPure programs often have declarations and definitions of global symbols scattered out over many different source files. The --ctags and --etags options let you create a tags file which allows you to quickly locate these items in text editors such as vi and emacs which support this feature.\n\nIf --ctags or --etags is specified, the interpreter enters a special variation of batch mode in which it only parses source files without executing them and collects information about the locations of global symbol declarations and definitions. The collected information is then written to a tags file in the ctags or etags format used by vi and emacs, respectively. The desired name of the tags file can be specified with the -T option; it defaults to tags for --ctags and TAGS for --etags (which matches the default tags file names used by vi and emacs, respectively).\n\nThe tags file contains information about the global constant, variable, macro, function and operator symbols of all scripts specified on the command line, as well as the prelude and other scripts included via a using clause. Tagged scripts which are located in the same directory as the tags file (or, recursively, in one of its subdirectories) are specified using relative pathnames, while scripts outside this hierarchy (such as included scripts from the standard library) are denoted with absolute pathnames. This scheme makes it possible to move an entire directory together with its tags file and have the tags information still work in the new location.\n\n### Running Interactively¶\n\nIf the interpreter runs in interactive mode, it repeatedly prompts you for input (which may be any legal Pure code or some special interpreter commands provided for interactive usage), and prints computed results. This is also known as the read-eval-print loop and is described in much more detail in the Interactive Usage section. To exit the interpreter, just type the quit command or the end-of-file character (Ctrl-d on Unix) at the beginning of the command line.\n\nThe interpreter may also source a few additional interactive startup files immediately before entering the interactive loop, unless the --norc option is specified. First .purerc in the user’s home directory is read, then .purerc in the current working directory. These are ordinary Pure scripts which can be used to provide additional definitions for interactive usage. Finally, a .pure file in the current directory (usually containing a dump from a previous interactive session) is loaded if it is present.\n\nWhen the interpreter is in interactive mode and reads from a tty, unless the --noediting option is specified, commands are usually read using readline or some compatible replacement, providing completion for all commands listed under Interactive Usage, as well as for symbols defined in the running program. When exiting the interpreter, the command history is stored in ~/.pure_history, from where it is restored the next time you run the interpreter.\n\nThe interpreter also provides a simple source level debugger when run in interactive mode, see Debugging for details. To enable the debugger, you need to specify the -g option when invoking the interpreter. This option causes your script to run much slower, so you should only use this option if you want to run the debugger.\n\n### Verbosity and Debugging Options¶\n\nThe -v option is useful for debugging the interpreter, or if you are interested in the code your program gets compiled to. The level argument is optional; it defaults to 1. Seven different levels are implemented at this time. Only the first two levels will be useful for the average Pure programmer; the remaining levels are mostly intended for maintenance purposes.\n\n1 (0x1, 001)\ndenotes echoing of parsed definitions and expressions.\n2 (0x2, 002)\nadds special annotations concerning local bindings (de Bruijn indices, subterm paths; this can be helpful to debug tricky variable binding issues).\n4 (0x4, 004)\nadds descriptions of the matching automata for the left-hand sides of equations (you probably want to see this only when working on the guts of the interpreter).\n8 (0x8, 010)\ndumps the “real” output code (LLVM assembler, which is as close to the native machine code for your program as it gets; you definitely don’t want to see this unless you have to inspect the generated code for bugs or performance issues).\n16 (0x10, 020)\nadds debugging messages from the bison(1) parser; useful for debugging the parser.\n32 (0x20, 040)\nadds debugging messages from the flex(1) lexer; useful for debugging the lexer.\n64 (0x40, 0100)\nturns on verbose batch compilation; this is useful if you want to see exactly which commands get executed during batch compilation (-c).\n\nThese values can be or’ed together, and, for convenience, can be specified in either decimal, hexadecimal or octal. Thus 0xff or 0777 always gives you full debugging output (which isn’t likely to be used by anyone but the Pure developers). Some useful flag combinations for experts are (in octal) 007 (echo definitions along with de Bruijn indices and matching automata), 011 (definitions and assembler code), 021 (parser debugging output along with parsed definitions) and 0100 (verbose batch compilation).\n\nNote that the -v option is only applied after the prelude has been loaded. If you want to debug the prelude, use the -n option and specify the prelude.pure file explicitly on the command line. Verbose output is also suppressed for modules imported through a using clause. As a remedy, you can use the interactive show command (see the Interactive Usage section) to list definitions along with additional debugging information.\n\n### Compilation Options¶\n\nBesides the options listed above, the interpreter also understands some additional command line switches and corresponding environment variables to control various compilation options.\n\n#### Code Generation Options¶\n\nThese options take the form --opt and --noopt, respectively, where opt denotes the option name (see below for a list of supported options). By default, these options are all enabled; --noopt disables the option, --opt reenables it. In addition, for each option opt there is also a corresponding environment variable PURE_NOOPT (with the option name in uppercase) which, when set, disables the option by default. (Setting this variable to any value will do, the interpreter only checks whether the variable exists in the environment.)\n\nFor instance, the checks option controls stack and signal checks. Thus --nochecks on the command line disables the option, and setting the PURE_NOCHECKS environment variable makes this the default, in which case you can use --checks on the command line to reenable the option.\n\nEach code generation option can also be used as a pragma (compiler directive) in source code so that you can control it on a per-rule basis. The pragma must be on a line by itself, starting in column 1, and takes the following form (using --nochecks as an example):\n\n```#! --nochecks // line-oriented comment may go here\n```\n\nCurrently, the following code generation options are recognized:\n\n--checks\n--nochecks\n\nEnable or disable various extra stack and signal checks. By default, the interpreter checks for stack overflows and pending signals on entry to every function, see Stack Size and Tail Recursion and Handling of Asynchronous Signals for details. This is needed to catch these conditions in a reliable way, so we recommend to leave this enabled. However, these checks also make programs run a little slower (typically some 5%, YMMV). If performance is critical then you can disable the checks with the --nochecks option. (Even then, a minimal amount of checking will be done, usually on entry to every global function.)\n\n--const\n--noconst\n\nEnable or disable the precomputing of constant values in batch compilation (cf. Compiling Scripts). If enabled (which is the default), the values of constants in const definitions are precomputed at compile time (if possible) and then stored in the generated executable. This usually yields faster startup times but bigger executables. You can disable this option with --noconst to get smaller executables at the expense of slower startup times. Please see the Batch Compilation section for an example.\n\n--fold\n--nofold\n\nEnable or disable constant folding in the compiler frontend. This means that constant expressions involving int and double values and the usual arithmetic and logical operations on these are precomputed at compile time. (This is mostly for cosmetic purposes; the LLVM backend will perform this optimization anyway when generating machine code.) For instance:\n\n```> foo x = 2*3*x;\n> show foo\nfoo x = 6*x;\n```\n\nDisabling constant folding in the frontend causes constant expressions to be shown as you entered them:\n\n```> #! --nofold\n> bar x = 2*3*x;\n> show bar\nbar x = 2*3*x;\n```\n\nThe same option also determines the handling of type aliases at compile time, see Type Rules.\n\n--symbolic\n--nosymbolic\n\nEnable or disable symbolic mode. Pure’s default behaviour is to evaluate function applications in a symbolic fashion using the equations (rewriting rules) supplied by the programmer, cf. Definitions and Expression Evaluation. This means that it is not normally an error if there is no equation which applies to the given function application to be evaluated; rather, the unevaluated function becomes a “constructor symbol” which is applied to the provided arguments to form a literal (“normal form”) term which stands for itself. E.g., here’s what you get if you try to add an (undefined) symbol and a number:\n\n```> a+1;\na+1\n```\n\nThe --nosymbolic option changes this behaviour so that if a global function has any defining equations, then an attempt to invoke the function on a combination of arguments for which there is no applicable equation, raises an exception. So if the interpreter is invoked with --nosymbolic then you’ll see this instead:\n\n```> a+1;\n<stdin>, line 1: unhandled exception 'failed_match' while evaluating 'a+1'\n```\n\nThis behaviour is more in line with traditional languages where it is an error if a “defined function” cannot be evaluated in case of argument mismatch. It makes it easier to spot argument mismatch errors which might well go unnoticed if a program is executed in Pure’s default symbolic mode. However, it also makes it impossible to perform symbolic expression evaluations which is one of the key features of term rewriting as a programming language.\n\nMuch of Pure’s library and many programming examples assume Pure’s default mode of symbolic evaluation, so that it is generally not advisable to run the interpreter with a global --nosymbolic option, except maybe for debugging purposes. More commonly --nosymbolic is used as a pragma in source code where it only applies to a specific collection of function definitions. In addition, there’s a --defined pragma which enables you to mark individual functions as “defined functions”, see below.\n\n--tc\n--notc\n\nEnable or disable tail call optimization (TCO). TCO is needed to make tail-recursive functions execute in constant stack space, so we recommend to leave this enabled. However, at the time of this writing LLVM’s TCO support is still bug-ridden on some platforms, so the --notc option allows you to disable it. (Note that TCO can also be disabled when compiling the Pure interpreter, in which case these options have no effect; see the installation instructions for details.)\n\nNote\n\nAll of the options above also have a corresponding “option symbol” so that they can be queried and set using the facilities described under Conditional Compilation below. (The symbol is just the name of the option, e.g., checks for the --checks, --nochecks option and pragma.)\n\nBesides these, there are the following special pragmas affecting the evaluation of some global function or macro, which is specified in the pragma. These pragmas can only be used in source code, they cannot be controlled using command line options or environment variables. Note that the given symbol fun may in fact be an arbitrary symbol (not just an identifier), so that these pragmas can also be applied to special operator symbols (cf. Lexical Matters). Also note that each of these pragmas also implicitly declares the symbol, so if a symbol needs any special attributes then it must be declared before any pragmas involving it (cf. Symbol Declarations).\n\n--eager fun\n\nInstruct the interpreter to JIT-compile the given function eagerly. This means that native code will be created for the function, as well as all other (global or local) functions that may be called by the compiled function, as soon as the function gets recompiled. This avoids the hiccups you get when a function is compiled on the fly if it is run for the first time, which is particularly useful for functions which are to be run in realtime (typically in multimedia applications). Please note that, in difference to the --eager-jit option, this feature is available for all LLVM versions (it doesn’t require LLVM 2.7 or later).\n\n--required fun\n\nInform the batch compiler (cf. Compiling Scripts) that the given function symbol fun should never be stripped from the program. This is useful, e.g., if a function is never called explicitly but only through eval. Adding a --required pragma for the function then makes sure that the function is always linked into the program. Please see the Batch Compilation section for an example.\n\n--defined fun\n--nodefined fun\n\nThese pragmas change the behaviour of global functions defined in a Pure program. The --defined pragma marks the given function or operator symbol as a “defined function” so that an exception is raised if the function is applied to a combination of arguments for which there is no applicable equation. This works similarly to the --nosymbolic pragma (see above), but allows you to mark individual functions as “defined”. For instance:\n\n```> #! --defined +\n> a+1;\n<stdin>, line 2: unhandled exception 'failed_match' while evaluating 'a+1'\n```\n\nThe --defined status of a function can be changed at any time (causing the function to be recompiled on the fly if necessary), and the --nodefined pragma restores the default behaviour of returning a normal form upon failure:\n\n```> #! --nodefined +\n> a+1;\na+1\n```\n\nMore information and examples for common uses of the --defined and --nosymbolic pragmas can be found under Defined Functions in the Caveats and Notes section.\n\n--quoteargs fun\n\nThis pragma tells the macro evaluator (cf. Macros) that the given macro should receive its arguments unevaluated, i.e., in quoted form. This is described in more detail in the Built-in Macros and Special Expressions section.\n\n#### Conditional Compilation¶\n\nAs of version 0.49, Pure also provides a rudimentary facility for denoting optional and alternative code paths. This is supposed to cover the most common cases where conditional compilation is needed. (For more elaborate needs you can always use real Pure code which enables you to configure your program at runtime using, e.g., the eval function.)\n\nPure’s conditional compilation pragmas are based on the notion of user-defined symbols (which can be really any text that does not contain whitespace or any of the shell wildcard characters *?[]) called compilation options. By default, all options are undefined and enabled. An option becomes defined as soon as it is set explicitly, either with an environment variable or one of the --enable and --disable pragmas, see below.\n\nYou can define the value of an option by setting a corresponding environment variable PURE_OPTION_OPT, where OPT is the option symbol in uppercase. The value of the environment variable should either be 0 (disabled) or 1 (enabled).\n\nOptions can be enabled and disabled in Pure scripts with the following pragmas, which are also available as command line options when invoking the Pure interpreter:\n\n--enable option\n--disable option\n\nEnable or disable the given option, respectively. Note that an option specified in the environment is overridden by a value specified with these options on the command line, which in turn is overridden by a corresponding pragma in source code.\n\nThe actual conditional compilation pragmas work in pretty much the same fashion as the C preprocessor directives #if, #ifdef etc. (except that, as already mentioned, an option is always enabled if it is undefined).\n\n--ifdef option\n--ifndef option\n\nBegins a code section which should be included in the program if the given option is defined or undefined, respectively.\n\n--if option\n--ifnot option\n\nBegins a code section which should be included in the program if the given option is enabled or disabled, respectively.\n\n--else\n\nBegins an alternative code section which is included in the program if the corresponding --ifdef, --ifndef, --if or --ifnot section was excluded, and vice versa.\n\n--endif\n\nEnds a conditional code section.\n\nConditional code sections may be nested to an arbitrary depth. Each --ifdef, --ifndef, --if or --ifnot pragma must be followed by a matching --endif. The --else section is optional; if present, it applies to the most recent --ifdef, --ifndef, --if or --ifnot section not terminated by a matching --endif. Unmatched conditional pragmas warrant an error message by the compiler.\n\nConditional code is handled at the level of the lexical analyzer. Excluded code sections are treated like comments, i.e., the parser never gets to see them.\n\nThe --ifdef and --ifndef pragmas are typically used to change the default of an option without clobbering defaults set by the user through an environment variable or a command line option. For instance:\n\n```#! --ifndef opt\n#! --disable opt\n#! --endif\n```\n\nHere’s a (rather contrived) example which shows all these pragmas in action. You may want to type this in the interpreter to verify that the code sections are indeed included and excluded from the Pure program as indicated:\n\n```// disable the 'bar' option\n#! --disable bar\n\n#! --ifdef foo\n1/2; // excluded\n#! --endif\n#! --ifndef bar\n1/3; // excluded\n#! --endif\n\n#! --if foo\nfoo x = x+1; // included\n#! --if bar\nbar x = x-1; // excluded\n#! --else\nbar x = x/2; // included\n#! --endif // bar\n#! --endif // foo\n\n// reenable the 'bar' option\n#! --enable bar\n\n#! --if bar\nbar 99; // included\n#! --endif // bar\n\n#! --ifnot foo\nbaz x = 2*x; // excluded\n#! --endif // not foo\n```\n\nA few options are always predefined as “builtins” by the interpreter. This includes all of the options described under Code Generation Options and Warning Options, so that these can also be queried with --if, --ifnot and set with --enable, --disable. For instance:\n\n```#! --ifnot checks\nputs \"This program uses deep recursion, so we enable stack checks here!\";\n#! --enable checks\n#! --endif // not checks\n\n#! --if warn\nputs \"Beware of bugs in the above code.\";\nputs \"I have only proved it correct, not tried it.\";\n#! --endif // warn\n```\n\nMoreover, the following options are provided as additional builtins which are useful for handling special compilation requirements as well as system and version dependencies.\n\n• The compiled option is enabled if a program is batch-compiled. This lets you pick alternative code paths depending on whether a script is compiled to a native executable or not. Please see the example at the end of the Batch Compilation section for details.\n\n• The interactive and debugging options are enabled if a program runs in interactive (-i) and/or debugging (-g) mode, respectively. These options are read-only; they cannot be changed with --enable, --disable. Example:\n\n```#! --if interactive\nputs \"Usage: run 'main filename'\";\n#! --else\nmain (argv!1);\n#! --endif\n```\n• The version-x.y option indicates a check against the version of the host Pure interpreter. x.y indicates the required (major/minor) version. You can also use x.y+ to indicate version x.y or later, or x.y- for version x.y or earlier. By combining these, you can pick code depending on a particular range of Pure versions, or you can reverse the test to check for anything later or earlier than a given version:\n\n```#! --if version-0.36+\n#! --if version-0.48-\n// code to be executed for Pure versions 0.36..0.48 (inclusive)\n#! --endif\n#! --endif\n\n#! --ifnot version-0.48-\n// code to be executed for Pure versions > 0.48\n#! --endif\n```\n• Last but not least, the interpreter always defines the target triplet of the host system as an option symbol. This is the same as what sysinfo returns, so you can check for a specific system like this:\n\n```#! --if x86_64-unknown-linux-gnu\n// 64 bit Linux-specific code goes here\n#! --endif\n```\n\nIt goes without saying that this method isn’t very practical if you want to check for a wide range of systems. As a remedy, the --if and --ifnot pragmas treat shell glob patterns in tests for option symbols in a special way, by matching the pattern against the host triplet to see whether the condition holds. This allows you to write a generic test, e.g., for Windows systems like this:\n\n```#! --if *-mingw32\n// Windows-specific code goes here\n#! --endif\n```\n\n#### Warning Options¶\n\nThe -w option enables some additional warnings which are useful to check your scripts for possible errors. In particular, it will report implicit declarations of function and type symbols, which might indicate undefined or mistyped symbols that need to be fixed, see Symbol Lookup and Creation for details.\n\nThis option can also be controlled on a per-rule basis by adding the following pragmas to your script:\n\n--warn\n--nowarn\n\nEnable or disable compiler warnings. The -w flag sets the default for these pragmas.\n\n--rewarn\n\nReset compiler warnings to the default, as set with the -w flag (or not).\n\nThe latter pragma is useful to enable or disable warnings in a section of code and reset it to the default afterwards:\n\n```#! --warn\n// Code with warnings goes here.\n#! --rewarn\n```\n\n(The same could also be achieved with conditional compilation, but only much more clumsily. However, note that --rewarn only provides a single level of “backup”, so nesting such sections is not supported.)\n\n### Startup Files¶\n\nThe interpreter may source various files during its startup. These are:\n\n~/.pure_history\n\nInteractive command history.\n\n~/.purerc, .purerc, .pure\n\nInteractive startup files. The latter is usually a dump from a previous interactive session.\n\nprelude.pure\n\nStandard prelude. If available, this script is loaded before any other definitions, unless -n was specified.\n\n### Environment¶\n\nVarious aspects of the interpreter can be configured through the following shell environment variables:\n\nCC\nCXX\n\nC and C++ compiler used by the Pure batch compiler (pure -c) to compile and link native executables. Defaults to gcc and g++, respectively.\n\nBROWSER\n\nIf the PURE_HELP variable is not set (see below), this specifies a colon-separated list of browsers to try for reading the online documentation. See http://catb.org/~esr/BROWSER/.\n\nPURELIB\n\nDirectory to search for library scripts, including the prelude. If PURELIB is not set, it defaults to some location specified at installation time.\n\nPURE_EAGER_JIT\n\nEnable eager JIT compilation (same as --eager-jit), see Compiling Scripts for details.\n\nPURE_ESCAPE\n\nIf set, interactive commands are prefixed with the first character in the value of this variable (same as --escape), see Interactive Usage for details.\n\nPURE_HELP\n\nCommand used to browse the Pure manual. This must be a browser capable of displaying html files. Default is w3m.\n\nPURE_INCLUDE\n\nAdditional directories (in colon-separated format) to be searched for included scripts.\n\nPURE_LIBRARY\n\nAdditional directories (in colon-separated format) to be searched for dynamic libraries.\n\nPURE_MORE\n\nShell command to be used for paging through output of the show command, when the interpreter runs in interactive mode. PURE_LESS does the same for evaluation results printed by the interpreter.\n\nPURE_PS\n\nCommand prompt used in the interactive command loop (“> ” by default).\n\nPURE_STACK\n\nMaximum stack size in kilobytes (0 = unlimited). A reasonable default is provided (currently this is always 8192K - 128K for interpreter and runtime, which should work on most modern PCs). If you’re still getting segfaults due to stack overflow then you’ll either have to reduce this value or increase the actual stack space available to programs.\n\nBesides these, the interpreter also understands a number of other environment variables for setting various compilation options (see Compilation Options above) and commands to invoke different LLVM compilers on inline code (see Inline Code).\n\n## Pure Overview¶\n\nPure is a fairly simple yet powerful language. Programs are basically collections of term rewriting rules, which are used to reduce expressions to normal form in a symbolic fashion. For convenience, Pure also offers some extensions to the basic term rewriting calculus, like global variables and constants, nested scopes of local function and variable definitions, anonymous functions (lambdas), exception handling and a built-in macro facility. These are all described below and in the following sections.\n\nMost basic operations are defined in the standard prelude. This includes the usual arithmetic and logical operations, as well as the basic string, list and matrix functions. The prelude is always loaded by the interpreter, so that you can start using the interpreter as a sophisticated kind of desktop calculator right away. Other useful operations are provided through separate library modules. Some of these, like the system interface and the container data structures, are distributed with the interpreter, others are available as separate add-on packages from the Pure website. A (very) brief overview of some of the modules distributed with the Pure interpreter can be found in the Standard Library section.\n\nIn this section we first give a brief overview of the most important elements of the Pure language. After starting out with a discussion of the lexical syntax, we proceed by explaining definitions and expressions, which are the major ingredients of Pure programs. After studying this section you should be able to write simple Pure programs. Subsequent sections then describe the concepts and notions introduced here in much greater detail and also cover the more advanced language elements which we only gloss over here.\n\n### Lexical Matters¶\n\nPure is a free-format language, i.e., whitespace is insignificant (unless it is used to delimit other symbols). Thus, in contrast to “layout-based” languages like Haskell, you must use the proper delimiters (;) and keywords (end) to terminate definitions and block structures. In particular, definitions and expressions at the toplevel have to be terminated with a semicolon, even if you’re typing them interactively in the interpreter.\n\nComments use the same syntax as in C++: // for line-oriented, and /* ... */ for multiline comments. The latter must not be nested. Lines beginning with #! are treated as comments, too; as already discussed above, on Unix-like systems this allows you to add a “shebang” to your main script in order to turn it into an executable program.\n\nA few ASCII symbols are reserved for special uses, namely the semicolon, the “at” symbol @, the equals sign =, the backslash \\, the Unix pipe symbol |, parentheses (), brackets [] and curly braces {}. (Among these, only the semicolon is a “hard delimiter” which is always a lexeme by itself; the other symbols can be used inside operator symbols.) Moreover, there are some keywords which cannot be used as identifiers:\n\n```case const def else end extern if\ninfix infixl infixr interface let namespace nonfix\nof otherwise outfix postfix prefix private public\nthen type using when with\n```\n\nPure fully supports the Unicode character set or, more precisely, UTF-8. This is an ASCII extension capable of representing all Unicode characters, which provides you with thousands of characters from most of the languages of the world, as well as an abundance of special symbols for almost any purpose. If your text editor supports the UTF-8 encoding (most editors do nowadays), you can use all Unicode characters in your Pure programs, not only inside strings, but also for denoting identifiers and special operator symbols.\n\nThe customary notations for identifiers, numbers and strings are all provided. In addition, Pure also allows you to define your own operator symbols. Identifiers and other symbols are described by the following grammar rules in EBNF format:\n\n```symbol ::= identifier | special\nidentifier ::= letter (letter | digit)*\nspecial ::= punct+\nletter ::= \"A\"|...|\"Z\"|\"a\"|...|\"z\"|\"_\"|...\ndigit ::= \"0\"|...|\"9\"\npunct ::= \"!\"|\"#\"|\"\\$\"|\"%\"|\"&\"|...\n```\n\nPure uses the following rules to distinguish “punctuation” (which may only occur in declared operator symbols) and “letters” (identifier constituents). In addition to the punctuation symbols in the 7 bit ASCII range, the following code points in the Unicode repertoire are considered as punctuation: U+00A1 through U+00BF, U+00D7, U+00F7, and U+20D0 through U+2BFF. This comprises the special symbols in the Latin-1 repertoire, as well as the Combining Diacritical Marks for Symbols, Letterlike Symbols, Number Forms, Arrows, Mathematical Symbols, Miscellaneous Technical Symbols, Control Pictures, OCR, Enclosed Alphanumerics, Box Drawing, Blocks, Geometric Shapes, Miscellaneous Symbols, Dingbats, Miscellaneous Mathematical Symbols A, Supplemental Arrows A, Supplemental Arrows B, Miscellaneous Mathematical Symbols B, Supplemental Mathematical Operators, and Miscellaneous Symbols and Arrows. This should cover almost everything you’d ever want to use in an operator symbol. All other extended Unicode characters are effectively treated as “letters” which can be used as identifier constituents. (Charts of all Unicode symbols can be found at the Code Charts page of the Unicode Consortium.)\n\nThe following are examples of valid identifiers: foo, foo_bar, FooBar, BAR, bar99. Case is significant in identifiers, so Bar and bar are distinct identifiers, but otherwise the case of letters carries no meaning. Special symbols consist entirely of punctuation, such as ::=. These may be used as operator symbols, but have to be declared before they can be used (see Symbol Declarations).\n\nPure also has a notation for qualified symbols which carry a namespace prefix. These take the following format (note that no whitespace is permitted between the namespace prefix and the symbol):\n\n```qualified_symbol ::= [qualifier] symbol\nqualified_identifier ::= [qualifier] identifier\nqualifier ::= [identifier] \"::\" (identifier \"::\")*\n```\n\nExample: foo::bar.\n\nNumber literals come in three flavours: integers, bigints (denoted with an L suffix) and floating point numbers (indicated by the presence of the decimal point and/or a base 10 scaling factor). Integers and bigints may be written in different bases (decimal, binary, octal and hexadecimal), while floating point numbers are always denoted in decimal.\n\n```number ::= integer | integer \"L\" | float\ninteger ::= digit+\n| \"0\" (\"X\"|\"x\") hex_digit+\n| \"0\" (\"B\"|\"b\") bin_digit+\n| \"0\" oct_digit+\noct_digit ::= \"0\"|...|\"7\"\nhex_digit ::= \"0\"|...|\"9\"|\"A\"|...|\"F\"|\"a\"|...|\"f\"\nbin_digit ::= \"0\"|\"1\"\nfloat ::= digit+ [\".\" digit+] exponent\n| digit* \".\" digit+ [exponent]\nexponent ::= (\"E\"|\"e\") [\"+\"|\"-\"] digit+\n```\n\nExamples: 4711, 4711L, 1.2e-3. Numbers in different bases: 1000 (decimal), 0x3e8 (hexadecimal), 01750 (octal), 0b1111101000 (binary).\n\nString literals are arbitrary sequences of characters enclosed in double quotes, such as \"Hello, world!\".\n\n```string ::= '\"' char* '\"'\n```\n\nSpecial escape sequences may be used to denote double quotes and backslashes (\\\", \\\\), control characters (\\b, \\f, \\n, \\r, \\t, these have the same meaning as in C), and arbitrary Unicode characters given by their number or XML entity name (e.g., \\169, \\0xa9 and \\&copy; all denote the Unicode copyright character, code point U+00A9). As indicated, numeric escapes can be specified in any of the supported bases for integer literals. For disambiguating purposes, these can also be enclosed in parentheses. E.g., \"\\(123)4\" is a string consisting of the character \\123 followed by the digit 4. Strings can also be continued across line ends by escaping the line end with a backslash. The escaped line end is ignored (use \\n if you need to embed a newline in a string). For instance,\n\n```\"Hello, \\\nworld.\\n\"\n```\n\ndenotes the same string literal as\n\n```\"Hello, world.\\n\"\n```\n\n### Definitions and Expression Evaluation¶\n\nThe real meat of a Pure program is in its definitions. In Pure these generally take the form of equations which tell the interpreter how expressions are to be evaluated. For instance, the following two equations together define a function fact which computes, for each given integer n, the factorial of n:\n\n```fact 0 = 1;\nfact n::int = n*fact (n-1) if n>0;\n```\n\nThe first equation covers the case that n is zero, in which case the result is 1. The second equation handles the case of a positive integer. Note the n::int construct on the left-hand side, which means that the equation is restricted to (machine) integers n. This construct is also called a “type tag” in Pure parlance. In addition, the n>0 in the condition part of the second equation ensures that n is positive. If these conditions are met, the equation becomes applicable and we recursively compute fact (n-1) and multiply by n to obtain the result. The fact function thus computes the product of all positive integers up to n, which is indeed just how the factorial is defined in mathematics.\n\nTo give this definition a try, you can just enter it at the command prompt of the interpreter as follows:\n\n```> fact 0 = 1;\n> fact n::int = n*fact (n-1) if n>0;\n> fact 10;\n3628800\n```\n\nOn the surface, Pure is quite similar to other modern functional languages like Haskell and ML. But under the hood it is a much more dynamic language, more akin to Lisp. In particular, Pure is dynamically typed, so functions can process arguments of as many different types as you like. In fact, you can add to the definition of an existing function at any time. For instance, we can extend our example above to make the fact function work with floating point numbers, too:\n\n```> fact 0.0 = 1.0;\n> fact n::double = n*fact (n-1) if n>0;\n> fact 10.0;\n3628800.0\n```\n\nHere we employed the constant 0.0 and the double type tag to define the factorial for the case of floating point numbers. Both int and double are built-in types of the Pure language. Our earlier definition for the int case still works as well:\n\n```> fact 10;\n3628800\n```\n\nIn FP parlance, we say that a function like fact is polymorphic, because it applies to different argument types. More precisely, the kind of polymorphism at work here is ad-hoc polymorphism, because we have two distinct definitions of the same function which behave differently for different argument types.\n\nNote that in this specific case, the two definitions are in fact very similar, to the point that the right-hand sides of the definitions are almost the same. Observing these similarities, we may also define fact in a completely generic way:\n\n```> clear fact\n> fact n = 1 if n==0;\n> fact n = n*fact (n-1) if n>0;\n```\n\n(Note that before we can enter the new definition, we first need to scratch our previous definition of fact, that’s what the clear fact command does. This is necessary because, as we already saw, the interpreter would otherwise just keep adding equations to the definition of fact that we already have.)\n\nOur new definition doesn’t have any type tags on the left-hand side and will thus work with any type of numbers:\n\n```> fact 10; // int\n3628800\n> fact 30.0; // floating point\n2.65252859812191e+32\n> fact 50L; // bigint\n30414093201713378043612608166064768844377641568960512000000000000L\n```\n\nLet’s now take a look at how the equations are actually applied in the evaluation process. Conceptually, Pure employs term rewriting as its underlying model of computation, so the equations are applied as rewriting rules, reading them from left to right. An equation is applicable if its left-hand side matches the target term to be evaluated, in which case we can bind the variables in the left-hand side to the corresponding subterms in the target term. Equations are tried in the order in which they are written; as soon as the left-hand side of an equation matches (and the condition part of the equation, if any, is satisfied), it can be applied to reduce the target term to the corresponding right-hand side.\n\nFor instance, let’s take a look at the target term fact 3. This matches both equations of our generic definition of fact from above, with n bound to 3. But the condition 3==0 of the first equation fails, so we come to consider the second equation, whose condition 3>0 holds. Thus we can perform the reduction fact 3 ==> 3*fact (3-1) and then evaluate the new target term 3*fact (3-1) recursively.\n\nAt this point, we have to decide which of the several subterms we should reduce first. This is also called the reduction strategy and there are different ways to go about it. For instance, we might follow the customary “call-by-value” strategy where the arguments of a function application are evaluated recursively before the function gets applied to it, and this is also what Pure normally does. More precisely, expressions are evaluated using the “leftmost-innermost” reduction strategy where the arguments are considered from left to right.\n\nSo this means that on the right-hand side of the second equation, first n-1 (being the argument of fact) is evaluated, then fact (n-1) (which is an argument to the * operator), and finally fact (n-1) is multiplied by n to give the value of fact n. Thus the evaluation of fact 3 actually proceeds as follows (abbreviating reductions for the built-in arithmetic operations):\n\n```fact 3 => 3*fact 2 => 3*2*fact 1 => 3*2*1*fact 0 => 3*2*1*1 => 6.\n```\n\nWe mention in passing here that Pure also has a few built-in “special forms” which take some or all of their arguments unevaluated, using “call by name” argument passing. This is needed to handle some constructs such as logical operations and conditionals in an efficient manner, and it also provides a way to implement “lazy” data structures. We’ll learn about these later.\n\nOne of the convenient aspects of the rewriting model of computation is that it enables you to define a function by pattern matching on structured argument types. For instance, we might compute the sum of the elements of a list as follows:\n\n```> sum [] = 0;\n> sum (x:xs) = x+sum xs;\n```\n\nThis discriminates over the different cases for the argument value which might either be the empty list [] or a non-empty list of the from x:xs where the variables x and xs refer to the head element and the rest of the list, respectively. (The ‘:‘ infix operator is Pure’s way of writing Lisp’s “cons”; this works the same as in other modern FPLs and is discussed in much more detail later.)\n\nLet’s give it a try:\n\n```> sum (1..10);\n55\n```\n\nNote that 1..10 denotes the list of all positive integers up to 10 here, so we get the sum of the numbers 1 thru 10 as the result, which is indeed 55. (The ‘..‘ operation is provided in Pure’s prelude, i.e., it is part of the standard library.)\n\nDue to its term rewriting semantics, Pure actually goes beyond most other functional languages in that it can do symbolic evaluations just as well as “normal” computations:\n\n```> square x = x*x;\n> square 4;\n16\n> square (a+b);\n(a+b)*(a+b)\n```\n\nIn fact, leaving aside the built-in support for some common data structures such as numbers and strings, all the Pure interpreter really does is evaluate expressions in a symbolic fashion, rewriting expressions using the equations supplied by the programmer, until no more equations are applicable. The result of this process is called a normal form which represents the “value” of the original expression. Moreover, there’s no distinction between “defined” and “constructor” function symbols in Pure, so any function symbol or operator can be used anywhere on the left-hand side of an equation, and may act as a constructor symbol if it happens to occur in a normal form term. This enables you to work with algebraic rules like associativity and distributivity in a direct fashion:\n\n```> (x+y)*z = x*z+y*z; x*(y+z) = x*y+x*z;\n> x*(y*z) = (x*y)*z; x+(y+z) = (x+y)+z;\n> square (a+b);\na*a+a*b+b*a+b*b\n```\n\nThe above isn’t possible in languages like Haskell and ML which always enforce that only “pure” constructor symbols (without any defining equations) may occur as a subterm on the left-hand side of a definition; this is also known as the constructor discipline. Thus equational definitions like the above are forbidden in these languages. Pure doesn’t enforce the constructor discipline, so it doesn’t keep you from writing such symbolic rules if you need them.\n\nAnother way of looking at this is that Pure allows you to have constructor equations. For instance, the following equation makes lists automatically stay sorted:\n\n```> x:y:xs = y:x:xs if x>y;\n> [13,7,9,7,1]+[1,9,7,5];\n[1,1,5,7,7,7,9,9,13]\n```\n\nThis isn’t possible in Haskell and ML either because it violates the constructor discipline; since ‘:‘ is a constructor it can’t simultaneously be a defined function in these languages. Pure gives you much more freedom there.\n\nThis symbolic mode of evaluation is rather unusual outside of the realm of symbolic algebra systems, but it provides the programmer with a very flexible model of computation and is one of Pure’s most distinguishing features. In some cases, however, the unevaluated normal forms may also become a nuisance since they may obscure possible programming errors. Therefore Pure provides special --nosymbolic and --defined pragmas (cf. Code Generation Options) which force functions to be treated as defined functions, so that they become more like functions in traditional untyped languages such as Lisp and Python which raise an exception under such conditions. This is described in more detail under Defined Functions in the Caveats and Notes section.\n\n#### Variables in Equations¶\n\nTaking another look at the examples above, you might wonder how the Pure interpreter figures out what the parameters (a.k.a. “variables”) in an equation are. This is quite obvious in rules involving just variables and special operator symbols, such as (x+y)*z = x*z+y*z. However, what about an equation like foo (foo bar) = bar? Since most of the time we don’t declare any symbols in Pure, how does the interpreter know that foo is a literal function symbol here, while bar is a variable?\n\nThe answer is that the interpreter considers the different positions in the left-hand side expression of an equation. Basically, a Pure expression is just a tree formed by applying expressions to other expressions, with the atomic subexpressions like numbers and symbols at the leaves of the tree. (This is true even for infix expressions like x+y, since in Pure these are always equivalent to a function application of the form (+) x y which has the atomic subterms (+), x and y at its leaves.)\n\nNow the interpreter divides the leaves of the expression tree into “head” (or “function”) and “parameter” (or “variable”) positions based on which leaves are leftmost in a function application or not. Thus, in an expression like f x y z, f is in the head or function position, while x, y and z are in parameter or variable positions. (Note that in an infix expression like x+y, (+) is the head symbol, not x, as the expression is really parsed as (+) x y, see above.)\n\nIdentifiers in head positions are taken as literal function symbols by the interpreter, while identifiers in variable positions denote, well, variables. We also refer to this convention as the head = function rule. It is quite intuitive and lets us get away without declaring the variables in equations. (There are some corner cases not covered here, however. In particular, Pure allows you to declare special “nonfix” symbols, if you need a symbol to be recognized as a literal even if it occurs in a variable position. This is done by means of a nonfix declaration, see Symbol Declarations for details.)\n\n### Expression Syntax¶\n\nLike in other functional languages, expressions are the central ingredient of all Pure programs. All computation performed by a Pure program consists in the evaluation of expressions, and expressions also form the building blocks of the equational rules which are used to define the constants, variables, functions and macros of a Pure program.\n\nTypical examples of the different expression types are summarized in the following table. Note that lambdas bind most weakly, followed by the special case, when and with constructs, followed by conditional expressions (if-then-else), followed by the simple expressions. Operators are a part of the simple expression syntax, and are parsed according to their declared precedences and associativities (cf. Symbol Declarations). Function application binds stronger than all operators. Parentheses can be used to group expressions and override default precedences as usual.\n\nType Example Description\nBlock \\x y->2*x-y anonymous function (lambda)\ncase f u of x,y = x+y end case expression\nx+y when x,y = f u end local variable definition\nf u with f (x,y) = x+y end local function definition\nConditional if x>0 then x else -x conditional expression\nSimple x+y, -x, x mod y operator application\nsin x, max a b function application\nPrimary 4711, 4711L, 1.2e-3 number\n\"Hello, world!\\n\" string\nfoo, x, (+) function or variable symbol\n[1,2,3], (1,2,3) list and tuple\n{1,2;3,4} matrix\n[x,-y | x=1..n; y=1..m; x<y] list comprehension\n{i==j | i=1..n; j=1..m} matrix comprehension\n\nThe formal syntax of expressions is as follows. (Note that the rule and simple_rule elements are part of the definition syntax, which is explained in the Rule Syntax section.)\n\n```expr ::= \"\\\" prim_expr+ \"->\" expr\n| \"case\" expr \"of\" rules \"end\"\n| expr \"when\" simple_rules \"end\"\n| expr \"with\" rules \"end\"\n| \"if\" expr \"then\" expr \"else\" expr\n| simple_expr\nsimple_expr ::= simple_expr op simple_expr\n| op simple_expr\n| simple_expr op\n| application\napplication ::= application prim_expr\n| prim_expr\nprim_expr ::= qualified_symbol\n| number\n| string\n| \"(\" op \")\"\n| \"(\" left_op right_op \")\"\n| \"(\" simple_expr op \")\"\n| \"(\" op simple_expr \")\"\n| \"(\" expr \")\"\n| left_op expr right_op\n| \"[\" exprs \"]\"\n| \"{\" exprs (\";\" exprs)* [\";\"] \"}\"\n| \"[\" expr \"|\" simple_rules \"]\"\n| \"{\" expr \"|\" simple_rules \"}\"\nexprs ::= expr (\",\" expr)*\nop ::= qualified_symbol\nleft_op ::= qualified_symbol\nright_op ::= qualified_symbol\nrules ::= rule (\";\" rule)* [\";\"]\nsimple_rules ::= simple_rule (\";\" simple_rule)* [\";\"]\n```\n\n#### Primary Expressions¶\n\nThe Pure language provides built-in support for machine integers (32 bit), bigints (implemented using GMP), floating point values (double precision IEEE 754) and character strings (UTF-8 encoded). These can all be denoted using the corresponding literals described in Lexical Matters. Truth values are encoded as machine integers; as you might expect, zero denotes false and any non-zero value true, and the prelude also provides symbolic constants false and true to denote these. Pure also supports generic C pointers, but these don’t have a syntactic representation in Pure, except that the predefined constant NULL may be used to denote a generic null pointer; other pointer values need to be created with external C functions.\n\nTogether, these atomic types of expressions make up most of Pure’s primary expression syntax. Pure also provides built-in support for some types of “compound primaries” (lists, tuples and matrices). We also list these here since they are typically denoted in some kind of bracketed form, even though some related non-primary expression types such as x:y or x,y really belong to the simple expressions.\n\nNumbers: 4711, 4711L, 1.2e-3\n\nThe usual C notations for integers (decimal: 1000, hexadecimal: 0x3e8, octal: 01750) and floating point values are all provided. Integers can also be denoted in base 2 by using the 0b or 0B prefix: 0b1111101000. Integer constants that are too large to fit into machine integers are promoted to bigints automatically. Moreover, integer literals immediately followed by the uppercase letter L are always interpreted as bigint constants, even if they fit into machine integers. This notation is also used when printing bigint constants, to distinguish them from machine integers.\n\nStrings: \"Hello, world!\\n\"\n\nString constants are double-quoted and terminated with a null character, like in C. In contrast to C, strings are always encoded in UTF-8, and character escapes in Pure strings have a more flexible syntax (borrowed from the author’s Q language) which provides notations to specify any Unicode character. Please refer to Lexical Matters for details.\n\nFunction and variable symbols: foo, foo_bar, BAR, foo::bar\n\nThese consist of the usual sequence of letters (including the underscore) and digits, starting with a letter. Case is significant, thus foo, Foo and FOO are distinct identifiers. The ‘_‘ symbol, when occurring on the left-hand side of an equation, is special; it denotes the anonymous variable which matches any value without actually binding a variable. Identifiers can also be prefixed with a namespace identifier, like in foo::bar. (This requires that the given namespace has already been created, as explained under Namespaces in the Declarations section.)\n\nOperator symbols: +, ==, not\n\nFor convenience, Pure also provides you with a limited means to extend the syntax of the language with special operator symbols by means of a corresponding fixity declaration, as discussed in section Symbol Declarations. Besides the usual infix, prefix and postfix operators, Pure also provides outfix (bracket) and nonfix (nullary operator) symbols. (Nonfix symbols actually work more or less like ordinary identifiers, but the nonfix attribute tells the compiler that when such a symbol occurs on the left-hand side of an equation, it is always to be interpreted as a literal, cf. The “Head = Function” Rule.)\n\nOperator (and nonfix) symbols may take the form of an identifier or a sequence of punctuation characters, which may optionally be qualified with a namespace prefix. These symbols must always be declared before use. Once declared, they are always special, and can’t be used as ordinary identifiers any more. However, like in Haskell, by enclosing an operator in parentheses, such as (+) or (not), you can turn it into an ordinary function symbol.\n\nLists: [x,y,z], x:xs\n\nPure’s basic list syntax is the same as in Haskell, thus [] is the empty list and x:xs denotes a list with head element x and tail list xs. The infix constructor symbol ‘:‘ is declared in the prelude. It associates to the right, so that x:y:z is the same as x:(y:z). The usual syntactic sugar for list values in brackets is also provided, thus [x,y,z] is exactly the same as x:y:z:[]. (This kind of list value is also called a “proper” list. Pure also permits “improper” list values such as 1:2:3 with a non-list value in the tail. These aren’t of much use as ordinary list values, but are frequently used in patterns or symbolic expressions such as x:y where the tail usually is a variable.)\n\nLists can be nested to an arbitrary depth. Also note that, in contrast to Haskell, lists are not required to be homogeneous, so in general they may contain an arbitary mix of element types. E.g., [1,2.0,[x,y]] is a three-element list consisting of an integer, a floating point number and a nested list containing two symbols.\n\nPure also provides a notation for arithmetic sequences such as 1..5, which denotes the list [1,2,3,4,5]. Note the missing brackets; Pure doesn’t use any special syntax for arithmetic sequences, the ‘..‘ symbol is just an ordinary infix operator declared and defined in the prelude. Sequences with arbitrary stepsizes can be written by denoting the first two sequence elements using the ‘:‘ operator, as in 1.0:1.2..3.0. To prevent unwanted artifacts due to rounding errors, the upper bound in a floating point sequence is always rounded to the nearest grid point. Thus, e.g., 0.0:0.1..0.29 actually yields [0.0,0.1,0.2,0.3], as does 0.0:0.1..0.31.\n\nTuples: (x,y,z)\n\nPure’s tuples are a flat variant of lists which are often used as aggregate function arguments and results when no elaborate hierarchical structure is needed. They are constructed using the infix “pairing” operator ‘,‘, for which the empty tuple () acts as a neutral element (i.e., (),x is just x, as is x,()). Pairs always associate to the right, meaning that x,y,z = x,(y,z) = (x,y),z, where x,(y,z) is the normalized representation. These rules imply that tuples can’t be nested and that there are no “true” 1-tuples distinct from their single members; if you need this then you should use lists instead (cf. Splicing Tuples and Matrices).\n\nNote that the parentheses are not really part of the tuple syntax in Pure, they’re just used to group expressions. So (x,y,z) denotes just x,y,z. But since the ‘,‘ operator has a low precedence, the parentheses are often needed to include tuples in other contexts. In particular, the parentheses are required to set off tuple elements in lists and matrices. E.g., [(1,2),3,(4,5)] denotes a three element list consisting of two tuples and an integer.\n\nMathematically, Pure’s notion of tuples corresponds to a monoid with an associative binary operation ‘,‘ and neutral element (). This is different from the usual definition of tuples in mathematical logic, which are nestable and correspond to Pure’s notion of lists. So in Pure you can take your pick and use either flat tuples or nestable lists, whatever is most convenient for the problem at hand.\n\nMatrices: {1.0,2.0,3.0}, {1,2;3,4}, {cos t,-sin t;sin t,cos t}\n\nPure also offers matrices, a kind of two-dimensional arrays, as a built-in data structure which provides efficient storage and element access. These work more or less like their Octave/MATLAB equivalents, but using curly braces instead of brackets. Component values may either be individual elements (“scalars”) or submatrices which are combined to form a larger matrix, provided that all dimensions match up. Here, a scalar is any expression which doesn’t yield a matrix; these are considered to be 1x1 submatrices for the purpose of matrix construction. (Note that this “splicing” behaviour pertains to matrix construction only; nested matrix patterns are always matched literally.)\n\nThe comma arranges submatrices and scalars in columns, while the semicolon arranges them in rows. So, if both x and y are n x m matrices, then {x,y} becomes an n x 2*m matrix consisting of all the columns of x followed by all the columns of y. Likewise, {x;y} becomes a 2*n x m matrix (all the rows of x above of all rows of y). For instance, {{1;3},{2;4}} is another way to write the 2x2 matrix {1,2;3,4}. Row vectors are denoted as 1 x n matrices ({1,2,3}), column vectors as n x 1 matrices ({1;2;3}). More examples can be found in the Matrices and Vectors section.\n\nPure supports both numeric and symbolic matrices. The former are homogeneous arrays of double, complex double or (machine) int matrices, while the latter can contain any mixture of Pure expressions. Pure will pick the appropriate type for the data at hand. If a matrix contains values of different types, or Pure values which cannot be stored in a numeric matrix, then a symbolic matrix is created instead (this also includes the case of bigints, which are considered as symbolic values as far as matrix construction is concerned). Numeric matrices use an internal data layout that is fully compatible with the GNU Scientific Library (GSL), and can readily be passed to GSL routines via the C interface. (The Pure interpreter does not require GSL, however, so numeric matrices will work even if GSL is not installed.)\n\nComprehensions: [x,y | x=1..n; y=1..m; x<y], {f x | x=1..n}\n\nPure provides both list and matrix comprehensions as a convenient means to construct list and matrix values from a “template” expression and one or more “generator” and “filter” clauses. The former bind a pattern to values drawn from a list or matrix, the latter are just predicates determining which generated elements should actually be added to the result. Comprehensions are in fact just syntactic sugar for a combination of lambdas, conditional expressions and certain list and matrix operations, but they are often much easier to write.\n\nThus, for instance, [f x | x=1..n] is pretty much the same as map f (1..n), while [x | x=xs; x>0] corresponds to filter (>0) xs. However, comprehensions are considerably more general in that they allow you to draw values from different kinds of aggregates including lists, matrices and strings. Also, matrix comprehensions alternate between row and column generation so that most common mathematical abbreviations carry over quite easily. Patterns can be used on the left-hand side of generator clauses as usual, and will be matched against the actual list or matrix elements; any unmatched elements are filtered out automatically, like in Haskell.\n\nMore details and examples can be found in the Examples section; in particular, see List Comprehensions and Matrices and Vectors.\n\n#### Simple Expressions¶\n\nThe rest of Pure’s expression syntax mostly revolves around the notion of function applications. For convenience, Pure also allows you to declare pre-, post-, out- and infix operator symbols, but these are in fact just syntactic sugar for function applications; see Symbol Declarations for details. Function and operator applications are used to combine primary expressions to compound terms, also referred to as simple expressions; these are the data elements which are manipulated by Pure programs.\n\nAs in other modern FPLs, function applications are written simply as juxtaposition (i.e., in “curried” form) and associate to the left. This means that in fact all functions only take a single argument. Multi-argument functions are represented as chains of single-argument functions. For instance, in f x y = (f x) y first the function f is applied to the first argument x, yielding the function f x which in turn gets applied to the second argument y. This makes it possible to derive new functions from existing ones using partial applications which only specify some but not all arguments of a function. For instance, taking the max function from the prelude as an example, max 0 is the function which, for a given x, returns x itself if it is nonnegative and zero otherwise. This works because (max 0) x = max 0 x is the maximum of 0 and x.\n\nOne major advantage of having curried function applications is that, without any further ado, functions become first-class objects. That is, they can be passed around freely both as parameters and as function return values. Much of the power of functional programming languages stems from this feature.\n\nOperator applications are written using prefix, postfix, outfix or infix notation, as the declaration of the operator demands, but are just ordinary function applications in disguise. As already mentioned, enclosing an operator in parentheses turns it into an ordinary function symbol, thus x+y is exactly the same as (+) x y. For convenience, partial applications of infix operators can also be written using so-called operator sections. A left section takes the form (x+) which is equivalent to the partial application (+) x. A right section takes the form (+x) and is equivalent to the term flip (+) x. (This uses the flip combinator from the prelude which is defined as flip f x y = f y x.) Thus (x+) y is equivalent to x+y, while (+x) y reduces to y+x. For instance, (1/) denotes the reciprocal and (+1) the successor function. (Note that, in contrast, (-x) always denotes an application of unary minus; the section (+-x) can be used to indicate a function which subtracts x from its argument.)\n\nThe common operator symbols like +, -, *, / etc. are all declared at the beginning of the prelude, see the Pure Library Manual for a list of these. Arithmetic and relational operators mostly follow C conventions. However, since !, & and | are used for other purposes in Pure, the logical and bitwise operations, as well as the negated equality predicates are named a bit differently: ~, && and || denote logical negation, conjunction and disjunction, while the corresponding bitwise operations are named not, and and or. Moreover, following these conventions, inequality is denoted ~=. Also note that && and || are special forms which are evaluated in short-circuit mode (see Special Forms below), whereas the bitwise connectives receive their arguments using call-by-value, just like the other arithmetic operations.\n\n#### Special Expressions¶\n\nSome special notations are provided for conditional expressions as well as anonymous functions (lambdas) and local function and variable definitions. The latter are also called block expressions since they introduce local bindings of variable and function symbols which may override other global or local bindings of these symbols. This gives rise to a kind of block structure similar to Algol-like programming languages. Please check Scoping Rules below for more information about this.\n\nThe constructs described here are called “special” because, in contrast to the other forms of expressions, they cannot occur in normal form terms as first-class values (at least not literally; there is an alternative quoted representation of special expressions, however, which can be manipulated with macros and functions for meta programming purposes, cf. Built-in Macros and Special Expressions).\n\nConditional expressions: if x then y else z\n\nEvaluates to y or z depending on whether x is “true” (i.e., a nonzero integer). A failed_cond exception is raised if the condition is not an integer.\n\nLambdas: \\x -> y\n\nThese denote anonymous functions and work pretty much like in Haskell. A lambda matches its argument against the left-hand side pattern x and then evaluates the right-hand side body y with the variables in x bound to their corresponding values. Pure supports multiple-argument lambdas (e.g, \\x y -> x*y), as well as pattern-matching lambda abstractions such as \\(x,y) -> x*y. A failed_match exception is raised if the actual arguments do not match the given patterns.\n\nCase expressions: case x of u = v; ... end\n\nMatches an expression, discriminating over a number of different cases, similar to the Haskell case construct. The expression x is matched in turn against each left-hand side pattern u in the rule list, and the first pattern which matches x gives the value of the entire expression, by evaluating the corresponding right-hand side v with the variables in the pattern bound to their corresponding values. A failed_match exception is raised if the target expression doesn’t match any of the patterns.\n\nWhen expressions: x when u = v; ... end\n\nAn alternative way to bind local variables by matching a collection of subject terms against corresponding patterns, similar to Aardappel‘s when construct. A single binding x when u = v end is equivalent to the lambda expression (\\u -> x) v or the case expression case v of u = x end, so it matches v against the pattern u and evaluates x with the variables in u bound to their corresponding values (or raises a failed_match exception if v doesn’t match u). However, a when clause may contain multiple definitions, which are processed from left to right, so that later definitions may refer to the variables in earlier ones. (This is exactly the same as several nested single definitions, with the first binding being the “outermost” one.)\n\nWith expressions: x with u = v; ... end\n\nDefines local functions. Like Haskell’s where construct, but it can be used anywhere inside an expression (just like Aardappel’s where, but Pure uses the keyword with which better lines up with case and when). Several functions can be defined in a single with clause, and the definitions can be mutually recursive and consist of as many equations as you want. Local functions are applied in the same way as global ones, i.e., the argument patterns of each rule are matched against the actual function arguments and the first rule which matches has its right-hand side evaluated with the variables in the argument patterns bound to their corresponding values. If none of the rules match then the function application remains unevaluated (it becomes a normal form), so no exception is raised in this case. (This is in contrast to a lambda which otherwise is pretty much like a nameless local function defined by a single rule.)\n\nThe block constructs are similar to those available in most modern functional languages. In Pure these constructs are all implemented in terms of the basic term rewriting machinery, using lambda lifting to eliminate local functions, and the following equivalences which reduce lambdas as well as case and when expressions to special kinds of local functions or local function applications:\n\n```\\x1 ... xn -> y\n== f with f x1 ... xn = y; f _ ... _ = throw failed_match end\n\ncase x of y1 = z1; ...; yn = zn end\n== f x with f y1 = z1; ...; f yn = zn; f _ = throw failed_match end\n\nx when y = z end\n== f z with f y = x; f _ = throw failed_match end\n\nx when y1 = z1; ...; yn = zn end\n== x when yn = zn end ... when y1 = z1 end\n```\n\nNote that by convention these constructs report a failed_match exception in case of argument mismatch. So they’re treated like defined functions, which is somewhat at odds with the term rewriting semantics. This is done for convenience, however, so that the programmer doesn’t have to deal with unevaluated applications of nameless block constructs in normal form terms. The case of named local functions is considered different because it effectively represents a local rewriting system which should be treated accordingly, in order to allow for symbolic evaluation.\n\n### Special Forms¶\n\nAs already mentioned, some operations are actually implemented as special forms which process some or all of their arguments using call-by-name.\n\nif x then y else z\n\nThe conditional expression is a special form with call-by-name arguments y and z; only one of the branches is actually evaluated, depending on the value of x.\n\nx && y\nx || y\n\nThe logical connectives evaluate their operands in short-circuit mode. Thus the second operand is passed by name and will only be evaluated if the first operand fails to determine the value of the expression. For instance, x&&y immediately becomes false if x evaluates to false; otherwise y is evaluated to give the value of the expression. The built-in definitions of these operations work as if they were defined by the following equations (but note that the second operand is indeed passed by name):\n\n```x::int && y = if x then y else x;\nx::int || y = if x then x else y;\n```\n\nNote that this isn’t quite the same as in C, as the results of these operations are not normalized, i.e., they may return nonzero values other than 1 to denote “true”. (This has the advantage that these operations can be implemented tail-recursively, see Stack Size and Tail Recursion.) Thus, if you need a normalized truth value then you’ll have to make sure that either both operands are already normalized, or you’ll have to normalize the result yourself. (A quick way to turn a machine int x into a normalized truth value is to compute ~~x or x~=0.)\n\nMoreover, if the built-in definition fails because the first operand is not a machine int, then the second operand will be evaluated anyway and the resulting application becomes a normal form, which gives you the opportunity to extend these operations with your own definitions just like the other built-in operations. Note, however, that in this case the operands are effectively passed by value.\n\nx \\$\\$ y\n\nThe sequencing operator \\$\\$ evaluates its left operand, immediately throws the result away and then goes on to evaluate the right operand which gives the result of the entire expression. This operator is useful to write imperative-style code such as the following prompt-input interaction:\n\n```> using system;\n> puts \"Enter a number:\" \\$\\$ scanf \"%g\";\nEnter a number:\n21\n21.0\n```\n\nWe mention in passing here that the same effect can be achieved with a when clause, which also allows you to execute a function solely for its side-effects and just ignore the return value:\n\n```> scanf \"%g\" when puts \"Enter a number:\" end;\nEnter a number:\n21\n21.0\n```\nx &\n\nThe & operator does lazy evaluation. This is the only postfix operator defined in the standard prelude. It turns its operand into a kind of parameterless anonymous closure, deferring its evaluation. These kinds of objects are also commonly known as thunks or futures. When the value of a future is actually needed (during pattern-matching, or when the value becomes an argument of a C call), it is evaluated automatically and gets memoized, i.e., the computed result replaces the thunk so that it only has to be computed once.\n\nFutures are useful to implement all kinds of lazy data structures in Pure, in particular: lazy lists a.k.a. streams. A stream is simply a list with a thunked tail, which allows it to be infinite. The Pure prelude defines many functions for creating and manipulating these kinds of objects; for further details and examples please Lazy Evaluation and Streams in the Examples section.\n\nquote x\n' x\n\nThis special form quotes an expression, i.e., quote x (or, equivalently, 'x) returns just x itself without evaluating it. The prelude also provides a function eval which can be used to evaluate a quoted expression at a later time. For instance:\n\n```> let x = '(2*42+2^12); x;\n2*42+2^12\n> eval x;\n4180.0\n```\n\nThis enables some powerful metaprogramming techniques, which should be well familiar to Lisp programmers. However, there are some notable differences to Lisp’s quote, please see The Quote in the Examples section for details and more examples.\n\n### Toplevel¶\n\nAt the toplevel, a Pure program basically consists of rewriting rules (which are used to define functions, macros and types), constant and variable definitions, and expressions to be evaluated:\n\n```script ::= item*\nitem ::= \"let\" simple_rule \";\"\n| \"const\" simple_rule \";\"\n| \"def\" macro_rule \";\"\n| \"type\" type_rule \";\"\n| rule \";\"\n| expr \";\"\n```\n\nThese elements are discussed in more detail in the Rule Syntax section. Also, a few additional toplevel elements are part of the declaration syntax, see Declarations.\n\nlhs = rhs;\n\nRewriting rules always combine a left-hand side pattern (which must be a simple expression) and a right-hand side (which can be any kind of Pure expression described above). The same format is also used in with, when and case expressions. In toplevel rules, with and case expressions, this basic form can also be augmented with a condition if guard tacked on to the end of the rule, where guard is an integer expression which determines whether the rule is applicable. Moreover, the keyword otherwise may be used to denote an empty guard which is always true (this is syntactic sugar to point out the “default” case of a definition; the interpreter just treats this as a comment). Pure also provides some abbreviations for factoring out common left-hand or right-hand sides in collections of rules; see the Rule Syntax section for details.\n\ntype lhs = rhs;\n\nA rule starting with the keyword type defines a type predicate. This works pretty much like an ordinary rewriting rule, except that only a single right-hand side is permitted (which may also be omitted in some cases) and the left-hand side may involve at most one argument expression; see the Type Rules section for details. There’s also an alternative syntax which lets you define types in a more abstract way and have the compiler generate the type rules for you; this is described in the Interface Types section.\n\ndef lhs = rhs;\n\nA rule starting with the keyword def defines a macro function. No guards or multiple right-hand sides are permitted here. Macro rules are used to preprocess expressions on the right-hand side of other definitions at compile time, and are typically employed to implement user-defined special forms and simple kinds of optimization rules. See the Macros section below for details and examples.\n\nlet lhs = rhs;\n\nBinds every variable in the left-hand side pattern to the corresponding subterm of the right-hand side (after evaluating it). This works like a when clause, but serves to bind global variables occurring free on the right-hand side of other function and variable definitions.\n\nconst lhs = rhs;\n\nAn alternative form of let which defines constants rather than variables. (These are not to be confused with nonfix symbols which simply stand for themselves!) Like let, this construct binds the variable symbols on the left-hand side to the corresponding values on the right-hand side (after evaluation). The difference is that const symbols can only be defined once, and thus their values do not change during program execution. This also allows the compiler to apply some special optimizations such as constant folding.\n\nexpr;\n\nA singleton expression at the toplevel, terminated with a semicolon, simply causes the given value to be evaluated (and the result to be printed, when running in interactive mode).\n\n### Scoping Rules¶\n\nA few remarks about the scope of identifiers and other symbols are in order here. Special expressions introduce local scopes of functions and variables. Specifically, lambda expressions, as well as the left-hand sides of rules in case, when and with expressions, bind the variables in the patterns to their corresponding values. In addition, a with expression also binds function names to the corresponding functions defined by the rules given in the expression. In either case, these bindings are limited to the scope of the corresponding construct. Inside that scope they override other (global or local) definitions of the same symbols which may be present in the surrounding program code. This gives rise to a hierarchical block structure where each occurrence of a symbol refers to the innermost definition of that symbol visible at that point of the program.\n\nThe precise scoping rules for the different constructs are as follows:\n\n• \\x -> y: The scope of the variables bound by the pattern x is the lambda body y.\n• case x of u = v; ... end: The scope of the variables bound by the pattern u in each rule is the corresponding right-hand side v.\n• x when u = v; ... end: The scope of the variables bound by the pattern u in each rule extends over the right-hand sides of all subsequent rules and the target expression x.\n• x with u = v; ... end: The scope of the variables bound by the pattern u in each rule is the corresponding right-hand side v. In addition, the scope of the function names defined by the with clause (i.e., the head symbols of the rules) extends over the right-hand sides of all rules and the target expression x. Note that this allows local function definitions to be mutually recursive, since the right-hand side of each rule in the with clause may refer to any other function defined by the with clause.\n\nLike most modern functional languages, Pure uses lexical or static binding for local functions and variables. What this means is that the binding of a local name is completely determined at compile time by the surrounding program text, and does not change as the program is being executed. In particular, if a function returns another (anonymous or local) function, the returned function captures the environment it was created in, i.e., it becomes a (lexical) closure. For instance, the following function, when invoked with a single argument x, returns another function which adds x to its argument:\n\n```> foo x = bar with bar y = x+y end;\n> let f = foo 99; f;\nbar\n> f 10, f 20;\n109,119\n```\n\nThis works the same no matter what other bindings of x may be in effect when the closure is invoked:\n\n```> let x = 77; f 10, (f 20 when x = 88 end);\n109,119\n```\n\nIn contrast to local bindings, Pure’s toplevel environment binds global symbols dynamically, so that the bindings can be changed easily at any time during an interactive session. This is mainly a convenience for interactive usage, but works the same no matter whether the source code is entered interactively or being read from a script, in order to ensure consistent behaviour between interactive and batch mode operation.\n\nIn particular, you can easily bind a global variable to a new value by just entering a corresponding let command. For instance, contrast the following with the local bar function from above which had the x value bound in the surrounding context:\n\n```> clear x\n> bar y = x+y;\n> bar 10, bar 20;\nx+10,x+20\n> let x = 99;\n> bar 10, bar 20;\n109,119\n> let x = 77;\n> bar 10, bar 20;\n87,97\n```\n\nObserve how changing the value of the global x variable immediately affects the value computed by the global bar function. This works pretty much like global variables in imperative languages, but note that in Pure the value of a global variable can only be changed with a let command at the toplevel. Thus referential transparency is unimpaired; while the value of a global variable may change between different toplevel expressions, it will always take the same value in a single evaluation.\n\nSimilarly, you can also add new equations to an existing function at any time. The Pure interpreter will then automatically recompile the function as needed. For instance:\n\n```> fact 0 = 1;\n> fact n::int = n*fact (n-1) if n>0;\n> fact 10;\n3628800\n> fact 10.0;\nfact 10.0\n> fact 1.0 = 1.0;\n> fact n::double = n*fact (n-1) if n>1;\n> fact 10.0;\n3628800.0\n> fact 10;\n3628800\n```\n\nIn interactive mode, it is even possible to completely erase a function definition and redo it from scratch, see section Interactive Usage for details.\n\nSo, while the meaning of a local symbol never changes once its definition has been processed, toplevel definitions may well evolve while the program is being processed, and the interpreter will always use the latest definitions at a given point in the source when an expression is evaluated.\n\nNote\n\nAs already mentioned, this behaviour makes Pure much more convenient to use in an interactive setting. We should point out, however, that dynamic environments are often frowned upon by functional programming purists (for good reasons), and Pure’s dynamic toplevel certainly has its pitfalls just like any other. Specifically, even in a script file you’ll have to take care that all symbols needed in an evaluation are completely defined before entering the expression to be evaluated. Nevertheless, it is expected that most Pure programmers will use Pure interactively most of the time, and so tailoring the design to interactive usage seems justifiable in this case.\n\n## Rule Syntax¶\n\nBasically, the same rule syntax is used in all kinds of global and local definitions. However, some constructs (specifically, when, let, const, type and def) use a variation of the basic rule syntax which does away with guards and/or multiple left-hand or right-hand sides. The syntax of these elements is captured by the following grammar rules:\n\n```rule ::= pattern (\"|\" pattern)* \"=\" expr [guard]\n(\";\" \"=\" expr [guard])*\ntype_rule ::= pattern (\"|\" pattern)* [ \"=\" expr [guard] ]\nmacro_rule ::= pattern (\"|\" pattern)* \"=\" expr\nsimple_rule ::= pattern \"=\" expr | expr\npattern ::= simple_expr\nguard ::= \"if\" simple_expr\n| \"otherwise\"\n| guard \"when\" simple_rules \"end\"\n| guard \"with\" rules \"end\"\n```\n\nWhen matching against a function or macro call, or the subject term in a case expression, the rules are always considered in the order in which they are written, and the first matching rule (whose guard evaluates to a nonzero value, if applicable) is picked. (Again, the when construct is treated differently, because each rule is actually a separate definition.)\n\n### Patterns¶\n\nThe left-hand side of a rule is a special kind of simple expression, called a pattern. The variables in a pattern serve as placeholders which are bound to corresponding values when the rule is applied to a target expression. To these ends, the pattern is matched against the target expression, i.e., the literal parts of the pattern are compared against the target expression and, if everything matches up, the variables in the pattern are bound to (set to the value of) the corresponding subterms of the target expression.\n\nPatterns are pervasive in Pure; they are used on the left-hand side of function and macro definitions, just as well as in global and local variable definitions. For instance, the following variable definition matches the result of evaluating the right-hand side list expression against the pattern x:y:xs and binds the variables x and y to the first two elements of the resulting list and xs to the list of remaining elements, respectively. We can then place x and y at the end of the list, thereby performing a kind of “rotation” of the first two list members:\n\n```> let x:y:xs = 1..10;\n> xs+[x,y];\n[3,4,5,6,7,8,9,10,1,2]\n```\n\nThe same works with a local variable definition:\n\n```> xs+[x,y] when x:y:xs = 1..10 end;\n[3,4,5,6,7,8,9,10,1,2]\n```\n\nOr with a case expression:\n\n```> case 1..10 of x:y:xs = xs+[x,y] end;\n[3,4,5,6,7,8,9,10,1,2]\n```\n\nThe arguments of functions (and macros) are handled in the same fashion, too:\n\n```> rot2 (x:y:xs) = xs+[x,y];\n> rot2 (1..10);\n[3,4,5,6,7,8,9,10,1,2]\n```\n\nHowever, there is a big difference here. For global and local variable definitions, it is an error if the pattern does not match the target expression:\n\n```> let x:y:xs = ;\n<stdin>, line 7: failed match while evaluating 'let x:y:xs = '\n```\n\nThe same holds if the target expression doesn’t match any of the left-hand side patterns in a case expression:\n\n```> case of x:y:xs = xs+[x,y] end;\n<stdin>, line 8: unhandled exception 'failed_match' while evaluating\n'case of x:y:xs = xs+[x,y] end'\n```\n\n(The error message is slightly different in this case, but the reported kind of exception is actually the same as with the let expression above.)\n\nThis doesn’t normally happen with functions and macros. Instead, a match failure just means that the corresponding rule will be bypassed and other rules will be tried instead. If there are no more rules, the target expression becomes a normal form which is simply returned as is:\n\n```> rot2 ;\nrot2 \n```\n\nThis may come as a surprise (other functional languages will give you an error in such cases), but is a crucial feature of term rewriting languages, as it opens the door to symbolic evaluation techniques, see Definitions and Expression Evaluation.\n\nThere are two different ways to force a function definition to bail out with an error if you prefer that behaviour. First, you can provide an explicit rule which raises an exception (cf. Exception Handling). But this can make it difficult or even impossible to add more rules to the function later, as discussed below. Instead, you may want to use the --defined pragma as follows:\n\n```> #! --defined rot2\n> rot2 ;\n<stdin>, line 13: unhandled exception 'failed_match' while evaluating 'rot2 '\n```\n\nNote\n\nThis pragma tells the compiler that rot2 is supposed to be a “defined” function, which means that it should be an error if no rule applies to it; please see Defined Functions in the Caveats and Notes section for details. Also note that exceptions will always interfere with symbolic evaluation and thus the use of this facility isn’t really recommended. However, there are situations in which it can make your life a lot easier.\n\nOne of Pure’s key features is that you can usually just keep on adding new rules to existing function definitions in order to handle different kinds of arguments. As already mentioned, the rules will then be considered in the order in which they are written, and the first rule which matches the given arguments will be used to reduce the function application. For instance, adding the following rule we can make the rot2 function also work with tuples:\n\n```> rot2 (x,y,xs) = xs,x,y;\n> rot2 (1,2,3,4,5);\n3,4,5,1,2\n```\n\nThis is also known as ad-hoc polymorphism. By these means, you can make a function apply to as many different kinds of arguments as you want, and the pattern matching handles the necessary “dispatching” so that the right rule gets invoked for the provided arguments.\n\nPattern matching is not limited to the predefined aggregates such as lists, tuples and matrices. In principle, any legal Pure expression can occur as a pattern on the left-hand side of a rule or definition, so you can also write something like:\n\n```> rot2 (point x y z) = point z x y;\n> rot2 (point 1 2 3);\npoint 3 1 2\n```\n\nOr even:\n\n```> foo (foo x) = foo x;\n> bar (foo x) = foo (bar x);\n> foo (bar (foo 99));\nfoo (bar 99)\n```\n\nNote that symbolic rules like in the latter example (which in this case express the idempotence of foo and a kind of commutativity with respect to bar) often involve symbols which play the role of both a function and a constructor symbol.\n\nSyntactically, patterns are simple expressions, thus special expressions need to be parenthesized if you want to include them in a pattern. (In fact, special expressions are given special treatment if they occur in patterns, see the Macros section for details.) A few other special elements in patterns are discussed below.\n\n#### The “Head = Function” Rule¶\n\nA central ingredient of all patterns are of course the variables which get bound in the pattern matching process. Pure is a rather terse language and thus it has no explicit way to declare which identifiers are the variables. Instead, the compiler figures them out on its own, using a rather intuitive rule already explained in Variables in Equations.\n\nRecall that the variables in a pattern are the identifiers in “variable positions”. The head = function rule tells us that a variable position is any leaf (atomic subexpression) of the expression tree which is not the head symbol of a function application. Thus a pattern like f (g x) y contains the variables x and y, whereas f and g are interpreted as literal function symbols. This rule also applies to the case of infix, prefix or postfix operator symbols, if we write the corresponding application in its unsugared form. E.g., x+y*z is equivalent to (+) x ((*) y z) which contains the variables x, y and z and the literal function symbols (+) and (*).\n\nThere are some exceptions to the “head = function” rule. Specifically, it is possible to declare an identifier as a nonfix symbol so that it will be interpreted as a literal function symbol even if it occurs in a variable position, see Symbol Declarations for details. For instance:\n\n```nonfix nil;\nfoo nil = 0;\n```\n\nNote that since nil is declared as a nonfix symbol here, the symbol is interpreted as a literal rather than a variable in the left-hand side foo nil, and thus foo will return 0 for a literal nil value only.\n\nAnother case which needs special consideration are patterns consisting of a single identifier, such as x. Here the meaning depends on the kind of construct. All variable-binding constructs (let, const, when and case) treat a singleton identifier as a variable (unless it is declared nonfix). Thus all of the following constructs will have the expected result of binding the variable x to the given list value [1,2,3]. In either case the result is [0,1,2,3]:\n\n```let x = [1,2,3]; 0:x;\n0:x when x = [1,2,3] end;\ncase [1,2,3] of x = 0:x end;\n```\n\nIn contrast, a single identifier is always interpreted as a literal if it occurs on the left-hand side of a function or macro definition, so that the following rule defines a parameterless function y:\n\n```y = [1,2,3]; 0:y;\n```\n\n(While they yield the same values here, there are some notable differences between the parameterless function y and the global variable x defined above; see Defining Functions for details.)\n\nPlease also check “Head = Function” Pitfalls in the Caveats and Notes section which has some some further interesting details and workarounds concerning the “head = function” rule.\n\n#### Constant Patterns¶\n\nConstants in patterns must be matched literally. For instance:\n\n```foo 0 = 1;\n```\n\nThis will only match an application of foo to the machine integer 0, not 0.0 or 0L (even though these compare equal to 0 using the ‘==‘ operator).\n\n#### The Anonymous Variable¶\n\nThe ‘_‘ symbol is special in patterns; it denotes the anonymous variable which matches an arbitrary value (independently for all occurrences) without actually binding a variable. This is useful if you don’t care about an argument or one of its components, in which case you can just use the anonymous variable as a placeholder for the value and don’t have to invent a variable name for it. For instance:\n\n```foo _ _ = 0;\n```\n\nThis will match the application of foo to any combination of two arguments (and just ignore the values of these arguments).\n\n#### Non-Linear Patterns and Syntactic Equality¶\n\nIn contrast to Haskell, patterns may contain repeated variables (other than the anonymous variable), i.e., they may be non-linear. Thus rules like the following are legal in Pure, and will only be matched if all occurrences of the same variable in the left-hand side pattern are matched to the same value:\n\n```> foo x x = x;\n> foo 1 1;\n1\n> foo 1 2;\nfoo 1 2\n```\n\nNon-linear patterns are particularly useful for computer algebra where you will frequently encounter rules such as the following:\n\n```> x*y+x*z = x*(y+z);\n> a*(3*4)+a*5;\na*17\n```\n\nThe notion of “sameness” employed here is that of syntactical identity, which means that the matched subterms must be identical in structure and content. The prelude provides syntactic equality as a function same and a comparison predicate ‘===‘. Thus the above definition of foo is roughly equivalent to the following:\n\n```foo x y = x if same x y;\n```\n\nIt is important to note the differences between syntactic equality embodied by same and ‘===‘, and the “semantic” equality operator ‘==‘. The former are always defined on all terms, whereas ‘==‘ is only available on data where it has been defined explicitly, either in the prelude or by the programmer. Also note that ‘==‘ may assert that two terms are equal even if they are syntactically different. Consider, e.g.:\n\n```> 0==0.0;\n1\n> 0===0.0;\n0\n```\n\nThis distinction is actually quite useful. It gives the programmer the flexibility to define ‘==‘ in any way that he sees fit, which is consistent with the way the other comparison operators like ‘<‘ and ‘>‘ are handled in Pure.\n\nSyntactic equality is also used in pattern matching in order to decide whether a constant in a pattern matches the corresponding subterm in the target expression. This explains why the pattern foo 0, as already mentioned, only matches an application of foo to the machine integer 0, not 0.0 or 0L which aren’t syntactically equal to 0.\n\nHowever, there is one caveat here. Due to its term rewriting heritage, Pure distinguishes between literal function symbols in patterns and named functions. The latter are runtime objects which are only considered syntactically equal if they not only have the same name but actually refer to the same (global or local) closure. In contrast, a function symbol in a pattern is just a literal symbol without reference to any particular closure that the symbol may be bound to in some context. Thus a function symbol in a pattern matches any instance of the symbol in the target expression, no matter whether it happens to be a pure constructor, quoted symbol or any named closure bound to that symbol.\n\nThis leads to some discrepancies between pattern matching and syntactic equality which may be surprising at first sight. For instance, consider:\n\n```> foo x = case x of bar y = x===bar y end;\n> bar x y = x+y;\n> foo (bar 99);\n1\n> foo ('bar 99);\n0\n> foo (bar 99) with bar x y = x*y end;\n0\n```\n\nNote that the argument term bar 99 matches the pattern bar y in the case expression in either case, even though in the last two expressions bar is not considered syntactically equal to the global bar function because it is quoted (cf. The Quote) or bound to a local closure of the same name, respectively.\n\n#### Special Patterns¶\n\nLast but not least, patterns may also contain the following special elements which are not permitted in right-hand side expressions:\n\n• A Haskell-style “as” pattern of the form variable @ pattern binds the given variable to the expression matched by the subpattern pattern (in addition to the variables bound by pattern itself). This is convenient if the value matched by the subpattern is to be used on the right-hand side of an equation.\n• A left-hand side variable (including the anonymous variable) may be followed by a type tag of the form :: name, where name is either one of the built-in type symbols int, bigint, double, string, matrix, pointer, or an identifier denoting a user-defined data type. The variable can then match only values of the designated type. Thus, for instance, ‘x::int‘ only matches machine integers. See the Type Tags section below for details.\n\nTo these ends, the expression syntax is augmented with the following grammar rule (but note that this form of expression is in fact only allowed on the left-hand side of a rule):\n\n```prim_expr ::= qualified_identifier\n(\"::\" qualified_identifier | \"@\" prim_expr)\n```\n\nAs shown, both “as” patterns and type tags are primary expressions, and the subpattern of an “as” pattern is a primary expression, too. Thus, if a compound expression is to be used as the subpattern, it must be parenthesized. For instance, the following function duplicates the head element of a list:\n\n```foo xs@(x:_) = x:xs;\n```\n\nNote that if you accidentally forget the parentheses around the subpattern x:_, you still get a syntactically correct definition:\n\n```foo xs@x:_ = x:xs;\n```\n\nBut this gets parsed as (foo xs@x):_ = x:xs, which is most certainly not what you want. It is thus a good idea to just always enclose the subpattern with parentheses in order to prevent such glitches.\n\nNote\n\nAnother pitfall is that the notation foo::bar is also used to denote “qualified symbols” in Pure, cf. Namespaces. Usually this will be resolved correctly, but if foo happens to also be a valid namespace then most likely you’ll get an error message about an undeclared symbol. You can always work around this by adding spaces around the ‘::‘ symbol, as in foo :: bar. Spaces are never permitted in qualified symbols, so this makes it clear that the construct denotes a type tag. The same applies if the variable or the tag is a qualified identifier; in this case they should always be separated by whitespace.\n\n### Type Tags¶\n\nLike Lisp, Pure is essentially a typeless language and doesn’t really have a built-in notion of “data types”. Rather, all data belongs to the same universe of terms. However, for convenience it is possible to describe data domains by means of (unary) type predicates which may denote arbitrary sets of terms. The names of these type predicates can then be used as type tags on variables, so that they can only be matched by values of the given type.\n\nWe have to emphasize here that Pure’s notion of types has nothing to do with static typing. Type tags are merely used at runtime to restrict the kind of data that can be matched by a rule (and by the compiler to generate better code in some cases). But they will never cause the compiler to impose a static typing discipline and spit out corresponding “type errors”. (This wouldn’t make any sense in Pure anyway, as failure to match any of the rules given in the definition of a function simply means that a function application is in normal form.)\n\nSome basic types are built into the language. The corresponding tags enable you to match the built-in types of terms for which there is no way to spell out all “constructors”, as there are infinitely many (or none, as in the case of pointer values which are constructed and inspected using special primitives, but are otherwise “opaque” at the Pure level). Specifically, the following data types are built-in (in fact, the pattern matcher has special knowledge about these so that they can be matched very efficiently):\n\ntype int\n\nThe type of machine integers.\n\ntype bigint\n\nThe type of arbitrary precision integers (GMP bigints).\n\ntype double\n\nThe type of double precision floating point numbers.\n\ntype string\n\nThe type of character strings.\n\ntype matrix\n\nThe type of all numeric and symbolic matrix values.\n\ntype pointer\n\nThe type of C pointer values.\n\nPure’s standard library provides additional data types along with the corresponding operations, such as rational and complex numbers, lists, tuples and the container data types (sets, dictionaries, etc.). These are all described in the Pure Library Manual.\n\nYou can define your own data types using a special kind of rule syntax which is explained in Type Rules below. For instance, we might represent points in the plane using a constructor symbol Point which gets applied to pairs of coordinates. We can then define the point data type as follows:\n\n```type point (Point x y);\n```\n\nThis introduces the type symbol point and specifies that this type consists of terms of the form Point x y. We can now equip this data type with an operation point to construct a point from its coordinates, two operations xcoord and ycoord to retrieve the coordinates, and an operation move to change the coordinates to the given values:\n\n```point x y = Point x y;\nxcoord (Point x y) = x;\nycoord (Point x y) = y;\nmove (Point _ _) x y = Point x y;\n```\n\nNext we might define a function translate which shifts the coordinates of a point by a given amount in the x and y directions as follows:\n\n```translate x y p::point = move p (xcoord p+x) (ycoord p+y);\n```\n\nNote the use of point as a type tag on the p variable. By these means, we can ensure that the argument is actually an instance of the point data type we just defined. The type tag acts just like an extra guard of the equation defining translate, but all the necessary type checking is done automatically during pattern matching. This is often more convenient (and, depending on the implementation, the compiler may generate more efficient code for a type tag than for an ordinary guard).\n\nThe translate function can be invoked as follows:\n\n```> let p::point = point 3 3;\n> p; translate 1 2 p;\nPoint 3 3\nPoint 4 5\n```\n\nOne important point to note here is that translate can be defined without knowing or assuming anything about the internal representation of the point data type. We have defined point as a concrete data type in this example, making its constructor and internal structure visible in the rest of the program. This is often convenient, but the Point constructor might just as well be hidden by making it a private member of some namespace (cf. Namespaces), so that all accesses to the data structure would have to be done through the provided operations. Such a data type is also known as an abstract data type (ADT).\n\nNote\n\nAs we’ve already seen, Pure has some powerful capabilities which enable you to write functions to inspect and manipulate terms in a completely generic fashion. Thus the internal structure of term data is never truly opaque in Pure and it is always possible to break the “abstraction barrier” provided by an ADT. But if the user of an ADT plays such dirty tricks to wreak havoc on the internal representation of an ADT, he gets what he deserves.\n\nPure provides some additional facilities to ease the handling of abstract data types. Specifically, instead of defining point as a concrete data type using a type rule, we might also specify it as an interface type which merely lists the supported operations as follows:\n\n```interface point with\nxcoord p::point;\nycoord p::point;\nmove p::point x y;\nend;\n```\n\nWe can implement this type the same way as before:\n\n```point x y = Point x y;\nxcoord (Point x y) = x;\nycoord (Point x y) = y;\nmove (Point _ _) x y = Point x y;\n```\n\nThe definition of the translate function is also unchanged:\n\n```translate x y p::point = move p (xcoord p+x) (ycoord p+y);\n```\n\nThe difference is that now the structure of members of the type is not made explicit anywhere in the definition of the type. Instead, the compiler figures out which data matches the point tag on its own. We can check the actual term patterns making up the point type with the show interface command:\n\n```> show interface point\ntype point (Point x y);\n```\n\nAs you can see, the compiler derived our previous definition of the type. But in fact translate will now work with any data type which implements the point interface (i.e., provides the xcoord, ycoord and move operations), so we may swap out the underlying data structure on a whim. For instance, if we’d like to use vectors instead of constructor terms, all we have to do is to provide a corresponding construction function and implement the interface operations:\n\n```vpoint x y = {x,y};\nxcoord {x,y} = x;\nycoord {x,y} = y;\nmove {_,_} x y = {x,y};\n```\n\nAfter these definitions the new data representation works just fine with existing point operations such as translate:\n\n```> show interface point\ntype point (Point x y);\ntype point {x,y};\n> let p::point = vpoint 3 3;\n> p; translate (1,2) p;\n{3,3}\n{4,5}\n```\n\nThis separation of interface and implementation of a data structure is an important ingredient of software engineering techniques. More examples and detailed explanations of Pure’s notions of type predicates and interface types can be found in the Type Rules and Interface Types sections.\n\n### General Rules¶\n\nThe most general type of rule, used in function definitions and case expressions, consists of a left-hand side pattern, a right-hand side expression and an optional guard. The left-hand side of a rule can be omitted if it is the same as for the previous rule. This provides a convenient means to write out a collection of equations for the same left-hand side which discriminates over different conditions:\n\n```lhs = rhs if guard;\n= rhs if guard;\n...\n= rhs otherwise;\n```\n\nFor instance:\n\n```fact n = n*fact (n-1) if n>0;\n= 1 otherwise;\n```\n\nThis expands to:\n\n```fact n = n*fact (n-1) if n>0;\nfact n = 1 otherwise;\n```\n\nPure also allows a collection of rules with different left-hand sides but the same right-hand side(s) to be abbreviated as follows:\n\n```lhs |\n...\nlhs = rhs;\n```\n\nThis is useful, e.g., if you specialize a rule to different type tags on the left-hand side variables. For instance:\n\n```fact n::int |\nfact n::double = n*fact(n-1) if n>0;\n= 1 otherwise;\n```\n\nThis expands to:\n\n```fact n::int = n*fact(n-1) if n>0;\n= 1 otherwise;\nfact n::double = n*fact(n-1) if n>0;\n= 1 otherwise;\n```\n\nIn fact, the left-hand sides don’t have to be related at all, so you can also write something like:\n\n```foo x | bar y = x*y;\n```\n\nWhich expands to:\n\n```foo x = x*y;\nbar y = x*y;\n```\n\nBut more often you’ll have an “as” pattern which binds a common variable to a parameter value after checking that it matches one of several possible argument patterns (which is slightly more efficient than using an equivalent type-checking guard). E.g., the following definition binds the xs variable to the parameter of foo, which may be either the empty list or a list starting with an integer:\n\n```foo xs@[] | foo xs@(_::int:_) = bar xs;\n```\n\nThe | notation also works in case expressions, which is convenient if different cases should be mapped to the same value, e.g.:\n\n```case ans of \"y\" | \"Y\" = 1; _ = 0; end;\n```\n\nSometimes it is useful if local definitions (when and with) can be shared by the right-hand side and the guard of a rule. This can be done by placing the local definitions behind the guard, as follows (we only show the case of a single when clause here, but of course there may be any number of when and with clauses behind the guard):\n\n```lhs = rhs if guard when defns end;\n```\n\nNote that this is different from the following, which indicates that the definitions only apply to the guard but not the right-hand side of the rule:\n\n```lhs = rhs if (guard when defns end);\n```\n\nConversely, definitions placed before the guard only apply to the right-hand side but not the guard (no parentheses are required in this case):\n\n```lhs = rhs when defns end if guard;\n```\n\nAn example showing the use of a local variable binding spanning both the right-hand side and the guard of a rule is the following quadratic equation solver, which returns the (real) solutions of the equation x^2+p*x+q = 0 if the discriminant d = p^2/4-q is nonnegative:\n\n```> using math;\n> solve p q = -p/2+sqrt d,-p/2-sqrt d if d>=0 when d = p^2/4-q end;\n> solve 4 2; solve 2 4;\n-0.585786437626905,-3.41421356237309\nsolve 2 4\n```\n\nNote that the above definition leaves the case of a negative discriminant undefined.\n\n### Simple Rules¶\n\nAs already mentioned, when, let and const use a simplified kind of rule syntax which just consists of a left-hand and a right-hand side separated by the equals sign. In this case the meaning of the rule is to bind the variables in the left-hand side of the rule to the corresponding subterms of the value of the right-hand side. This is also called a pattern binding.\n\nGuards or multiple left-hand or right-hand sides are not permitted in these rules. However, it is possible to omit the left-hand side if it is just the anonymous variable ‘_‘ by itself, indicating that you don’t care about the result. The right-hand side is still evaluated, if only for its side-effects, which is handy, e.g., for adding debugging statements to your code. For instance, here is a variation of the quadratic equation solver which also prints the discriminant after it has been computed:\n\n```> using math, system;\n> solve p q = -p/2+sqrt d,-p/2-sqrt d if d>=0\n> when d = p^2/4-q; printf \"The discriminant is: %g\\n\" d; end;\n> solve 4 2;\nThe discriminant is: 2\n-0.585786437626905,-3.41421356237309\n> solve 2 4;\nThe discriminant is: -3\nsolve 2 4\n```\n\nNote that simple rules of the same form lhs = rhs are also used in macro definitions (def), to be discussed in the Macros section. In this case, however, the rule denotes a real rewriting rule, not a pattern binding, hence the left-hand side is mandatory in these rules.\n\n### Type Rules¶\n\nIn Pure the definition of a type takes a somewhat unusual form, since it is not a static declaration of the structure of the type’s members, but rather an arbitrary predicate which determines through a runtime check which terms belong to the type. Thus the definition of a type looks more like an ordinary function definition (and that’s essentially what it is, although types live in their own space where they can’t be confused with functions of the same name).\n\nThe definition of a type thus consists of one or more type rules which basically have the same format as the general rules, but with the keyword type in front of each rule. Also, each left-hand side must have at most one argument pattern and exactly one right-hand side. Hence, if the definition of a type requires several right-hand sides, you normally have to write a separate type rule for each of them. Multiple left-hand sides work the same as in the general rule format, though.\n\nAs already mentioned, there is an alternative way for defining types in an indirect way through so-called interface types from which the corresponding type rules are derived automatically. These are part of Pure’s declaration syntax and thus will be discussed later in the Declarations section. In this section we focus on how you can write your own type rules in order to define types in a direct fashion.\n\nThe identifier in the head of the left-hand side of a type rule is the name of the type which can then be used as a type tag in other equations, cf. Type Tags. This is just a normal, possibly qualified identifier subject to the same namespace mechanisms as other symbols; see Namespaces for details. However, as the type symbol only gets used as a type tag, it can never collide with function and variable symbols and hence the same symbol can be used both as a type and as a function or variable name.\n\nA collection of type rules specifies a predicate, i.e. a unary, truth-valued function which denotes a set of terms. The type consists precisely of those terms for which the type predicate yields a nonzero result. For instance, the following type defines the type triple as the set of all tuples with exactly three elements:\n\n```type triple (x,y,z) = ~tuplep z;\n```\n\nNote that the type check consists of two parts here: The left-hand side pattern (x,y,z) restricts the set to all tuples with at least three elements. The right-hand side ~tuplep z then verifies that the last component z is not a tuple itself, and thus the entire tuple consists of exactly three elements.\n\nAnother important point here is that the definition of the triple predicate is partial, as the given rule only applies to tuples with at least three elements. A value will only match the triple type tag if the predicate explicitly returns true; otherwise the match will fail, no matter what the result is (and even if the predicates just fails, i.e., returns an unevaluated normal form). Thus there is no need to make the predicate work on all terms (and in fact there are good reasons to not do so, see below).\n\nIn general, you should try to make your type definitions as specific as possible. This makes it possible to extend the predicate later, just like Pure allows you to extend the definition of a function to new types of arguments. For instance, if you later decide that lists with three elements should be considered as triples, too, then you may add the following type rule:\n\n```type triple [x,y,z] = true;\n```\n\nThis makes it possible to define a type in a piecemeal fashion. Each subsequent rule enlarges the term set of the type. Conversely, consider a definition like:\n\n```type pair x = tuplep x && #x==2;\n```\n\nIn this case the type rule applies to all values x and thus the type definition is complete; there is no way to extend it later. Whether to prefer the former or latter kind of definition depends on the situation. If you want to keep a type extensible, so that you can later make existing definitions of operations on the type work with new data representations, then you should use the former approach, otherwise the latter.\n\nAs an example for an extensible type definition, consider the following type nat which denotes the type of positive (machine) integers:\n\n```type nat x::int = x>0;\n```\n\nThis definition is complete for the case of machine integers, but allows the type to be extended for other base types, and we’ll do that in a moment. But first let’s define the factorial on nat values as follows:\n\n```fact n::nat = if n==1 then 1 else n * fact (n-1);\n```\n\nNote that this definition would loop on zero or negative values if we permitted arbitrary int arguments. But since we restricted the argument type to nat, this case cannot occur and so the definition is safe:\n\n```> fact 0;\nfact 0\n> map fact (1..10);\n[1,2,6,24,120,720,5040,40320,362880,3628800]\n```\n\nThe way we defined fact, it works on positive machine integers, but nothing else:\n\n```> fact 10L;\nfact 10L\n```\n\nIf we later decide that positive bigints should be considered as members of nat as well, we can simply add another rule for the nat type:\n\n```type nat x::bigint = x>0;\n```\n\nEt voila, our fact routine now magically works with bigints, too:\n\n```> map fact (0L..10L);\n[fact 0L,1,2L,6L,24L,120L,720L,5040L,40320L,362880L,3628800L]\n```\n\nNote that we did all this without ever touching our original definition of fact. This works because the bigint data type already provides all the operations which we expect to use with the nat type. Pulling off this trick with other, more exotic kinds of data requires more preparation, since we’ll first have to provide the required operations. In this case, we need at least multiplication, as well as comparisons with 1 and subtraction by 1. For instance, and just for the fun of it, let’s implement our own variation of the nat type using Peano arithmetic:\n\n```type nat (s x) = true;\n\nx + 0 = x;\nx + 1 = s x;\nx + s y = s (x+y);\n\n// multiplication\nx * 0 = 0;\nx * 1 = x;\nx * s y = x + x*y;\n\n// subtract 1\ns x - 1 = x;\n\n// comparison with 0 and 1\ns x == 0 = false;\ns x == 1 = x == 0;\n```\n\nThis implements just the bare bones, but that should be enough to make fact work. Let’s give it a try:\n\n```> fact (s (s (s 0)));\ns (s (s (s (s (s 0)))))\n```\n\nSo, counting the s‘s, the factorial of 3 is 6. Works! (It goes without saying, though, that this implementation of nat is not very practical; you’ll get mountains of s‘s for larger values of n.)\n\nAs you can see, a type definition may in general consist of many type rules which may be scattered out over different parts of a program. This works in exactly the same way as with ordinary functions.\n\nThere’s an additional convenience provided for type rules, namely that the right-hand side may be omitted if it’s just true. For instance, the rule\n\n```type nat (s x) = true;\n```\n\nfrom above can also be written simply as:\n\n```type nat (s x);\n```\n\nThis kind of notation is particularly convenient for “algebraic types” which are usually given by a collection of constructors with different arities. For instance, a binary tree data type might be defined as follows (here we employ the | symbol to separate the different left-hand sides so that we can give all the constructor patterns in one go):\n\n```nonfix nil;\ntype bintree nil | bintree (bin x left right);\n```\n\nThis method is also useful if you define your own abstract data types. In this case you’re free to choose any suitable representation, so you might just wrap up all data objects of the type with a special constructor symbol, which makes checking the type simple and efficient. This is also the approach taken in the point example in Type Tags above, as well as by the container data types in the standard library.\n\nThe same notation can also be used to quickly make one type a “subtype” of another, or to create a type which is the union of several existing types. The following example can be found in the standard library:\n\n```type integer x::int | integer x::bigint;\n```\n\nA type rule can also take the form of a function definition without arguments. The corresponding right-hand side may either be another type symbol, or any kind of closure denoting a (curried) type predicate. In this case the defined type is simply an alias for the type denoted on the right-hand side. This is often done, e.g., for numeric types, to document that they actually stand for special kinds of quantities:\n\n```type speed = double;\ntype size = int;\n```\n\nNote that the definition of a type alias is always complete; there’s no way to extend the corresponding type later. Therefore type aliases are normally resolved at compile time, so that they incur no additional runtime cost. For instance:\n\n```> half x::speed = x/2;\n> show half\nhalf x::double = x/2;\n```\n\n(If necessary, this “type folding” can also be disabled with the --nofold pragma.)\n\nFinally, it’s also possible to just specify the type name, without giving the right-hand side:\n\n```type thing;\n```\n\nThis doesn’t have any effect other than just declaring the type symbol, so that it can be used as a type tag in subsequent definitions. You then still have to give a proper definition of the type later (either as an explicit predicate or an alias).\n\nType aliases can also be used to quickly turn an existing predicate into a “convenience” type which can be used as a tag on the left-hand side of equations. The prelude defines a number of these, see Prelude Types. For instance:\n\n```type closure = closurep;\n```\n\nConversely, you can turn any type tag into an ordinary predicate which can be used on the right-hand side of other definitions. To these ends, the prelude provides the typep predicate which takes a type symbol and the value to be checked as arguments. For instance:\n\n```type odd x::int = x mod 2;\ntype even x::int = ~odd x;\n\nodd x = typep odd x;\neven x = typep even x;\n```\n\nWith those definitions you get:\n\n```> map odd (0..10);\n[0,1,0,1,0,1,0,1,0,1,0]\n> map even (0..10);\n[1,0,1,0,1,0,1,0,1,0,1]\n```\n\nThere’s one caveat here. As the type symbol passed to typep gets evaluated in normal code you have to be careful if the symbol is also defined as a parameterless function or a variable; in such a case you’ll have to quote the symbol, as described in section The Quote. For instance, we might rewrite the above definitions as follows, giving “pointless” definitions of the odd and even predicates in terms of typep:\n\n```type odd x::int = x mod 2;\ntype even x::int = ~odd x;\n\nodd = typep ('odd);\neven = typep ('even);\n```\n\nNote that the quotes on odd and even are really needed here to prevent the predicate definitions from looping. If you need this a lot then you might define a little helper macro (cf. Macros) which quotes the type symbol in an automatic fashion:\n\n```def typep ty::symbol = typep ('ty);\n```\n\n(However, this gets in the way if you want to check for computed type symbols, that’s why this macro isn’t defined in the prelude.)\n\nPure places no a priori restrictions on the rules defining a data type (other than that they must either define a unary predicate or an alias for an existing data type). As far as Pure is concerned, types are just subsets of the universe of terms. Thus any type of relation between two data types is possible; they might be unrelated (disjoint) term sets, one may be a subset of another, or they might be related in some other way (some terms may be members of both types, while others aren’t).\n\nFor instance, consider the types nat and odd from above. Both are subtypes of the int type (assuming our original definition of nat as the positive int values), but neither is a subtype of the other. It’s sometimes useful to define the “intersection type” of two such types, which can be done in a straightforward way using the logical conjunction of the two type predicates:\n\n```type nat x::int = x>0;\ntype odd x::int = x mod 2;\ntype odd_nat x = typep nat x && typep odd x;\n```\n\nSimilarly, a variation of the integer union type from above could be defined using logical disjunction (this employs the intp and bigintp predicates from the prelude):\n\n```type myinteger x = intp x || bigintp x;\n```\n\n(Note that this isn’t quite the same as the previous definition, which uses explicit patterns in order to make the definition extensible.)\n\nSince the right-hand side of a type definition may in general be any predicate, it is up to the programmer to ensure that the definition of a type is actually computable. In fact, you should strive for the best possible efficiency in type predicates. A type definition which has worse than", null, "complexity may well be a serious performance hog depending on the way in which it is used, see Recursive Types in the Caveats and Notes section for more information about this.\n\nFinally, note that in general it may be hard or even impossible to predict exactly when the code of a type definition will be executed at runtime. Thus, as a general rule, a type definition should not rely on side effects such as doing I/O (except maybe for debugging purposes), modifying references or external data structures via C pointers, etc.\n\n## Examples¶\n\nThis section assumes that you’ve read the Pure Overview and Rule Syntax sections, so that you are familiar with the basic elements of the Pure language. We now bring the pieces together and show you how simple but typical problems can be solved using Pure. You might use this section as a mini-tutorial on the Pure language. As we haven’t discussed the more advanced elements of the Pure language yet, the scope of this section is necessarily limited. But it should give you a pretty good idea of how Pure programs looks like. After working through these examples you should be able to write useful Pure programs and understand the more advanced features discussed in subsequent sections.\n\n### Hello, World¶\n\nThe notorious “hello world” program can be written in Pure as follows:\n\n```using system;\nputs \"Hello, world!\";\n```\n\nThis employs the puts function from Pure’s system module (which is in fact just the puts function from the C library). If you put these lines into a script file, say, hello.pure, you can run the program from the command line as follows:\n\n```\\$ pure hello.pure\nHello, world!\n```\n\nYou may notice a slight delay when executing the script, before the “Hello, world!” message appears. That’s because the interpreter first has to compile the definitions in your script as well as the prelude and other imported modules before the puts \"Hello, world!\" expression can be evaluated. The startup times can be reduced (sometimes considerably) by compiling scripts to native executables, see Compiled Scripts below.\n\n#### Passing Parameters¶\n\nSometimes you may want to pass parameters to a script from the command line. To these ends, just follow the script name with the required parameters. The interpreter makes the command line parameters (including the script name) available as a list of strings in the argv variable. For instance, here is a version of the “hello world” program which uses printf to print the line Hello, foo! where foo is whatever was specified as the first command line parameter:\n\n```using system;\nprintf \"Hello, %s!\\n\" (argv!1);\n```\n\nThis script is invoked as:\n\n```\\$ pure hello.pure foo\nHello, foo!\n```\n\nOf course, many real-world programs will require more elaborate processing of command line parameters, such as recognizing program options. We won’t discuss this here, but you can have a look at the getopt module which provides that kind of functionality in a convenient package.\n\n#### Executable Scripts¶\n\nIt is often convenient if you can turn a script into a standalone executable which can be invoked by just typing its name on the command line. There are several ways to do this.\n\nFirst, on most systems you can invoke the Pure script through some kind of shell script or command file which contains the command to invoke the interpreter. The details of this depend on the operating system and type of shell that you use, however, so we won’t go into this here.\n\nSecond, on Unix-like systems it is possible to make any script file executable like this:\n\n```\\$ chmod a+x hello.pure\n```\n\nHowever, we also have to tell the shell about the command interpreter which should be invoked to run the script. (Otherwise the shell itself may try to execute the script, which won’t work because it’s not a shell script.) As already mentioned in Overview of Operation, this is done by adding a special kind of comment, a “shebang”, to the beginning of the script, so that it looks like:\n\n```#!/usr/local/bin/pure\nusing system;\nputs \"Hello, world!\";\n```\n\nNote that you must give the full path to the Pure interpreter in the shebang line. This path of course depends on where you installed Pure. The above shebang will work with an installation from source, unless you changed the installation prefix when configuring the source package. If you installed the interpreter from a binary package, the proper path will often be /usr/bin/pure instead. In any case, you can find out where the interpreter lives by typing the following command in the shell:\n\n```\\$ which pure\n/usr/local/bin/pure\n```\n\nIf you get anything else on your system then you’ll have to fix the shebang accordingly. You should then be able to run the script as follows:\n\n```\\$ ./hello.pure\nHello, world!\n```\n\nNote\n\nMany modern Unix-like systems provide the /usr/bin/env utility which can perform a search for the interpreter executable, so that you can also use a shebang like:\n\n```#!/usr/bin/env pure\n```\n\nThis has the advantage that you don’t have to hardcode the path to the Pure interpreter into the shebang; the /usr/bin/env utility will locate the interpreter for you, provided that it is installed somewhere on the system PATH.\n\n#### Compiled Scripts¶\n\nLast but not least, you can also turn a Pure script into an executable by “batch-compiling” it. This works on all supported systems (provided that you have the necessary LLVM tools and 3rd party compilers installed, see the installation instructions for details). The result is a real native executable which can then be run directly just like any other binary program on your system. To these ends, the interpreter is run with the -c option which tells it to run in batch compilation mode, and the -o option which specifies the desired name of the executable. For instance:\n\n```\\$ pure -c hello.pure -o hello\nHello, world!\n\\$ ./hello\nHello, world!\n```\n\nYou’ll notice that the compilation command in the first line above also prints the Hello, world! message. This reveals a rather unusual aspect of Pure’s batch compiler: it actually executes the script even during batch compilation. The reasons for this behaviour and potential uses are discussed in the Batch Compilation section. If you want to suppress the program output during batch compilation, you can rewrite the program as follows:\n\n```using system;\nmain = puts \"Hello, world!\";\ncompiling || main;\n```\n\nNote that here we turned the code to be executed into a separate main function. This isn’t really necessary, but often convenient, since it allows us to run the code to be executed by just evaluating a single function. (Note that in contrast to C, the name main has no special significance in Pure; it’s just a function like any other. We still have to include a call to this function at the end of our program so that it gets executed.)\n\nThe last line now reads compiling || main which is a shorthand for “if the compiling variable is nonzero then do nothing, otherwise evaluate the main function”. In a batch compilation the interpreter sets this variable to a nonzero value so that the evaluation of main is skipped:\n\n```\\$ pure -c hello.pure -o hello\n\\$ ./hello\nHello, world!\n```\n\nWe should mention here that batch-compiled scripts have some limitations because the compiled executable runs under a trimmed-down runtime system. This disables some of the advanced compile time features which are only available when running a script with the interpreter or at batch-compilation time. However, this won’t usually affect run-of-the-mill scripts like the one above. More information about this can be found in the Batch Compilation section.\n\n### Running the Interpreter¶\n\nWhile Pure scripts can be run as standalone programs directly from the shell, most of the time you’ll probably use the Pure interpreter in an interactive way. You then simply run it like this:\n\n```\\$ pure\n\n__ \\ | | __| _ \\ Pure 0.66 (x86_64-unknown-linux-gnu)\n| | | | | __/ Copyright (c) 2008-2017 by Albert Graef\n.__/ \\__,_|_| \\___| (Type 'help' for help, 'help copying'\n\n>\n```\n\nThe interpreter prints its sign-on message and leaves you at its command prompt. (You can also try pure --plain for a less fancy sign-on, or pure -q to completely suppress the message.)\n\nAt this point you can just start typing definitions and expressions to be evaluated. For instance:\n\n```> fact n = if n<=0 then 1 else n*fact (n-1);\n> map fact (1..10);\n[1,2,6,24,120,720,5040,40320,362880,3628800]\n```\n\nNote that Pure is a free-format language, and thus definitions and expressions must be terminated with a semicolon, so that the interpreter knows when you’re done entering each item. This probably needs getting used to, but it’s convenient because you can easily type more than one expression on a single line, or split longer constructs across multiple lines:\n\n```> 6*7; 16.3805*5.0;\n42\n81.9025\n> 16753418726345\n> * 991726534256718265234;\n16614809890429729930396098173389730L\n```\n\nIf the interpreter appears to just eat away expressions without printing any results, then most likely you forgot to enter the terminating semicolon. In such a case you can just type the semicolon on a line by itself:\n\n```> 6*7\n> ;\n```\n\n(This won’t do any harm even if it’s not needed, because an empty item is always valid input at Pure’s toplevel.)\n\nThe interpreter also reports syntax errors if you mistype an expression:\n\n```> 16.3805*(5;\n<stdin>, line 8: syntax error, unexpected ';', expecting when or with or ')'\n```\n\nIn such a case, just correct the error and resubmit the offending input. The interpreter’s readline facility makes this pretty convenient, because you can use the cursor keys to recall previous input lines and edit them as needed.\n\nOther kinds of errors may happen at runtime, when evaluating a syntactically correct expression. These give rise to so-called exceptions. For instance:\n\n```> 1 div 0;\n<stdin>, line 9: unhandled exception 'signal 8' while evaluating '1 div 0'\n```\n\nBesides integer division by zero (flagged as ‘signal 8‘ here), common sources of exceptions are failed matches and conditionals, interrupts (e.g., if the user aborts an evaluation with Ctrl-c) and stack overflows (cf. Stack Size and Tail Recursion). Normally these are fatal and require you to fix the program or the expression that you entered, but programs can also catch these errors and handle them in any desired way, cf. Exception Handling.\n\nNote that in contrast to most other programming languages, undefined identifiers are generally not an error in Pure. Instead, you’ll simply get an unevaluated normal form:\n\n```> foo 5;\nfoo 5\n```\n\nTherefore, we recommend invoking the interpreter with the -w option so that it at least warns you about unknown symbols. You can also enter this option interactively or in a script using the --warn pragma:\n\n```> #! --warn\n> bar 5;\n<stdin>, line 12: warning: implicit declaration of 'bar'\nbar 5\n```\n\nThe interpreter has a global variable environment in which you can store intermediate results:\n\n```> let x = 16.3805*5;\n> x; x/2; 1/x;\n81.9025\n40.95125\n0.0122096395103935\n> let y = 2*x; y;\n163.805\n```\n\nAnother handy feature is the special built-in function ans which yields the most recent result printed by the interpreter:\n\n```> 16.3805*5;\n81.9025\n> ans*2;\n163.805\n```\n\nThe interpreter recognizes a few other special commands which, like ans, are only available when it is run interactively. For instance, you can purge the value of a variable like this (this also works with any other defined item, such as constants, functions and macros):\n\n```> clear x\n> x;\nx\n```\n\nAnother useful command is show which prints the definition of anything that you can define in a Pure script, such as variables and functions. For instance:\n\n```> show fact\nfact n = if n<=0 then 1 else n*fact (n-1);\n```\n\nYou can also just type show to print all definitions done interactively at the command prompt, which lets us review our accomplishments so far:\n\n```> show\nfact n = if n<=0 then 1 else n*fact (n-1);\nlet y = 163.805;\n```\n\nThe dump command saves these definitions in a file for later use:\n\n```> dump\n```\n\nThis command doesn’t print anything, but you can have a look at the written file in a text editor and maybe edit it as needed. By default, dump saves interactive definitions in a hidden file named .pure in the current directory, which gets reloaded automatically if we later rerun the interpreter in the same directory. We can also print this file, e.g., with the Unix cat command (note that ‘!‘ executes a shell command):\n\n```> !cat .pure\n// dump written Wed Sep 5 10:00:15 2012\nfact n = if n<=0 then 1 else n*fact (n-1);\nlet y = 163.805;\n```\n\nIf we mess up badly, it’s often convenient to just rerun the interpreter from scratch so that we can try again in a clean environment:\n\n```> run\n```\n\nAs we’ve saved our scribblings with dump previously, those definitions will be reloaded automatically:\n\n```> show\nfact n = if n<=0 then 1 else n*fact (n-1);\nlet y = 163.805;\n```\n\nIf you don’t want this then you can just remove the .pure file or rename it before invoking run.\n\nAnother helpful command is help which brings up the online documentation (this requires that you’ve configured the interpreter for the web browser that you use; see Online Help):\n\n```> help help\n```\n\nLast but not least, you can use the following command to exit the interpreter and return to the command shell:\n\n```> quit\n```\n\nTyping just an end-of-file character (usually Ctrl-d on Unix-like systems) at the beginning of the command line does the same.\n\nThere are a few other built-in commands that you may find useful when working with the interpreter, and you can even define your own. These interactive commands are special; they have their own syntax and need to be typed on a separate line. Please refer to Interactive Usage for a detailed explanation of the command syntax and the available commands.\n\n### Basic Examples¶\n\nPure has a few built-in data types, namely numbers (machine integers, bigints and double precision floating point numbers), strings, matrices, symbols, functions and pointer values. Compound expressions are formed from these using function application. In the syntax of the Pure language, these are also known as simple expressions. For want of a catchier name, we also simply call them terms. Pure is a programming language based on term rewriting, so all computations performed in Pure consist of the rewriting of terms. Some terms may reduce to other terms, others simply stand for themselves; the latter are also called normal forms and are what constitutes a “value” in the Pure language.\n\nWhen the Pure interpreter starts up, it normally loads a collection of Pure scripts collectively called the prelude. The prelude defines many of the usual operations on numbers, strings, lists and other basic data structures that you may need, so you can start using the interpreter as a sophisticated kind of desktop calculator right away. Let’s begin with some simple calculations involving integer and floating point numbers:\n\n```> 6*7;\n42\n> 16.3805*5.0;\n81.9025\n> 16753418726345 * 991726534256718265234;\n16614809890429729930396098173389730L\n```\n\nNote that the integer constants in the last example exceeded the 32 bit range of machine integers, so they were promoted to bigints. The result is again a bigint (indicated by the L suffix). You can also turn any integer constant into a bigint by explicitly adding the L suffix:\n\n```> 6L*7L;\n42L\n```\n\nArithmetic with mixed operands will generally return the most general type capable of holding the result:\n\n```> 6*7L;\n42L\n> 16.3805*5;\n81.9025\n> 16.3805*5L;\n81.9025\n```\n\nBut note that most operations involving only machine integers will produce another machine integer; the result is never promoted to a bigint automatically, even in case of “overflow” (i.e., wrap-around). So the following will yield the same kind of signed 32 bit result as you’d get in C:\n\n```> 2147483647 + 1;\n-2147483648\n```\n\nThis has the advantage that you always know the type of the result of each operation beforehand by just looking at the types of the operands. It also makes it possible to compile machine integer operations to efficient native code. Therefore, if you suspect that a machine integer operation may wrap around and you’d thus prefer to do the calculation with bigints instead, you’ll have to convert at least one of the operands to a bigint beforehand:\n\n```> 2147483647L + 1;\n2147483648L\n```\n\nAlso note that, in contrast to C or Fortran, the result of the / (division) and ^ (exponentiation) operators is always a floating point value in Pure, even if both operands are integers:\n\n```> 14/12;\n1.16666666666667\n> 2L^60L;\n1.15292150460685e+18\n```\n\nInteger division and modulo are done with the div and mod operators, and exact powers of machine integers and bigints can be computed with the pow function:\n\n```> 14 div 12; 14 mod 12;\n1\n2\n> pow 2 60;\n1152921504606846976L\n```\n\nAlso note that many of the standard math functions are available in a separate math module, so we need to import that module if we want to use one of these (see Modules and Imports for a detailed explanation of Pure’s module system). For instance:\n\n```> using math;\n> sqrt (16.3805*5)/.05;\n181.0\n```\n\nThe math module also provides you with complex and rational number types for doing more advanced calculations, but we won’t go into that here.\n\nBefore we proceed, a few remarks about the syntax of function applications are in order. Function application is an explicit operation in Pure, so that functions become first class values which can be passed around as function arguments and results. Like in most modern functional languages, function application is simply denoted by juxtaposition:\n\n```> sqrt 2;\n1.4142135623731\n```\n\nIn this case, you may also write sqrt(2) instead, but multiple arguments are normally specified as f x y z rather than f(x,y,z). The former notation is known as currying (named after the American mathematician and logician Haskell B. Curry), and is ubiquitous in modern functional programming languages. The latter notation can be used in Pure as well, but it actually indicates that f is called on a single, structured argument (in this case a tuple). However, most predefined functions use the curried notation in Pure. For instance, the max function defined in the prelude takes two separate arguments, so it is invoked as follows:\n\n```> max 4 7;\n7\n```\n\nFunction application associates to the left, so the above is parsed as (max 4) 7, where max 4 is called a partial application of the max function. A partial application is a function in its own right; e.g., max 4 denotes the function which computes max 4 y for each given y.\n\nParentheses are used for grouping expressions as usual. In particular, since function application associates to the left, a nested function application in a function argument must be parenthesized as follows:\n\n```> sqrt (sqrt 2);\n1.18920711500272\n```\n\nThe same is true for any kind of expression involving operators, since function application binds stronger than any of these:\n\n```> sqrt (2*3);\n2.44948974278318\n```\n\nThe map function lets us apply a function to each member of a given list, which gives us a quick way of tabulating function values:\n\n```> map sqrt (0..2);\n[0.0,1.0,1.4142135623731]\n```\n\nHere, the list argument is specified as an arithmetic sequence 0..2 which evaluates to the list [0,1,2]. This is fairly convenient when tabulating values of numeric functions. Here is another example which employs a partial application of the max function as the function argument:\n\n```> map (max 0) (-3..3);\n[0,0,0,0,1,2,3]\n```\n\nNote that when the max 0 function gets applied, say, to the first list member -3, we obtain the application max 0 (-3) which now has all the arguments that it needs; we also say that max 0 (-3) is a saturated application, which means that it’s “ready to go”. Evaluating max 0 (-3) gives 0 which becomes the first member of the result list returned by map. The other list members are calculated in an analogous fashion. It is easy to see that max 0 thus computes what mathematicians call the “positive part” of its argument x, which is x itself if it is greater than 0 and 0 otherwise.\n\nOperators aren’t special either, they are just functions in disguise. You can turn any operator into an ordinary function by enclosing it in parentheses. Thus (+) denotes the function which adds its two arguments, and x+1 can also be written as (+) x 1; in fact, the former expression is nothing but syntactic sugar for the latter. You can easily verify this in the interpreter:\n\n```> (+) x 1;\nx+1\n```\n\nYou can also have partial applications of operators like (*) 2 which denotes a function which doubles its argument:\n\n```> map ((*) 2) [1,2,3,4,5];\n[2,4,6,8,10]\n```\n\nMoreover, Pure offers some convenient syntactic sugar to denote so-called operator sections which specify a binary operator with only either its left or right operand. So the doubling function above may also be denoted as (2*) or (*2). Similarly, (+1) denotes the “increment by 1” and (1/) the reciprocal function:\n\n```> map (+1) (1..5);\n[2,3,4,5,6]\n> map (1/) (1..5);\n[1.0,0.5,0.333333333333333,0.25,0.2]\n```\n\nNote that the latter kind of section (also called a left section) is just a convenient shorthand for a partial application:\n\n```> (1/);\n(/) 1\n```\n\nThe former kind (a right section) can’t be handled this way, because it’s the first operand which is missing, and partial applications only allow you to omit trailing arguments. Instead, right sections expand to a partial application of the flip function,\n\n```> (+1);\nflip (+) 1\n```\n\nwhich is defined in the prelude as follows:\n\n```flip f x y = f y x;\n```\n\nNote that flip (+) 1 thus denotes a function which, when the missing operand is supplied, reduces to an application of the first (function) argument while also flipping around the operands. For another example, here’s how you can compute third powers 3^x of some numbers x with a right section of the ‘^‘ operator:\n\n```> map (^3) (1..5);\n[1.0,8.0,27.0,64.0,125.0]\n```\n\nNote that this is exactly the same as:\n\n```> map (flip (^) 3) (1..5);\n[1.0,8.0,27.0,64.0,125.0]\n```\n\nSuch explicit applications of flip also work with ordinary functions like pow, so if we want to compute the cubes as exact bigint numbers, we can also write:\n\n```> map (flip pow 3) (1..5);\n[1L,8L,27L,64L,125L]\n```\n\nNote the difference between flip pow 3 which computes third powers, and pow 3 which is a partial application that computes powers of 3.\n\nSometimes it is convenient to have function application as an explicit operation which can be passed as a function value to other functions. The \\$ operator is provided for this purpose. f \\$ x is just f x, so you can write, e.g.:\n\n```> map (\\$1) [(+2),(*2),(/2)];\n[3,2,0.5]\n```\n\nRecall that (\\$1) is a right section which, when applied to an argument f, evaluates to f \\$ 1 = f 1. E.g., we have that (\\$1) (+2) = (+2) \\$ 1 = (+2) 1 = 1+2 = 3. Hence the above expression actually applies a list of functions to the given argument 1.\n\nThe \\$ operator has a low precedence and is right-associative, so that it is sometimes used to eliminate the parentheses in cascading function calls. For instance, sqrt \\$ sqrt \\$ 2*3 is the same as sqrt (sqrt (2*3)).\n\nAnother convenient operation for combining functions is the function composition operator, denoted ‘.‘. It applies two functions in sequence, so that (f.g) x evaluates to f (g x). For instance:\n\n```> g x = 2*x-1;\n> map g (-3..3);\n[-7,-5,-3,-1,1,3,5]\n> map (max 0 . g) (-3..3);\n[0,0,0,0,1,3,5]\n```\n\nOperations like ‘.‘, which take functions as arguments and return other functions as results, are also called higher-order functions. We’ll have a closer look at these later.\n\nAs already mentioned, the interpreter also has a global variable environment in which you can store arbitrary expression values. This provides a means to define abbreviations for frequently-used expressions and for storing intermediate results. Global variable definitions are done with let. For instance:\n\n```> let x = 16.3805*5;\n> x;\n81.9025\n```\n\nAs we’ve explained above, functions are first-class citizens and can thus be assigned to variables as well:\n\n```> let f = sqrt;\n> f x/0.05;\n181.0\n```\n\nThe value of a global variable can be changed at any time. So we can type:\n\n```> let f = sin;\n> f x/0.05;\n4.38588407225469\n```\n\nYou can also bind several variables at once by using an expression pattern as the left-hand side of a variable definition. This is useful if we need to extract elements from an aggregate value such as a list:\n\n```> let x1:x2:xs = map (^3) (1..5);\n> x1,x2,xs;\n1.0,8.0,[27.0,64.0,125.0]\n```\n\nPure also provides a kind of “read-only” variables a.k.a. constants. They are defined pretty much like global variables (using the const keyword in lieu of let), but work more like a parameterless function whose value is precomputed at compile time:\n\n```> const π = 4*atan 1.0;\n> show π\nconst π = 3.14159265358979;\n> h x = sin (2*π*x);\n> show h\nh x = sin (6.28318530717959*x);\n> map h [-1/4,-1/8,0,1/8,1/4];\n[-1.0,-0.707106781186547,0.0,0.707106781186547,1.0]\n```\n\nNote that the compiler normally computes constant subexpressions at compile time, such as 2*π in the function h. This works with all simple scalars (machine ints and doubles), see Constant Definitions for details.\n\nAs an aside, the last example also shows that Pure has no problems with Unicode. π is a Greek letter and thus an identifier as good as any other, although you will have a hard time finding that letter on an English keyboard. Fortunately, most operating systems nowadays provide you with an applet that lets you enter foreign language characters and other special symbols with ease.\n\n### Defining Functions¶\n\nNow that we’ve learned how to run the interpreter and evaluate some expressions, it’s time to embark on some real programming. Like in other functional programming languages, we do this by defining functions which perform the desired computation. The form these definitions take in Pure is a collection of rewriting rules which specify how an application of the function reduces to another expression which then gets evaluated recursively to give the value of the function application.\n\nIn the simplest case, the left-hand side of a rewriting rule may just specify the function name along with some argument names. For instance:\n\n```square x = x*x;\n```\n\nNow, if we evaluate an expression like square 7, it reduces to 7*7 which in turn reduces to 49 by the built-in rules for integer arithmetic. You can verify this by entering the definition in the interpreter:\n\n```> square x = x*x;\n> square 7;\n49\n```\n\nIn fact, the above definition is completely generic; since x is an unqualified variable, we can apply square to any value x and have it evaluate to x*x:\n\n```> square 7.0;\n49.0\n> square 7L;\n49L\n> square (a+b);\n(a+b)*(a+b)\n```\n\nAs the last example shows, this will even work if the supplied argument is no number at all, which is useful, e.g., if we want to do symbolic evaluations.\n\nFunctions can have as many arguments as you like, subject to the constraint that each equation defining the function has the same number of arguments on the left-hand side. For instance, suppose that we want to calculate the sum of two squares. We can do this using the square function from above as follows:\n\n```> sumsquares x y = square x + square y;\n> sumsquares 3 4;\n25\n```\n\nThe interpreter keeps track of the number of arguments of each defined function, so if we accidentally try to define sumsquares with three arguments later then we’ll get an error message:\n\n```> sumsquares x y z = square x + square y + square z;\n<stdin>, line 8: function 'sumsquares' was previously defined with 2 args\n```\n\nThis actually makes perfect sense if you think about the way curried function applications work. If the above was permitted, then an expression like sumsquares x y would become ambiguous (would it denote an invocation of the binary sumsquares or a partial application of the ternary one?).\n\nThus Pure doesn’t really have variadic functions which take a variable number of arguments. There are ways to emulate this behaviour in some cases, but usually it’s easier to just pass the arguments as a single structured value instead. It is customary to employ tuples for this purpose, so that the call uses the familiar notation f (x,y,z). A typical example are optional arguments. For instance, suppose that we’d like to define a function incr which increments a numeric value, where the amount to be added can be specified as an optional second value which defaults to 1. This can be done in Pure as follows:\n\n```incr (x,y) = x+y;\nincr x = x+1 otherwise;\n```\n\nThese equations must be in the indicated order. Pure considers different equations for the same function in the order in which they are written. Therefore “special case” rules, like the one for incr (x,y) in this example, must be listed first. (Note that if the second equation came first, incr (5,2) would reduce to (5,2)+1 rather than 5+2, because x also matches, in particular, any tuple x,y.)\n\nFunctions taking a single tuple argument are also (somewhat misleadingly) called uncurried functions, because their arguments have to be given all in one go, which precludes partial applications of the function. While curried functions are often preferred, uncurried functions can be more convenient at times, e.g., if you have to map a function to a list containing given combinations of arguments. For instance, given the above definition of incr we may write:\n\n```> map incr [(5,1),(5,2),(6,3),(7,5)];\n[6,7,9,12]\n```\n\nTo make this work with curried functions, the prelude provides a function uncurry which turns a curried function of two arguments into an uncurried one which takes a single tuple argument:\n\n```> map (uncurry (+)) [(5,1),(5,2),(6,3),(7,5)];\n[6,7,9,12]\n```\n\nOn the other hand, some generic list processing functions such as foldl expect curried functions, so the reverse transformation curry is also provided:\n\n```> foldl (curry incr) 0 (1..10);\n55\n```\n\nIn fact, the definitions of curry and uncurry don’t involve any special magic, they just translate curried calls to uncurried ones and vice versa. From the horse’s mouth:\n\n```> show curry uncurry\ncurry f x y = f (x,y);\nuncurry f (x,y) = f x y;\n```\n\nA function can also have zero arguments, i.e., you can define parameterless functions such as:\n\n```foo = 1..3;\n```\n\nThe function is then simply invoked without any arguments:\n\n```> foo;\n[1,2,3]\n```\n\nIt is worth noting the difference between this and the variable definition:\n\n```let bar = 1..3;\n```\n\nWhile bar and foo yield the same result [1,2,3], they do so in different ways. bar is a global variable whose value is computed once and then stored under its name, so that the value can be simply recalled when bar is later invoked in an expression. Also, the value of bar can be changed at any time with an appropriate let statement. (If the value is not supposed to change later then you can also define it as a const instead.)\n\nIn contrast, foo is a function which recomputes the list value on each invocation. To avoid the overhead of recalculating the same value each time it is needed, a variable or constant is usually preferred over a parameterless function in Pure. However, a parameterless function will be needed if the computation involves some hidden side effects which cause a new value to be produced for each invocation. For instance, the math module provides a parameterless function random which computes a new pseudo random number each time it is called:\n\n```> using math;\n> random, random, random;\n-795755684,581869302,-404620562\n```\n\nMany functions also involve conditionals which let them take different computation paths depending on the outcome of a condition. One way to do this is to employ a conditional expression. For instance, we may compute the sign of a number as follows:\n\n```> sign x = if x>0 then 1 else if x<0 then -1 else 0;\n> map sign (-3..3);\n[-1,-1,-1,0,1,1,1]\n```\n\nAlternatively, you can also use a collection of conditional rules instead:\n\n```sign x = 1 if x>0;\n= -1 if x<0;\n= 0 otherwise;\n```\n\nNote that here we omitted the left-hand side in the second and third equations, in which case the compiler assumes that it’s the same as for the first equation; cf. Rule Syntax for details. Also note that the otherwise keyword is only syntactic sugar in Pure, you can always omit it. However, it tends to improve readability by marking the default case of a definition.\n\nBoth styles are frequently used in Pure programs; it depends on the situation which one is more appropriate. Conditional rules make the conditions stick out more clearly and hence tend to improve readability. On the other hand, conditional expressions can be nested more easily and thus facilitate the programming of complicated decision trees.\n\nFunction definitions may also be recursive, i.e., a function may invoke itself either directly or indirectly in its definition. For instance, here is a definition of the Ackerman function using conditional rules:\n\n```ack x y = y+1 if x == 0;\n= ack (x-1) 1 if y == 0;\n= ack (x-1) (ack x (y-1)) otherwise;\n```\n\nWe will have more to say about recursive functions later; see Recursion below.\n\n### Pattern Matching¶\n\nSo far we have only seen function definitions involving just unqualified variables as parameters. In general it is possible to specify arbitrary patterns for the parameters, in which case the actual arguments are checked against the patterns and, if everything matches up, the right-hand side of the rule is invoked with the variables in the patterns bound to their corresponding values.\n\nThe simplest nontrivial patterns are type tags which can be placed on a variable to restrict the type of value an argument can match. For instance:\n\n```> square x::int = x*x;\n> square 7;\n49\n```\n\nNote that in contrast to our previous generic definition of the square function we gave in Defining Functions, this definition now only applies to the case of an int argument:\n\n```> square 7.0;\nsquare 7.0\n```\n\nPolymorphic definitions can be made by giving separate equations for the different argument types. For instance, we can easily add an equation for the double case:\n\n```> square x::double = x*x;\n> show square\nsquare x::int = x*x;\nsquare x::double = x*x;\n> square 7; square 7.0;\n49\n49.0\n```\n\nHere the right-hand sides of both rules are the same. Pure has a convenient shorthand notation for this case which lets you factor out the common right-hand side using the ‘|‘ delimiter as follows:\n\n```square x::int | square x::double = x*x;\n```\n\nThe compiler expands this to the same two rules as above:\n\n```square x::int = x*x;\nsquare x::double = x*x;\n```\n\nLet’s compare this to our earlier generic definition of square:\n\n```square x = x*x;\n```\n\nThere are two different kinds of polymorphism at work here. The latter, generic definition is an example of parametric polymorphism; it applies to any type of argument x whatsoever (at least if it makes sense to multiply a member of the type with itself). Also note that this definition is “closed”; because equations are considered in the order in which they are written, there’s no way you could add another “special case” rule to this definition later.\n\nIn contrast, the former definition leaves any application of square to a value other than int or double undefined. This gives us the opportunity to define square on as many types of arguments as we like, and (this is the crucial point) define the function in different ways for different argument types. This is also known as ad-hoc polymorphism or function overloading. For instance, if we later need to square 2x2 matrices, we might add a rule like:\n\n```square {a,b;c,d} = {a*a+b*c,a*b+b*d;c*a+d*c,c*b+d*d};\n```\n\nPure places no restriction on the number of equations used to define a function, and the different equations may in fact be scattered out over many different places. So as long as the left-hand side patterns properly discriminate between the different cases, you can overload any operation in Pure to handle as many argument types as you want. However, it is important to note that in contrast to overloaded functions in statically typed languages such as C++, there’s really only one square function here which handles all the different argument types. The necessary “dispatching” to select the proper rewriting rule for the argument values at hand is done at runtime by pattern matching.\n\nParametric polymorphism has the advantage that it lets you define polymorphic functions in a very concise way. On the other hand, ad-hoc polymorphism lets you deal with disparate cases of an operation which cannot easily be reconciled. It also allows you to tailor the definition to the specific case at hand, which might be more efficient than using a generic rule. You can also combine both approaches, but in this case you have to list the special case rules before the generic ones. For instance:\n\n```square x::int | square x::double |\nsquare x = x*x;\n```\n\n(Note that the first two rules are just specialization of the last rule to int and double arguments, so we could in fact eliminate the special case rules here and still get the same results. But the type tags tell the compiler that the argument in these rules is always an int or double, respectively, so it may generate more efficient code for these cases.)\n\nPatterns may also involve constant values, in which case the constant must be matched literally in the argument. For instance, here is another definition of the Ackerman function from Defining Functions which uses constant argument patterns instead of conditional rules:\n\n```ack 0 y = y+1;\nack x 0 = ack (x-1) 1;\nack x y = ack (x-1) (ack x (y-1)) otherwise;\n```\n\nThe first two rules take care of the “base cases” x==0 and y==0. Note that these rules must be given in the indicated order to make them work. Specifically, the left-hand side ack x y of the last equation also matches, in particular, terms like ack 0 y and ack x 0, so placing the last equation before the first two will “shadow” those rules and cause non-termination, resulting in a stack overflow. Similarly, placing the second equation before the first one will cause the definition to loop on ack 0 0.\n\nAnother point that deserves mentioning here is that constants on the left-hand side of a rule must be matched literally, cf. Constant Patterns. E.g., ack 0 y only matches if the first argument is really 0, not 0.0 or 0L (although these compare equal to 0). So the above definition of ack isn’t quite the same as our previous definition from Defining Functions. If you wanted the definition above to also work with double and bigint values, you’d have to add corresponding rules for the 0.0 and 0L cases.\n\nLast but not least, patterns are also used to “deconstruct” structured values like lists, tuples and matrices, binding variables to the component values. For instance, to compute the sum of a list of values, you may write:\n\n```> sum [] = 0;\n> sum (x:xs) = x+sum xs;\n> sum (1..100);\n5050\n```\n\nThis definition works in a straightforward recursive manner. The first rule involves the constant pattern [] and thus handles the base case of an empty list, in which case the sum is zero. The second rule has a structured argument pattern x:xs which denotes a list with head element x and tail xs; in this case the result is x added to the sum of the remaining list elements xs. (In fact, this computational pattern is so common that the prelude provides a family of functions such as foldl and foldr to do this kind of operation in a generic way. Our sum function above is actually equivalent to foldr (+) 0, see List Processing below for details.)\n\nInstead of placing the patterns directly into the left-hand sides of the function definition, you might also do the necessary pattern-matching in the right hand side, by employing a case expression:\n\n```sum xs = case xs of [] = 0; x:xs = x+sum xs end;\n```\n\nThis works a bit different, though, since a case expression raises an exception if the target expression is not matched (cf. Patterns):\n\n```> sum (1:2:xs);\n<stdin>, line 2: unhandled exception 'failed_match' while evaluating 'sum (1:2:xs)'\n```\n\nTo avoid that, you may want to add a type tag, which ensures that the argument of sum is of the proper type:\n\n```sum xs::list = case xs of [] = 0; x:xs = x+sum xs end;\n```\n\nNow the case of an improper list is handled a bit more gracefully, yielding the same normal form expression you’d get with the first definition of sum above:\n\n```> sum (1:2:xs);\n1+(2+sum xs)\n```\n\nPure also allows to define sum in a more traditional way which will be familiar to Lisp programmers (note that head and tail correspond to Lisp’s “car” and “cdr”):\n\n```sum xs::list = if null xs then 0 else head xs + sum (tail xs);\n```\n\nChoosing one or the other is again a question of style. However, if you’re dealing with concrete data structures such as lists, pattern-matching definitions are often more convenient and easier to understand.\n\nPattern matching also works with user-defined constructors (cf. Data Types). For instance, here’s how to implement an insertion operation which can be used to construct a binary tree data structure useful for sorting and searching:\n\n```nonfix nil;\n\ninsert nil y = bin y nil nil;\ninsert (bin x L R) y = bin x (insert L y) R if y<x;\n= bin x L (insert R y) otherwise;\n```\n\nNote that nil needs to be declared as a nonfix symbol here, so that the compiler doesn’t mistake it for a variable; see The “Head = Function” Rule for details. The following example illustrates how the above definition may be used to obtain a binary tree data structure from a list:\n\n```> tree [] = nil;\n> tree (x:xs) = insert (tree xs) x;\n> tree [7,12,9,5];\nbin 5 nil (bin 9 (bin 7 nil nil) (bin 12 nil nil))\n```\n\nConversely, it’s also easy to convert such a tree structure back to a list. We can then combine these operations to sort a list in ascending order:\n\n```> list nil = [];\n> list (bin x L R) = list L + (x:list R);\n> list (tree [7,12,9,5]);\n[5,7,9,12]\n```\n\n### Local Functions and Variables¶\n\nUp to this point our examples only involved global functions and variables. When the problems to be solved become more difficult, it will be necessary to structure the solution in some way, so that you’ll often end up with many small functions which need to work in concert to solve the problem at hand. Typically only a few of these functions will serve as actual entry points, while other functions are only to be used internally. Pure supports this through local functions and variables whose scope is limited either to the right-hand side of a rule or one of its subexpression. This offers two main advantages:\n\n• Local functions and variables are hidden from the main scope so that they can only be used in the context where they are needed and don’t clutter up the global environment. This provides a way to define functions in a modular fashion while hiding internal details from the rest of the program.\n• The right-hand sides of local definitions have full access to other local functions and variables in their parent environments, which eliminates the “plumbing” which would otherwise be needed to pass these values around. For instance, a local function nested in another function can freely access the parent function’s arguments and other local variables in its scope.\n\nLocal functions are defined using the with construct, while local variables can be introduced with a when or case expression, see Special Expressions for details. These constructs can be tacked on to any expression, and they can also be nested. For instance:\n\n```> f 5 with f x = y+y when y = x*x end end;\n50\n```\n\nNote that the local function f there computes twice the square of its argument x. To these ends, first x*x is assigned to the local variable y whose value is then doubled by computing y+y which becomes the result of f.\n\nLocal functions can also be created without actually naming them, by employing a so-called lambda abstraction. For instance, a function which squares its argument might be denoted as \\x -> x*x. This is pretty much the same as a local function f with f x = x*x end except that the function remains nameless. This notation is pretty convenient for making up little “one-off” functions which are to be applied on the spot or passed as function arguments or results to other functions. For instance, here’s how you can compute the first ten squares, first with an ordinary (named) local function, and then with an equivalent lambda:\n\n```> map f (1..10) with f x = x*x end;\n[1,4,9,16,25,36,49,64,81,100]\n> map (\\x -> x*x) (1..10);\n[1,4,9,16,25,36,49,64,81,100]\n```\n\nFor obvious reasons lambdas work best for non-recursive functions. While there are techniques to create recursive functions out of lambdas using so-called fixed point combinators (cf. fix), named functions are much more convenient for that purpose.\n\nPattern matching works in local definitions as usual. For instance, here are several ways to swap two values represented as a tuple, using either a local function or a when or case expression:\n\n```> swap (1,2) with swap (x,y) = y,x end;\n2,1\n> (\\(x,y) -> y,x) (1,2);\n2,1\n> y,x when x,y = 1,2 end;\n2,1\n> case 1,2 of x,y = y,x end;\n2,1\n```\n\nYou’ll also frequently find code like the following, where a global “wrapper” function just sets up some initial parameter values and then invokes a local “worker” function which does all the real work. The following function calculates the sum of the positive integers up to n (the “accumulating parameters” technique used in this example will be explained later, cf. Recursion).\n\n```sum n = sum 0 n with\nsum s n = s if n < 0;\n= sum (s+n) (n-1) otherwise;\nend;\n```\n\nNote that there are actually two separate functions named sum here. This works because according to the scoping rules the right-hand side of the global definition is under the scope of the with clause, and thus the call sum 0 n on the right-hand refers to the local sum function, not the global one. (While it is perfectly correct and even makes sense in this example, this style may be somewhat confusing, so we often prefer to give wrapper and worker different names for clarity.)\n\nAs discussed in Scoping Rules, a local function can refer to other local functions and variables in its parent environments. It can also be returned as a function value, which is where things get really interesting. The local function value then becomes a lexical closure which carries around with it the local variable environment it was created in. For instance:\n\n```> adder x = add with add y = x+y end;\n> let g = adder 5; g; map g (1..5);\n[6,7,8,9,10]\n```\n\nNote that here the local function add refers to the argument value x of its parent function adder. The invocation adder 5 thus returns an instance of add which has x bound to the value 5, so that add y reduces to 5+y for each y. This works as if this instance of the add closure had an invisible x argument of 5 attached to it. (And this is in fact how closures are implemented internally, using a transformation called lambda lifting which effectively turns local functions into global ones.) You should study this example carefully until you fully understand how it works; we’ll see a bunch of other, more complicated examples of this kind later.\n\nLexical closures also provide a means to encapsulate data in a way reminiscent of object-oriented programming. For instance:\n\n```nonfix coords;\n\npoint (x,y) = \\msg -> case msg of\ncoords = x,y;\nmove (dx,dy) = point (x+dx,y+dy);\nend;\n```\n\nThe anonymous function returned by point in fact works like an “object” which can be queried for its coordinates and moved by a given offset through corresponding “messages” passed as arguments to the object:\n\n```> let p = point (1,2); p;\n#<closure 0x7f420660e658>\n> p coords; p (move (2,3)) coords;\n1,2\n3,5\n```\n\nNote that this still lacks some typical features of object-oriented programming such as mutability and inheritance. It isn’t really hard to add these, but this requires the use of some of Pure’s more advanced machinery which we didn’t discuss yet. For instance, mutability can be implemented in Pure by using so-called expression references, a kind of mutable storage cells which can hold arbitrary expression values:\n\n```> let x = ref 99; get x;\n99\n> put x 2;\n2\n> get x;\n2\n```\n\nUsing these we can rewrite our definition of the point object as follows:\n\n```nonfix coords;\n\npoint (x,y) = (\\msg -> case msg of\ncoords = get x, get y;\nmove (dx,dy) = put x (get x+dx), put y (get y+dy);\nend) when\nx,y = ref x,ref y;\nend;\n```\n\nNote that the coordinates are kept in corresponding expression references assigned to the local x and y variables, which now shadow the x and y arguments of point. This makes it possible to have move actually modify the point object in-place:\n\n```> let p = point (1,2); p coords;\n1,2\n> p (move (2,3)); p coords;\n3,5\n3,5\n```\n\nIt goes without saying that this style isn’t preferred in functional programs, but it certainly has its uses, especially when interfacing to imperative code written in other languages such as C.\n\n### Data Types¶\n\nBefore we consider the more advanced uses of functions in Pure, a few remarks about data types are in order. Like Lisp, Pure is basically a “typeless” language. That doesn’t mean that there are no data types; in fact, they’re a dime a dozen in Pure. But Pure lets you make up your own data structures as you go, without even formally defining a data type. Data types can be defined and associated with a name pretty much in the same way as functions, but that’s just a convenience and completely optional. This sets Pure apart from statically typed languages like ML and Haskell, where explicit data type definitions are mandatory if you want to introduce new data structures.\n\nAs we’ve seen, Pure knows about a few built-in types such as numbers, strings, symbols and functions; everything else is a function application. If a symbol is defined as a function, which merely means that there are some rewriting rules for it, then an application of that function to some arguments may evaluate to something else. But if it doesn’t, then Pure is perfectly happy with that; it just means that the function application is in normal form and thus becomes a “value”. For instance:\n\n```> cons 3 (cons 5 nil);\ncons 3 (cons 5 nil)\n```\n\nThere’s nothing mysterious about this; the cons and nil symbols being used here aren’t defined anywhere, and thus any terms constructed with these symbols are just “data”, no questions asked. We also call such symbols constructors. (Note that these are different from constructors in object-oriented programming; constructor applications in term rewriting and functional programming normally don’t execute any code, they’re just literal data objects.)\n\nWe can now go ahead and define some operations on this kind of data. (To these ends, it’s necessary to declare nil as a nonfix symbol so that we can use it as a literal in patterns; cf. Pattern Matching.)\n\n```nonfix nil;\n\n#nil = 0;\n#cons x xs = #xs+1;\n\nhead (cons x xs) = x;\ntail (cons x xs) = xs;\n\nnil + ys = ys;\ncons x xs + ys = cons x (xs + ys);\n```\n\nEt voilà, we’ve just created our own list data structure! It’s admittedly still a bit paltry, but if we keep at it and define all the other functions that we need then we could turn it into a full-blown replacement for Pure’s list data structure. In fact Pure’s lists work in a very similar fashion, using the infix ‘:‘ constructor and the empty list [] in lieu of cons and nil, respectively.\n\nIf we want, we can define a new data type for the data structure we just invented. This works by giving a number of type rules similar to those used in function definitions. In general, these may denote arbitrary unary predicates, but in our case it’s sufficient to just list the patterns of terms which are supposed to be members of the type (see Type Rules for an explanation of the definition syntax):\n\n```type mylist nil | mylist (cons x xs);\n```\n\nThis definition lets us use the mylist type as a tag on the left-hand side of an equation, cf. Pattern Matching. But if we’re content with using the patterns directly then we might just as well do without that.\n\nTypes consisting solely of constructor term patterns are sometimes also called algebraic types. In fact, most user-defined data structures are algebraic types in Pure, and there are plenty of examples of these in the standard library as well. In particular, lists and tuples are algebraic types, as are complex and rational numbers, and most of Pure’s container data types such as dictionaries and sets are also implemented as algebraic types.\n\nPure differs from most functional languages in that symbols may act as both constructors and defined functions, depending on the arguments. Thus Pure allows you to have “constructors with equations”. For instance:\n\n```cons nil ys = ys;\ncons (cons x xs) ys = cons x (cons xs ys);\n```\n\nNow cons has become a (partially) defined function. Note that these rules make cons associative and turn nil into a left-neutral element for cons. This in fact makes cons behave like concatenation, so that our lists are always flat now:\n\n```> cons (cons 1 (cons 2 nil)) (cons 3 nil);\ncons 1 (cons 2 (cons 3 nil))\n```\n\nExamples of such constructor equations can be found in the standard library as well, such as the rules used to flatten tuples, keep rational numbers in lowest terms, or confine the angles of complex numbers in polar notation.\n\nAnother possible use of constructor equations is to check the well-formedness of constructor terms. For instance, in our example we might want to preclude terms like cons 1 2 which don’t have a mylist in the second argument to cons. This can be done with a constructor equation which raises an exception in such cases (cf. Exception Handling):\n\n```> cons x y = throw (bad_mylist y) if ~typep mylist y;\n> cons 1 2;\n<stdin>, line 18: unhandled exception 'bad_mylist 2' while evaluating 'cons 1 2'\n```\n\nA specific kind of algebraic data types which are useful in many applications are the enumerated types. In this case the type consists of symbolic constants (nonfix symbols) only, which are the elements of the type. For instance:\n\n```nonfix sun mon tue wed thu fri sat;\ntype day sun | day mon | day tue | day wed | day thu | day fri | day sat;\n```\n\nHowever, to make this type actually work as an enumerated type, we may want to provide definitions for basic arithmetic, ord, succ, etc. This is rather straightforward, but tedious. So as of Pure 0.56, the standard library provides a little utility module, enum, which generates the necessary definitions in an automatic fashion. All we have to do is to import the module and then invoke the enum function on the type and we’re set:\n\n```using enum;\nenum day;\n```\n\nIt’s also possible to define the type and make it enumerable in one go using the defenum function:\n\n```defenum day [sun,mon,tue,wed,thu,fri,sat];\n```\n\nIn either case, we can now perform calculations with the members of the type just like with other predefined enumerated types such as numbers and characters:\n\n```> ord sun;\n0\n> day (ans+3);\nwed\n> pred sat;\nfri\n> sun+3;\nwed\n> fri-2;\nwed\n> fri-tue;\n3\n> mon..fri;\n[mon,tue,wed,thu,fri]\n> sun:tue..sat;\n[sun,tue,thu,sat]\n> sat:fri..mon;\n[sat,fri,thu,wed,tue,mon]\n```\n\nA more abstract way to define algebraic types are the interface types. For instance, if we take another look at the operations defined on our list type, we may observe that the data structure is quite apparent from the patterns in the rules of operations such as ‘#‘ and ‘+‘. Pure lets us leverage that information by creating an algebraic type from a collection of operation patterns it supports. For instance, we may write:\n\n```interface list_alike with\n#x::list_alike;\nx::list_alike + y;\nend;\n```\n\nThis defines a generic type consisting of all terms which may be passed as an argument to both ‘#‘ and ‘+‘. We can ask the interpreter about the patterns actually matched by the type as follows:\n\n```> show interface list_alike\ntype list_alike s::string;\ntype list_alike [];\ntype list_alike (x:xs);\ntype list_alike nil;\ntype list_alike (cons x xs);\n```\n\nNote that the list_alike type not only includes our own list type, but also any other data structure providing the ‘#‘ and ‘+‘ operations. This also comprises the standard list and string types for which there are definitions of the ‘#‘ and ‘+‘ operations in the prelude.\n\nPure’s interface types are a first attempt at formalizing the notion of Duck typing in Pure. They are thus still a bit experimental and require some diligence in defining the interface operations in a suitable way. Please check Interface Types in the Declarations section for more information and examples.\n\n### Recursion¶\n\nRecursion means that a function calls itself, either directly or indirectly. It is one of the most fundamental techniques in functional programming, and you won’t find many useful Pure programs which don’t use it in one form or another. That’s because most interesting programs execute pieces of code repeatedly. Pure doesn’t have any special looping constructs, so recursion is the only way to do this in Pure. We’ve already seen various examples of this throughout the manual, so let’s take a closer look at it now and learn a few related tricks along the way.\n\nFor a simple example, consider the factorial. In order to compute the factorial of an integer n, we need to multiply the positive integers up to n. There’s a straightforward recursive definition which does this:\n\n```fact n = if n>0 then n*fact (n-1) else 1;\n```\n\nIf you prefer conditional rules instead, you can also write:\n\n```fact n = n*fact (n-1) if n>0;\n= 1 otherwise;\n```\n\nIt’s not hard to see how this definition operates. The first rule only applies if n>0, otherwise the second rule kicks in so that fact n becomes 1 if n is zero or negative (which is consistent with our informal description because in this case the product of all positive integers up to n is the empty product which is 1 by mathematical convention). The first rule is the interesting one where the recursion happens. If n>0 then we may compute fact n by computing fact (n-1) recursively and multiplying that with n, giving n*(n-1)*...*1. Let’s check that this works:\n\n```> map fact (1..10);\n[1,2,6,24,120,720,5040,40320,362880,3628800]\n```\n\nNote that these numbers grow fairly quickly; they outgrow the 32 bit range and start wrapping around already at n==13. To avoid that, you’ll have to do the computation with bigints, or you could use floating point values if you don’t mind the limited precision.\n\n```> fact 13;\n1932053504\n> fact 13L;\n6227020800L\n> fact 30L;\n265252859812191058636308480000000L\n> fact 30.0;\n2.65252859812191e+32\n```\n\nHowever, you’ll run into another, more serious obstacle if you want to compute factorials for some really big values of n. For instance:\n\n```> fact 200000L;\n<stdin>, line 7: unhandled exception 'stack_fault' while evaluating 'fact 200000L'\n```\n\nOops. What happened there? Well, each recursive invocation of fact needs some small amount of memory on the execution stack, a so-called “stack frame”. Thus, when n becomes big enough then our definition is in danger of running out of stack space. (This is also why you keep hearing in most CS 101 courses that you should try to avoid recursion. If you’ve forgotten how subroutine calls are executed by keeping the execution context on a stack then it’s time to revisit those CS 101 lecture notes now.)\n\nSo how can we avoid using all that stack space? In a language like C we’d be using a specialized loop construct instead of recursion, e.g.:\n\n```int fact(int n)\n{\nint p = 1;\nwhile (n>0) { p = n*p; n = n-1; }\nreturn p;\n}\n```\n\nPure doesn’t have a while loop, but we can rewrite the definition so that it becomes tail-recursive. This means that the recursive call becomes the final operation on the right-hand side of the recursive rule. The Pure compiler treats this pretty much like a loop in traditional programming languages.\n\nThe trick of the trade to turn a recursive function into a tail-recursive one is the accumulating parameter technique. The idea here is to have a separate “worker” function which carries around an extra argument representing the intermediate result for the current iteration. The final value of that parameter is then returned as the result. In the case of the factorial this can be done as follows:\n\n```fact n = loop n 1 with\nloop n p = loop (n-1) (n*p) if n>0;\n= p otherwise;\nend;\n```\n\nNote that fact has now become a simple “wrapper” which supplies the initial value of the accumulating parameter (p in this case) for the “worker” function loop which does all the hard work. This kind of design is fairly common in functional programs.\n\nOur worker function is tail-recursive since the recursive call to loop is indeed the final call on the right-hand side of the first equation defining loop. The Pure compiler generates code which optimizes such “tail calls” so that they reuse the stack frame of the calling function. Thus a tail-recursive function like loop will execute in constant stack space; in fact it will be just as efficient as the while loop in our little C snippet above (up to constant factors, of course). After entering our new definition of fact we can now compute fact 200000L just fine (this may take a little while, though, depending on how fast your computer is; the result has 973351 digits):\n\n```> fact 200000L;\n14202253454703144049669463336823059760899... // lots of digits follow\n```\n\nThe accumulating parameter technique isn’t fully general, but it covers all the kinds of simple iterative algorithms which you’d do using loop constructs in traditional programming languages. Some algorithms may require additional techniques such as tabulation (keeping track of some or all intermediate results), however, so that they can be written in an iterative form. To see how this can be done in Pure, let’s consider the Fibonacci numbers. These can be computed with the following naive recursive definition:\n\n```fib n = if n<=1 then n else fib (n-2) + fib (n-1);\n```\n\nHere are some members of this famous sequence:\n\n```> map fib (0..20);\n[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765]\n```\n\nNote that the right-hand side of the definition above involves two recursive invocations of fib in the else branch. This is bad because it means our definition will need exponential running time. (More precisely, you’ll find that the ratio between the running times of successive invocations quickly starts approaching the golden ratio φ = 1.618..., which is no accident because the times are proportional to the Fibonacci function itself!)\n\nUsing a simple iterative algorithm, it is possible to calculate the Fibonacci numbers in linear time instead. Observe that each member of the sequence is simply the sum of the two preceding members. If we keep track of the last two members of the sequence then we can compute the next member with a single addition. This yields the following tail-recursive implementation which uses the same kind of “wrapper-worker” design:\n\n```fib n = loop n 0L 1L with\nloop n a b = loop (n-1) b (a+b) if n>0;\n= a otherwise;\nend;\n```\n\nNote that as a matter of prudence we primed the iteration with the bigints 0L and 1L so that we can compute large Fibonacci numbers without suffering wrap-around. For instance, try the following:\n\n```> fib 1000000;\n1953282128707757731632014947596256332443... // lots of digits follow\n```\n\nRecursion also naturally occurs when traversing recursive data structures. We’ve already seen various examples of these, such as the binary tree data structure:\n\n```nonfix nil;\n\ninsert nil y = bin y nil nil;\ninsert (bin x L R) y = bin x (insert L y) R if y<x;\n= bin x L (insert R y) otherwise;\n```\n\nThe insert function implements a binary tree insertion algorithm which keeps the tree (represented with the bin and nil constructor symbols) sorted. To these ends, it recurses into the left or right subtree, depending on whether the element y to be inserted is less than the current element x or not. The final result is a new tree which has a nil subtree replaced with a new bin y nil nil subtree at the right location.\n\nIf we do an inorder traversal of such a binary tree (at each non-nil subtree, first visit the left subtree, then note the element at the top of the current subtree, and finally visit the right subtree), we obtain the elements of the tree in ascending order. This traversal is also implemented recursively, e.g., as follows:\n\n```list nil = [];\nlist (bin x L R) = list L + (x:list R);\n```\n\nNote that these functions can’t be made tail-recursive using the accumulating parameter technique, because traversing a tree structure requires more general forms of recursion. There is in fact a more general continuation passing technique to do this, which we will look at in The Same-Fringe Problem below; alas, it’s not as easy as accumulating parameters. Fortunately, some important recursive structures such as lists only involve simple recursion and can thus be traversed and manipulated in a tail-recursive fashion more easily. For instance, consider our earlier definition of the sum function:\n\n```sum [] = 0;\nsum (x:xs) = x+sum xs;\n```\n\nThis definition isn’t tail-recursive, but we can easily massage it into this form using the accumulating parameter technique:\n\n```sum xs::list = loop 0 xs with\nloop s [] = s;\nloop s (x:xs) = loop (s+x) xs;\nend;\n```\n\nFunctions can also be mutually recursive, in which case two or more functions are defined in terms of each other. For instance, suppose that we’d like to skip every other element of a list (i.e., return a list with only the elements having either even or odd indices, respectively). One way to do this involves two functions (named pick and skip here) which recursively call each other:\n\n```> pick [] = []; pick (x:xs) = x:skip xs;\n> skip [] = []; skip (x:xs) = pick xs;\n> pick (1..10);\n[1,3,5,7,9]\n> skip (1..10);\n[2,4,6,8,10]\n```\n\n#### A Numeric Root Finder¶\n\nLet’s now see how we can apply the techniques explained above in the context of a somewhat more practical example: a numeric root finder. That is, we’re going to write a function which takes another function f and determines a (double) value x such that f x becomes (close to) zero.\n\nWe’ll develop this in a bottom-up fashion. The method we employ here is known as the Newton-Raphson algorithm, whose basic building block is the following routine improve which improves a given candidate solution x by computing a first-order approximation of the root. This involves computing (a numeric approximation of) the first derivative at the given point, which we do using a second function derive:\n\n```improve f x = x - f x / derive f x;\nderive f x = (f (x+dx) - f x) / dx;\n```\n\nIf you still remember your calculus then these should look familiar. Note that in both functions, f is our target function to be solved and x the current candidate solution. The second equation is nothing but the difference quotient of the function at the point x, using dx as the increment along the x axis. The improve function computes the intersection of the corresponding secant of f with the x axis.\n\nTo illustrate how the method works, let’s perform a few improvement steps manually, using the target function f x = x*x-2 which becomes zero at the square root of 2. Here we choose a dx value of 1e-8 and start from the initial guess 2:\n\n```> let dx = 1e-8;\n> improve f x = x - f x / derive f x;\n> derive f x = (f (x+dx) - f x) / dx;\n> f x = x*x-2;\n> improve f 2;\n1.49999999696126\n> improve f ans;\n1.41666666616021\n> improve f ans;\n1.41421568628522\n> improve f ans;\n1.41421356237468\n```\n\nIt should be apparent by now that this converges to the square root of 2 rather quickly. To automate this process, we need another little helper function which iterates improve until the current candidate solution is “good enough”. A suitable termination criterion is that the improvement drops below a certain threshold (i.e., abs (x-f x) <= dy for some reasonably small dy). For extra safety, we’ll also bail out of the loop if a prescribed number n of iterations has been performed. This function can be implemented in a tail-recursive fashion as follows:\n\n```loop n f x = x if n <= 0;\n= if abs (x-y) < dy then y else loop (n-1) f y when y = f x end;\n```\n\nLet’s give it a try:\n\n```> let dy = 1e-12;\n> loop n f x = x if n <= 0;\n> = if abs (x-y) < dy then y else loop (n-1) f y when y = f x end;\n> loop 20 (improve dx f) 2;\n1.4142135623731\n> ans*ans;\n2.0\n```\n\nLooks good. So let’s finally wrap this up in a main entry point solve which takes the function to be solved and an initial guess as parameters. Our little helper functions improve, derive and loop are only used internally, so we can turn them into local functions of solve. The additional parameters of the algorithm are implemented as global variables so that we can easily modify their values if needed. The end result looks as follows. Note that the initial guess x is an implicit parameter of the solve function, so the function actually gets invoked as solve f x.\n\n```let dx = 1e-8; // delta value for the approximation of the derivative\nlet dy = 1e-12; // delta value for testing convergence\nlet nmax = 20; // maximum number of iterations\n\nsolve f = loop nmax (improve f) with\nloop n f x = x if n <= 0;\n= if abs (x-y) < dy then y else loop (n-1) f y when y = f x end;\nimprove f x = x - f x / derive f x;\nderive f x = (f (x+dx) - f x) / dx;\nend;\n```\n\nHere are some examples showing how the solve function is used. Note that we specify the target functions to be solved as lambdas here. E.g., \\t -> t^3-x denotes a function mapping t to t^3-x, which becomes zero if t equals the cube root of x.\n\n```> sqrt x = solve (\\t -> t*t-x) x;\n> sqrt 2; sqrt 5;\n1.4142135623731\n2.23606797749979\n> cubrt x = solve (\\t -> t^3-x) x;\n> cubrt 8;\n2.0\n```\n\nOur little root finder isn’t perfect. It needs a fairly well-behaved target function and/or a good initial guess to work properly. For instance, consider:\n\n```> solve (\\t -> 1/t-2) 1;\n0.00205230175365927\n```\n\nHere solve didn’t find the real root at 0.5 at all. In fact, if you print the solution candidates then you will find that solve converges rather slowly in this case and thus bails out after 20 iterations before a good solution is found. Increasing the nmax value fixes this:\n\n```> let nmax = 50;\n> solve (\\t -> 1/t-2) 1;\n0.5\n```\n\nThere are other pathological cases where the algorithm performs even more poorly. Further improvements of the method presented here can be found in textbooks on numeric algorithms; the interested reader may want to cut his teeth on these algorithms by translating them to Pure in the way we’ve shown here.\n\n#### The Same-Fringe Problem¶\n\nThis is one of the classical problems in functional programming which has a straightforward recursive solution, but needs some thought if we want to solve it in an efficient way. Consider a (rooted, directed) tree consisting of branches and leaves. To keep things simple, we may represent these structures as nested lists, e.g.:\n\n```let t1 = [[a,b],c,[[d]],e,[f,[[g,h]]]];\nlet t2 = [a,b,c,[[d],[],e],[f,[g,[h]]]];\nlet t3 = [[a,b],d,[[c]],e,[f,[[g,h]]]];\n```\n\nThus each inner node of the tree is represented as a list containing its (zero or more) subtrees, and the leaves are the “atomic” (non-list) elements. The fringe of such a structure is the list of all leaves in left-to-right order, which can be computed as follows:\n\n```fringe t = if listp t then catmap fringe t else [t];\n```\n\nNote that listp is a predicate which decides whether its argument is a (proper or improper) list and the catmap function applies the given function to a list, like map, and concatenates all the resulting lists, like cat. Thus, if the argument t is an “atom” (leaf) then fringe simply returns [t], otherwise it recursively applies itself to all the subtrees and concatenates the results:\n\n```> fringe t1;\n[a,b,c,d,e,f,g,h]\n> fringe t2;\n[a,b,c,d,e,f,g,h]\n> fringe t3;\n[a,b,d,c,e,f,g,h]\n```\n\nNote that t1 and t2 differ in structure but have the same fringe, while t1 and t3 have the same structure but different fringes. The problem now is to decide, given any two trees, whether they have the same fringe. Of course, we can easily solve this by just computing the fringes and comparing them with ‘===‘ (note that we employ syntactic equality here which also allows us to compare symbols, for which ‘==‘ isn’t normally defined):\n\n```> fringe t1 === fringe t2;\n1\n> fringe t3 === fringe t2;\n0\n```\n\nHowever, this is rather inefficient since we always have to fully construct the fringes which may need considerable extra time and space if the trees are large. Most of this effort may be completely wasted if we only need to inspect a tiny fraction of the fringes to find out that they’re different, as in the case of t2 and t3. Also note that our version of the fringe function isn’t tail-recursive and we may thus run into stack overflows for large trees.\n\nThis problem, while posed in an abstract way here, is not only of academic interest. For instance, trees may be used as an alternative string data structure which implements concatenation in constant time by just delaying it. In this case we certainly don’t want to explicitly carry out all those concatenations in order to decide whether two such objects are the same.\n\nTherefore, this problem has been studied extensively and more efficient approaches have been developed. One way to solve the problem involves the technique of continuation passing which is a generalization of the accumulating parameter technique we already discussed. It never constructs any part of the fringes explicitly and also works in constant stack space. The algorithm can be implemented in Pure as follows. (This is a slightly modified transliteration of a Lisp program given in Henry Baker’s article “Iterators: Signs of Weakness in Object-Oriented Languages”, ACM OOPS Messenger 4(3), 1993, pp. 18-25, which is also available from Henry Baker’s Archive of Research Papers.)\n\n```samefringe t1 t2 =\nsamefringe (\\c -> genfringe t1 c done) (\\c -> genfringe t2 c done) with\ndone c = c [] done;\nsamefringe g1 g2 =\ng1 (\\x1 g1 -> g2 (\\x2 g2 -> x1===x2 && (x1===[] || samefringe g1 g2)));\ngenfringe [] c g = g c;\ngenfringe (x:t) c g = genfringe x c (\\c -> genfringe t c g);\ngenfringe x c g = c x g;\nend;\n```\n\nAs Baker admits himself, this style of programming isn’t “particularly perspicuous”, so we’ll explain the algorithm in a moment. But first let us verify that the program indeed works as advertized. It’s helpful to print out the actual comparisons performed in the innermost lambda in the definition of the local samefringe function, which can be done by adding a little debugging statement as follows (this also needs an import clause “using system;” to make the printf function available):\n\n```samefringe g1 g2 =\ng1 (\\x1 g1 -> g2 (\\x2 g2 -> printf \"%s === %s?\\n\" (str x1,str x2) \\$\\$\nx1===x2 && (x1===[] || samefringe g1 g2)));\n```\n\nWith this we get:\n\n```> samefringe t1 t2;\na === a?\nb === b?\nc === c?\nd === d?\ne === e?\nf === f?\ng === g?\nh === h?\n[] === []?\n1\n```\n\nSo in this case we do a complete traversal of both trees which is the best that we can hope for if the fringes are the same. Note that the final comparison [] === [] ensures that we also hit the end of the two fringes at the same time. This test deals with the corner case that one fringe is a prefix of the other. For instance:\n\n```> let t4 = [[a,b],c,[[d]],e,[f,[[g,h,i]]]];\n> samefringe t4 t2;\na === a?\nb === b?\nc === c?\nd === d?\ne === e?\nf === f?\ng === g?\nh === h?\ni === []?\n0\n```\n\nThings go a bit differently, however, when comparing t3 and t2; as soon as we hit the first discrepany between the two fringes, the algorithm bails out and correctly asserts that the fringes are different:\n\n```> samefringe t3 t2;\na === a?\nb === b?\nd === c?\n0\n```\n\nLet’s take a closer look at the various parts of the algorithm now. First, the genfringe function:\n\n```genfringe [] c g = g c;\ngenfringe (x:t) c g = genfringe x c (\\c -> genfringe t c g);\ngenfringe x c g = c x g;\n```\n\nThis routine generates the fringe of a tree, given as the first argument, on the fly. The second argument c (the “consumer”) is a function which gets invoked on the current leaf, to do any required processing. (As we’ll see later, it may also get invoked with the special “sentinel” value [] to indicate the end of the fringe.)\n\nThe third argument g (the “generator”) is a continuation, a kind of “callback function” to be invoked after the current subtree has been traversed, in order to process the remainder of the tree. It takes the consumer function c as its sole argument. Consequently, genfringe simply invokes the continuation g on the consumer c when applied to an empty subtree [], i.e., if there aren’t any leaves to be processed. This case is handled in the first equation for genfringe.\n\nThe second equation for genfringe is the interesting one where the recursion happens. It deals with a nonempty tree x:t by invoking itself recursively on x, setting up a new continuation \\c -> genfringe t c g, which will take care of processing the rest of the subtree t, after which it chains to the previous continuation g which will handle the rest of the tree.\n\nThe third equation for genfringe handles the case of a non-list argument, i.e., a leaf. In this case we just pass the leaf x to the consumer function c along with the continuation g. The consumer processes x as needed and may then decide to call the continuation g on itself in order to continue processing the rest of the tree, or simply bail out, returning any value. Note that this entire process is tail-recursive, as long as c chains to g as the last call. It thus only needs constant stack space in addition to what c itself uses.\n\nNote that we need an initial continuation g to get the process started. This is provided by the done function:\n\n```done c = c [] done;\n```\n\nAs we’ve defined it, done invokes the consumer c on an empty list to signal the end of the fringe. For good measure, it also passes itself as the continuation argument; however, normally the consumer will never use this argument and just bail out when invoked on the [] value.\n\nTo see how this works, we can just enter done and genfringe as global functions and invoke them on a suitable consumer function, e.g.:\n\n```> done c = c [] done;\n> genfringe [] c g = g c;\n> genfringe (x:t) c g = genfringe x c (\\c -> genfringe t c g);\n> genfringe x c g = c x g;\n> c x g = if x===[] then g else printf \"%s... \" (str x) \\$\\$ g c;\n> genfringe t1 c done;\na... b... c... d... e... f... g... h... done\n```\n\nIn the case of samefringe, we use the local samefringe function as our consumer instead. This works pretty much the same, except that samefringe employs two continuations g1 and g2 to traverse both trees at the same time:\n\n```samefringe g1 g2 =\ng1 (\\x1 g1 -> g2 (\\x2 g2 -> x1===x2 && (x1===[] || samefringe g1 g2)));\n```\n\nNote that the outer lambda (\\x1 g1 -> ...) becomes the consumer for the first generator g1 which traverses t1. When called, it then invokes the second generator g2, which traverses t2, on the consumer (inner lambda) (\\x2 g2 -> ...). This in turn does the necessary tests to verify that the current leaf elements are the same, or to bail out from the recursion if they aren’t or if we reached the end of the fringes. Also note that this is still tail-recursive because the short-circuit logical operations && and || are both tail-recursive in their second operand (cf. Stack Size and Tail Recursion).\n\n### Higher-Order Functions¶\n\nAs we have seen, functions are first-class citizens in Pure which can be created on the fly (using partial applications as well as lambdas and local functions), assigned to variables and passed around freely as function arguments and results. Thus it becomes possible to define higher-order functions which take other functions as arguments and/or return them as results. This is generally considered a hallmark feature of functional programming, and much of the power of functional programming stems from it. In fact, higher-order functions are so deeply ingrained in the modern functional programming style that you’ll hardly find a nontrivial program that doesn’t use them in some way, and we have already seen many examples of them throughout the manual. While most imperative programming languages today let you treat functions as values, too, they’re typically much more limited in the ways that new functions can be created dynamically. Only recently have partial application and anonymous closures arrived in some mainstream imperative languages, and they are often still rather awkward to use.\n\nThe simplest case of a higher-order function is a function which takes another function as an argument. For instance, we have seen the function map which applies a function to each member of a list. If it wasn’t in the prelude, it could be defined as follows:\n\n```map f [] = [];\nmap f (x:xs) = f x : map f xs;\n```\n\n(Note that this isn’t the actual definition from the prelude, which goes to some lengths to make the operation tail-recursive and properly handle lazy lists. But we won’t dive into these technicalities here since we’re only interested in the higher-order aspect right now.)\n\nThis definition is rather straightforward: To map a function f to a list, just apply it to the head element x and recurse into the tail xs. The recursion stops at the empty list which is returned as is. For instance:\n\n```> map (*2) (0..10);\n[0,2,4,6,8,10,12,14,16,18,20]\n```\n\nThe prelude includes an entire collection of such generic list functions which have proven their utility as basic building blocks for many list processing tasks. We’ll have a closer look at these later, see List Processing.\n\nAnother numerical example is the function derive which we used in our root finder example to calculate the difference quotient of a function f at a given point x:\n\n```derive f x = (f (x+dx) - f x) / dx;\n```\n\nThis example is also interesting because we can turn derive into a function mapping functions to other functions, by partially applying it to the target function. So we may write:\n\n```> let dx = 1e-8;\n> map (derive square) (1..4) with square x = x*x end;\n[1.99999998784506,3.99999997569012,5.99999996353517,7.99999995138023]\n```\n\nThis illustrates an easy way to create new functions from existing ones: partial application. (In fact we also did that when we applied the operator section (*2) using map above. Note that (*2) is a function which doubles its single argument.) This simple recipe is surprisingly powerful. For instance, the prelude defines the function composition operator ‘.‘ as:\n\n```(f.g) x = f (g x);\n```\n\nThe partial application f.g thus applies two given functions f and g in sequence (first g, then f). Functions of this kind, which create new functions by combining existing ones, are also known as combinators. For instance, using ‘.‘ we can easily create a function which “clamps” its argument between given bounds by just combining the min and max functions from the prelude as follows:\n\n```> clamp a b = max a . min b;\n> map (clamp (-3) 3) (-5..5);\n[-3,-3,-3,-2,-1,0,1,2,3,3,3]\n```\n\nNote that partial application works with constructor symbols, too:\n\n```> map (0:) [1..3,4..6,7..9];\n[[0,1,2,3],[0,4,5,6],[0,7,8,9]]\n```\n\nAnother more direct way to define combinators is to make them return a local or anonymous function. For instance, the following equations lift the ‘+‘ and ‘-‘ operators to pointwise operations:\n\n```f + g = \\x -> f x + g x if nargs f > 0 && nargs g > 0;\nf - g = \\x -> f x - g x if nargs f > 0 && nargs g > 0;\n```\n\nThis employs the nargs function from the standard library which returns the argument count of a global or local function. We use this here to check that the operands are defined functions taking at least one argument. The result is a function which applies the function operands to the given argument and computes their sum and difference, respectively. For instance:\n\n```> map (f+g-h) (1..10) with f x = 2*x+1; g x = x*x; h x = 3 end;\n[1,6,13,22,33,46,61,78,97,118]\n```\n\nThese rules also handle functions taking multiple arguments, so that you can write, e.g.:\n\n```> (max-min) 2 5;\n3\n```\n\nConstructors can be extended in exactly the same way:\n\n```> f,g = \\x -> f x, g x if nargs f > 0 && nargs g > 0;\n> (max,min,max-min) 2 5;\n5,2,3\n```\n\n### List Processing¶\n\nPure’s list data structure provides you with a convenient way to represent sequences of arbitrary values. This is one of the few compound data structures which has built-in support by the compiler, so that some syntactic sugar is available which allows you to express certain list operations in a convenient way. But for the most part, lists are implemented in the prelude just like any other data structure.\n\nThe empty list is denoted [], and compound lists can be put together in a right-recursive fashion using the ‘:‘ operator. The customary bracketed notation is provided as well, and this is also the syntax the interpreter normally uses to print list values:\n\n```> 1:2:3:[];\n[1,2,3]\n```\n\nNote that the bracketed notation is just syntactic sugar; internally all list values are represented as right-recursive applications of the ‘:‘ operator. Thus it is possible to match the head and tail of a list using a pattern like x:xs:\n\n```> case [1,2,3] of x:xs = x,xs end;\n1,[2,3]\n```\n\nLists can contain any combination of elements (also from different types) and they may also be nested:\n\n```> [1,2.0,[x,y],\"a string\"];\n[1,2.0,[x,y],\"a string\"]\n```\n\nList concatenation is denoted +, and the #, ! and !! operators can be used to compute the length of a list and extract elements and slices of a list using zero-based indexing:\n\n```> [a,b,c]+[x,y,z];\n[a,b,c,x,y,z]\n> #ans, ans!5, ans!![2,3];\n6,z,[c,x]\n```\n\nNote that lists are immutable in Pure (just like most of Pure’s built-in and predefined data structures), so there are no operations which modify lists in-place. E.g., concatenation works as if it was defined recursively by the following rules:\n\n```[]+ys = ys;\n(x:xs) + ys = x : (xs+ys);\n```\n\nSo a new list is created which replaces the empty list in the last component of the left operand with the right operand. This even works if the second operand is no list at all, in which case an improper list value is produced:\n\n```> [a,b,c]+y;\na:b:c:y\n```\n\nThese can be useful, e.g., to represent symbolic list values. Note that a proper list value contains the empty list [] in its rightmost component; an improper list value is one which doesn’t. There are some list functions like reverse which really need proper lists to work and will throw an exception otherwise, but many predefined operations will deal with improper lists just fine:\n\n```> map f (x:y:z);\nf x:f y:map f z\n```\n\nLists can also be compared using the == and ~= operators:\n\n```> [1,2,3] == [1,2,4];\n0\n```\n\nArithmetic sequences are denoted with the .. operator:\n\n```> 1..10; 10:9..1; 0.0:0.1..1.0;\n[1,2,3,4,5,6,7,8,9,10]\n[10,9,8,7,6,5,4,3,2,1]\n[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]\n```\n\nList comprehensions provide another way to construct (proper) list values using a convenient math-like notation:\n\n```> [2^x | x = 1..10];\n[2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0]\n```\n\nWe’ll discuss this construct in more detail later, see List Comprehensions.\n\nThe prelude provides a fairly comprehensive collection of useful list functions, including some powerful generic operations which let you do most common list manipulations with ease. For instance, we have already seen the map function:\n\n```> map (\\x->2*x-1) (1..10);\n[1,3,5,7,9,11,13,15,17,19]\n```\n\nThere’s also a function do which works in the same fashion but throws away all the results and simply returns (). Of course this makes sense only if the applied function has some interesting side-effect. E.g., here’s a quick way to print all members of a list, one per line. This combines the str function (which converts any Pure expression to its printable representation, cf. String Processing below) with the puts function from the system module (which is just the corresponding C function, so it prints a string on the terminal, followed by a newline).\n\n```> using system;\n> do (puts.str) (1..3);\n1\n2\n3\n()\n```\n\nAnother useful list function is filter which applies a predicate to each member of a list and collects all list elements which satisfy the predicate:\n\n```> odd x = x mod 2; even x = ~odd x;\n> filter odd (1..20);\n[1,3,5,7,9,11,13,15,17,19]\n> filter even (1..20);\n[2,4,6,8,10,12,14,16,18,20]\n```\n\nIn addition, the all and any functions can be used to check whether all or any list elements satisfy a given predicate:\n\n```> any even (1:3..20);\n0\n> all odd (1:3..20);\n1\n```\n\nThere’s also a family of functions such as foldl which generalize the notion of aggregate functions such as list sums and products. Starting from a given initial value a, foldl iterates a binary function f over a list xs and returns the accumulated result. It’s defined as follows:\n\n```foldl f a [] = a;\nfoldl f a (x:xs) = foldl f (f a x) xs;\n```\n\nFor instance, we can use foldl to compute list sums and products:\n\n```> foldl (+) 0 (1..10);\n55\n> foldl (*) 1 (1..10);\n3628800\n```\n\nNote that foldl (“fold-left”) accumulates results from left to right, so the result accumulated so far is passed as the left argument to the function f. There’s a foldr (“fold-right”) function which works analogously but collects results from right to left, and accordingly passes the accumulated result in the right argument. Usually this won’t make a difference if the iterated function is associative, but foldl and foldr have lots of applications beyond these simple use cases. For instance, we may use foldl to reverse a list as follows:\n\n```> foldl (flip (:)) [] (1..10);\n[10,9,8,7,6,5,4,3,2,1]\n```\n\nNote that we have to flip the arguments of the ‘:‘ constructor here, since foldl passes the accumulated list in the left argument, but ‘:‘ wants it on the right. Conversely, we have that:\n\n```> foldr (:) [] (1..10);\n[1,2,3,4,5,6,7,8,9,10]\n```\n\nThis just returns the list unchanged. So the order in which we accumulate results does matter here.\n\nIn a similar fashion, we might use foldl (or foldr) to build any kind of compound data structure from a list of its members. For instance, recall our binary tree example:\n\n```nonfix nil;\ninsert nil y = bin y nil nil;\ninsert (bin x L R) y = bin x (insert L y) R if y<x;\n= bin x L (insert R y) otherwise;\n```\n\nWe can then use foldl insert to construct a binary tree from its member list as follows:\n\n```> foldl insert nil [7,12,9,5];\nbin 7 (bin 5 nil nil) (bin 12 (bin 9 nil nil) nil)\n```\n\nSometimes we’d like to know not just the final result of an aggregate function, but all the intermediate results as well. The scanl function does this. For instance:\n\n```> scanl (+) 0 (1..10);\n[0,1,3,6,10,15,21,28,36,45,55]\n```\n\nNote that this computes the same list of partial sums as:\n\n```> [foldl (+) 0 (1..n) | n = 0..10];\n[0,1,3,6,10,15,21,28,36,45,55]\n```\n\nHowever, the former is more efficient since it does all the partial sums in one go.\n\nLike foldl, scanl also has a sibling called scanr which collects results from right to left, starting at the end of the list:\n\n```> scanr (+) 0 (1..10);\n[55,54,52,49,45,40,34,27,19,10,0]\n```\n\nAnother useful list generation function is iterwhile which keeps applying a function starting at a given initial value, as long as the current value satisfies the given predicate. So another way to generate the odd numbers up to 20 is:\n\n```> iterwhile (<=20) (+2) 1;\n[1,3,5,7,9,11,13,15,17,19]\n```\n\nOr we might collect all powers of 2 which fall into the 16 bit range:\n\n```> iterwhile (<0x10000) (*2) 1;\n[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768]\n```\n\nThere are also various functions to partition a list into different parts according to various criteria. The simplest of these are the head and tail functions:\n\n```> let xs = 1..10;\n1\n[2,3,4,5,6,7,8,9,10]\n```\n\nConversely, the last and init functions give you the last element of a list, and all but the last element, respectively:\n\n```> last xs; init xs;\n10\n[1,2,3,4,5,6,7,8,9]\n```\n\nThe take and drop functions take or remove a given number of initial elements, while takewhile and dropwhile take or remove initial elements while a given predicate is satisfied:\n\n```> take 4 xs; drop 4 xs;\n[1,2,3,4]\n[5,6,7,8,9,10]\n> takewhile (<=4) xs; dropwhile (<=4) xs;\n[1,2,3,4]\n[5,6,7,8,9,10]\n```\n\nLists can be reversed with reverse and sorted using sort:\n\n```> reverse xs;\n[10,9,8,7,6,5,4,3,2,1]\n> sort (<) (xs + ans);\n[1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10]\n```\n\nYou can also concatenate a list of lists with the cat function:\n\n```> cat [1..n | n = 1..5];\n[1,1,2,1,2,3,1,2,3,4,1,2,3,4,5]\n```\n\nLast but not least, there is the zip family of functions which let you combine members of two or more lists in different ways. The zip function itself collects pairs of corresponding elements in two input lists:\n\n```> zip (1..5) (\"a\"..\"e\");\n[(1,\"a\"),(2,\"b\"),(3,\"c\"),(4,\"d\"),(5,\"e\")]\n```\n\nThe effect of zip can be undone with unzip which returns a pair of lists:\n\n```> unzip ans;\n[1,2,3,4,5],[\"a\",\"b\",\"c\",\"d\",\"e\"]\n```\n\nThe zipwith function is a generic version of zip which combines corresponding members from two lists using a given binary function f:\n\n```> zipwith (*) (1..10) (1..10);\n[1,4,9,16,25,36,49,64,81,100]\n```\n\nYou might also consider zipwith a variant of map working with two lists at the same time (in fact this operation is also known as map2 in some functional programming languages). There are also variations of these functions which work with three lists (zip3, unzip3, zipwith3).\n\nNote that zip itself is equivalent to zipwith (,):\n\n```> zipwith (,) (1..5) (\"a\"..\"e\");\n[(1,\"a\"),(2,\"b\"),(3,\"c\"),(4,\"d\"),(5,\"e\")]\n```\n\nAlso note that since tuples are formed by just applying the ‘,‘ operator repeatedly, you can use multiple calls of zip to piece together tuples of any length:\n\n```> zip (1..3) (zip (\"a\"..\"c\") [a,b,c]);\n[(1,\"a\",a),(2,\"b\",b),(3,\"c\",c)]\n```\n\nThis can be achieved even more easily by folding zip over a list of lists; here we employ a variation foldr1 of foldr which takes the initial value from the beginning of the list.\n\n```> foldr1 zip [1..3,\"a\"..\"c\",[a,b,c]];\n[(1,\"a\",a),(2,\"b\",b),(3,\"c\",c)]\n```\n\nNote that this method easily scales up to as many element lists as you want. Recovering the original element lists is a bit trickier, though, but it can be done using this little helper function:\n\n```unzipn n xs = xs if n<=1;\n= xs,unzipn (n-1) ys when xs,ys = unzip xs end otherwise;\n```\n\nFor instance:\n\n```> foldr1 zip [1..3,\"a\"..\"c\",[a,b,c]];\n[(1,\"a\",a),(2,\"b\",b),(3,\"c\",c)]\n> unzipn 3 ans;\n[1,2,3],[\"a\",\"b\",\"c\"],[a,b,c]\n```\n\nAlso, the elements to be zipped don’t have to be singletons, they can themselves be tuples of any size:\n\n```> foldr1 zip [[1,2,3],[a,(),c],[x,y,(z,t)]];\n[(1,a,x),(2,y),(3,c,z,t)]\n```\n\nBut note that in this case you loose the information which elements came from which sublists, so unzip won’t be able to recover the original lists any more. If you need to avoid that then it’s best to use other aggregates such as lists or vectors for the sublist elements.\n\nThere are other interesting list functions in the prelude, but we’ll leave it at that for now. Please check the Pure Library Manual for a full account of the available operations.\n\n### String Processing¶\n\nLet’s take a short break from lists and look at strings. We postponed that until now since strings are in many ways just like lists of characters. In fact the similarities run so deep that in some languages, most notably Haskell, strings are in fact just lists. Pure doesn’t go quite that far; it still represents strings as null-terminated arrays of characters in the UTF-8 encoding, which is a much more compact representation and eases interoperability with C. However, most common list operations also work on strings in an analogous fashion. Thus you can concatenate strings, compute their length, and index, slice and compare them as usual:\n\n```> \"abc\"+\"xyz\";\n\"abcxyz\"\n> #ans, ans!5, ans!![2,3];\n6,\"z\",\"cx\"\n> \"abc\"==\"abd\";\n0\n```\n\nIn addition, strings can also be ordered lexicographically:\n\n```> \"abd\"<\"abcd\";\n0\n> \"abd\">\"abcd\";\n1\n> sort (<) [\"the\",\"little\",\"brown\",\"fox\"];\n[\"brown\",\"fox\",\"little\",\"the\"]\n```\n\nWhere it makes sense, list operations on strings return again a string result:\n\n```> head \"abc\"; tail \"abc\";\n\"a\"\n\"bc\"\n> take 4 \"abcdefg\"; drop 4 \"abcdefg\";\n\"abcd\"\n\"efg\"\n```\n\nA slight complication arises with the map function, because in this case the result is not guaranteed to be a string in all cases. For instance:\n\n```> map ord \"HAL\";\n[72,65,76]\n```\n\nTo have map work consistently, it will thus yield a list even in cases where the result could again be represented as a string. If you want a string result instead, you’ll have to do the conversion explicitly, using the string function:\n\n```> map (+1) \"HAL\";\n[\"I\",\"B\",\"M\"]\n> string ans;\n\"IBM\"\n```\n\nConversely, you can also convert a string to a list of its characters using either chars or the generic list conversion function:\n\n```> list ans;\n[\"I\",\"B\",\"M\"]\n```\n\nAs in the case of map, this conversion is usually done automatically if a list operation from the prelude is applied to a string. This also happens if a list comprehension draws values from a string:\n\n```> [x-1 | x = \"IBM\"];\n[\"H\",\"A\",\"L\"]\n```\n\nTalking about characters, these are simply single character strings, so Pure has no separate data type for them. However, there is a type tag char for the single character strings which can be used in pattern matching:\n\n```> isupper x::char = \"A\"<=x && x<= \"Z\";\n> filter isupper \"The Little Brown Fox\";\n\"TLBF\"\n> any isupper \"The Little Brown Fox\";\n1\n```\n\nMaybe you wondered how that \"HAL\" => \"IBM\" transformation above came about? Well, the prelude also defines basic arithmetic on characters:\n\n```> \"a\"+1, \"a\"+2, \"z\"-1;\n\"b\",\"c\",\"y\"\n> \"z\"-\"a\";\n25\n```\n\nThis considers characters as an enumerated data type where each character corresponds to a numeric code point in Unicode. Hence, e.g., \"a\"+1 gives \"b\" because \"b\" is the code point following \"a\" in Unicode, and \"b\"-\"a\" gives 1 for the same reason.\n\nSo here’s the rot13 encoding in Pure:\n\n```rot13 x::string = string (map rot13 x) with\nrot13 c = c+13 if \"a\" <= lower c && lower c <= \"m\";\n= c-13 if \"n\" <= lower c && lower c <= \"z\";\n= c otherwise;\nlower c = \"a\"+(c-\"A\") if \"A\"<=c && c<=\"Z\";\n= c otherwise;\nend;\n```\n\nFor instance:\n\n```> rot13 \"The quick brown fox\";\n\"Gur dhvpx oebja sbk\"\n> rot13 ans;\n\"The quick brown fox\"\n```\n\nCharacter arithmetic also makes arithmetic sequences of characters work as expected:\n\n```> \"a\"..\"k\"; \"k\":\"j\"..\"a\";\n[\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\"]\n[\"k\",\"j\",\"i\",\"h\",\"g\",\"f\",\"e\",\"d\",\"c\",\"b\",\"a\"]\n> string (\"a\":\"c\"..\"z\");\n\"acegikmoqsuwy\"\n```\n\nYou can also convert between characters and their ordinal numbers using the ord and chr functions:\n\n```> ord \"a\";\n97\n> chr (ans+1);\n\"b\"\n```\n\nThus using Horner’s rule we might convert a string of decimal digits to its numeric representation as follows:\n\n```> foldl (\\x c -> 10*x+ord c-ord \"0\") 0 \"123456\";\n123456\n```\n\nHowever, there are much easier and more general ways to convert between strings and Pure expressions. Specifically, val and str can be used to convert between any Pure value and its string representation:\n\n```> val \"2*(3+4)\"; str ans;\n2*(3+4)\n\"2*(3+4)\"\n```\n\nIf you also want to evaluate the string representation of a Pure expression then eval is your friend:\n\n```> eval \"2*(3+4)\";\n14\n```\n\nTwo other convenient functions are split which breaks apart a string at a given delimiter string, and join which concatenates a list of strings, interpolating the delimiter string between successive list elements:\n\n```> split \" \" \"The quick brown fox\";\n[\"The\",\"quick\",\"brown\",\"fox\"]\n> join \":\" ans;\n\"The:quick:brown:fox\"\n```\n\nIf you don’t need the intervening delimiters then you can also concatenate string lists simply with strcat:\n\n```> strcat [\"The\",\"quick\",\"brown\",\"fox\"];\n\"Thequickbrownfox\"\n```\n\nThese operations are all implemented in an efficient way so that they run in linear time. (Note that the string conversion function we mentioned above is in fact just strcat on lists of strings, but it also works with other aggregates such as vectors of strings.)\n\nFor more elaborate needs there’s also a suite of functions for doing regular expression matching in the regex module, and the system module provides the usual facilities for reading and writing strings from/to text files and the terminal, as well as the printf and scanf family of functions which are used to print and parse strings according to a given format string. These are all explained in detail in the Pure Library Manual.\n\n### List Comprehensions¶\n\nList comprehensions are Pure’s main workhorse for generating and processing all kinds of list values. You can think of them as a combination of map and filter using a prettier syntax reminiscent of the way in which sets are commonly specified in mathematics. List comprehensions are in fact just syntactic sugar, so anything that can be done with them can also be accomplished with Pure’s generic list functions; but often they are much easier to write and understand.\n\nIn the simplest case, list comprehensions are just a shorthand for map with lambdas:\n\n```> [2*x-1 | x = 1..10];\n[1,3,5,7,9,11,13,15,17,19]\n```\n\nThis can be read aloud as “the list of all 2*x-1 for which x runs through the list 1..10”. The part x = 1..10 is called a generator clause. The comprehension binds x to each member of the list 1..10 in turn and evaluates the target expression 2*x+1 in the context of this binding. This is equivalent to the following map expression:\n\n```> map (\\x->2*x-1) (1..10);\n[1,3,5,7,9,11,13,15,17,19]\n```\n\nList comprehensions may also involve filter clauses: predicates which determine the elements that are to be included in the result list.\n\n```> [2*x-1 | x = 1..10; x mod 3];\n[1,3,7,9,13,15,19]\n```\n\nThis can be read as “the list of all 2*x-1 for which x runs through 1..10 and for which x mod 3 is non-zero” (which means that x is not a multiple of 3). It is roughly equivalent to:\n\n```> map (\\x->2*x-1) (filter (\\x->x mod 3) (1..10));\n[1,3,7,9,13,15,19]\n```\n\nList comprehensions can also draw values from other kinds of aggregates such as strings and matrices, but the result is always a list:\n\n```> [x-1 | x = \"IBM\"];\n[\"H\",\"A\",\"L\"]\n> [1/x | x = {1,2,3;4,5,6}; ~x mod 2];\n[0.5,0.25,0.166666666666667]\n```\n\nList comprehensions can have as many generator and filter clauses as you want. The clauses are considered in left-to-right order so that later clauses may refer to any variables introduced in earlier generator clauses. E.g., here’s how you can generate the list of all pairs (i,j) with 1<=i<=j<=5 such that i+j is even:\n\n```> [i,j | i = 1..5; j = i..5; ~(i+j) mod 2];\n[(1,1),(1,3),(1,5),(2,2),(2,4),(3,3),(3,5),(4,4),(5,5)]\n```\n\nThe left-hand side of a generator clause can be an arbitary pattern, which is useful if you need to peek at the list elements to see what’s inside. For instance, let’s take the previous result and check that the sums of the number pairs are in fact all even:\n\n```> [i+j | i,j = ans];\n[2,4,6,4,6,6,8,8,10]\n```\n\nGenerator clauses involving patterns also act as filters; unmatched elements are filtered out automatically:\n\n```> [i+j | i,j = [\"to be ignored\",(1,1),(2,2),3]];\n[2,4]\n```\n\nList comprehensions can also be nested to an arbitrary depth. For instance, we may rewrite the “even sums” comprehension from above as follows, in order to group the pairs into sublists for each value of i:\n\n```> [[i,j | j = i..5; ~(i+j) mod 2] | i = 1..5];\n[[(1,1),(1,3),(1,5)],[(2,2),(2,4)],[(3,3),(3,5)],[(4,4)],[(5,5)]]\n```\n\nA notorious example is the following recursive algorithm which implements a variation of Erathosthenes’ classical prime sieve. (This method is actually rather slow and thus not suitable for computing large primes, but we’re not concerned with that here.)\n\n```primes n = sieve (2..n) with\nsieve [] = [];\nsieve (p:qs) = p : sieve [q | q = qs; q mod p];\nend;\n```\n\nNote that the sieve recursively filters out the multiples of the current front element p of the list, which, by virtue of the construction, is always a prime number. The result is the list of all primes up to n:\n\n```> primes 100;\n[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]\n```\n\nList comprehensions are also a useful device to organize backtracking searches. For instance, here’s an algorithm for the n queens problem, which returns the list of all placements of n queens on an n x n board (encoded as lists of n pairs (i,j) with i = 1..n), so that no two queens hold each other in check:\n\n```queens n = search n 1 [] with\nsearch n i p = [reverse p] if i>n;\n= cat [search n (i+1) ((i,j):p) | j = 1..n; safe (i,j) p];\nsafe (i,j) p = ~any (check (i,j)) p;\ncheck (i1,j1) (i2,j2)\n= i1==i2 || j1==j2 || i1+j1==i2+j2 || i1-j1==i2-j2;\nend;\n```\n\n### Lazy Evaluation and Streams¶\n\nAs already mentioned, lists can also be evaluated in a “lazy” fashion, by just turning the tail of a list into a future. This special kind of list is also called a stream. Streams enable you to work with infinite lists (or finite lists which are so huge that you would never want to keep them in memory in their entirety). E.g., here’s one way to define the infinite stream of all Fibonacci numbers:\n\n```> let fibs = fibs 0L 1L with fibs a b = a : fibs b (a+b) & end;\n> fibs;\n0L:#<thunk 0xb5d54320>\n```\n\nNote the & on the tail of the list in the definition of the local fibs function. This turns the result of fibs into a stream, which is required to prevent the function from recursing into samadhi. Also note that we work with bigints in this example because the Fibonacci numbers grow quite rapidly, so with machine integers the values would soon start wrapping around to negative integers.\n\nStreams like these can be worked with in pretty much the same way as with lists. Of course, care must be taken not to invoke “eager” operations such as # (which computes the size of a list) on infinite streams, to prevent infinite recursion. However, many list operations work with infinite streams just fine, and return the appropriate stream results. E.g., the take function (which retrieves a given number of elements from the front of a list) works with streams just as well as with “eager” lists:\n\n```> take 10 fibs;\n0L:#<thunk 0xb5d54350>\n```\n\nHmm, not much progress there, but that’s just how streams work (or rather they don’t, they’re lazy bums indeed!). Nevertheless, the stream computed with take is in fact finite and we can readily convert it to an ordinary list, forcing its evaluation:\n\n```> list (take 10 fibs);\n[0L,1L,1L,2L,3L,5L,8L,13L,21L,34L]\n```\n\nAn alternative way to achieve this is to cut a “slice” from the stream:\n\n```> fibs!!(0..10);\n[0L,1L,1L,2L,3L,5L,8L,13L,21L,34L,55L]\n```\n\nNote that since we bound the stream to a variable, the already computed prefix of the stream has been memoized, so that this portion of the stream is now readily available in case we need to have another look at it later. By these means, possibly costly reevaluations are avoided, trading memory for execution speed:\n\n```> fibs;\n0L:1L:1L:2L:3L:5L:8L:13L:21L:34L:55L:#<thunk 0xb5d54590>\n```\n\nThe prelude also provides some convenience operations for generating stream values. Infinite arithmetic sequences are specified using inf or -inf to denote an upper (or lower) infinite bound for the sequence, e.g.:\n\n```> let u = 1..inf; let v = -1.0:-1.2..-inf;\n> u!!(0..10); v!!(0..10);\n[1,2,3,4,5,6,7,8,9,10,11]\n[-1.0,-1.2,-1.4,-1.6,-1.8,-2.0,-2.2,-2.4,-2.6,-2.8,-3.0]\n```\n\nOther useful stream generator functions are iterate, which keeps applying the same function over and over again, repeat, which just repeats its argument forever, and cycle, which cycles through the elements of the given list:\n\n```> iterate (*2) 1!!(0..10);\n[1,2,4,8,16,32,64,128,256,512,1024]\n> repeat 1!!(0..10);\n[1,1,1,1,1,1,1,1,1,1,1]\n> cycle [0,1]!!(0..10);\n[0,1,0,1,0,1,0,1,0,1,0]\n```\n\nMoreover, list comprehensions can draw values from streams and return the appropriate stream result:\n\n```> let rats = [m,n-m | n=2..inf; m=1..n-1; gcd m (n-m) == 1]; rats;\n(1,1):#<thunk 0xb5d54950>\n> rats!!(0..10);\n[(1,1),(1,2),(2,1),(1,3),(3,1),(1,4),(2,3),(3,2),(4,1),(1,5),(5,1)]\n```\n\nWe can also rewrite our prime sieve so that it generates the infinite stream of all prime numbers:\n\n```all_primes = sieve (2..inf) with\nsieve (p:qs) = p : sieve [q | q = qs; q mod p] &;\nend;\n```\n\nNote that we can omit the empty list case of sieve here, since the sieve now never becomes empty. Example:\n\n```> let P = all_primes;\n> P!!(0..20);\n[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73]\n> P!299;\n1987\n```\n\nYou can also just print the entire stream. Note that this sieve algorithm isn’t tail-recursive, so the following will eventually result in a stack overflow. But this will take a while, so you may want to hit Ctrl-c when you get bored:\n\n```> using system;\n> do (printf \"%d\\n\") all_primes;\n2\n3\n5\n...\n```\n\nIt’s also possible to convert an ordinary list to a stream:\n\n```> stream (1..10);\n1:#<thunk 0x7f2692a0f138>\n```\n\nThis may seem like a silly thing to do, because the original list is already fully known beforehand. But this transformation allows us to traverse the list in a lazy fashion, which can be useful if the list is employed in a list comprehension or processed by functions such as cat and map. For instance, we can use this to rewrite the fringe function from The Same-Fringe Problem so that it calculates the fringe in a lazy fashion:\n\n```lazyfringe t = if listp t then catmap lazyfringe (stream t) else [t];\n```\n\nRecall that the fringe of a tree is the list of its leaves in left-to-right order. The tree itself is represented as a nested list, to which lazyfringe applies stream recursively so that the fringe becomes a stream whose elements are only produced on demand:\n\n```> lazyfringe [[a,b],c,[[d]],e,[f,[[g,h]]]];\na:#<thunk 0x7f127fc1f090>\n> list ans;\n[a,b,c,d,e,f,g,h]\n```\n\nHence a simple syntactic equality check now suffices to solve the same-fringe problem in an efficient way. For instance, consider the following sample trees from The Same-Fringe Problem:\n\n```let t1 = [[a,b],c,[[d]],e,[f,[[g,h]]]];\nlet t2 = [a,b,c,[[d],[],e],[f,[g,[h]]]];\nlet t3 = [[a,b],d,[[c]],e,[f,[[g,h]]]];\n```\n\nLet’s also bind the fringes to some variables so that we can check which parts actually get evaluated:\n\n```let l1 = lazyfringe t1;\nlet l2 = lazyfringe t2;\nlet l3 = lazyfringe t3;\n```\n\nNow comparing l3 and l2 we get:\n\n```> l3 === l2; l3; l2;\n0\na:b:d:#<thunk 0x7fd308116178>\na:b:c:#<thunk 0x7fd308116060>\n```\n\nAs you can see, the two fringes were only constructed as far as needed to decide that they differ. Of course, if we compare l1 and l2 then the fringes will still be fully constructed before we find that they’re equal:\n\n```> l1 === l2; l1; l2;\n1\n[a,b,c,d,e,f,g,h]\n[a,b,c,d,e,f,g,h]\n```\n\nBut this doesn’t really matter if we construct the fringes as temporary values, as in:\n\n```> fringe t1 === fringe t2;\n```\n\nNow only the parts of the fringes are in memory which are currently under scrutiny as the ‘===‘ operator passes over them; the prefixes which have already been found to be equal can be garbage-collected immediately. Moreover, the ‘===‘ operator is tail-recursive so that the entire equality test can be executed in constant stack space. This gives us an easier way to solve the same-fringe problem which has pretty much the same benefits as our earlier solution using continuations. The latter might still be considered more elegant, because it works without actually constructing the fringes at all. But the solution using lazy evaluation is certainly much simpler.\n\n### Matrices and Vectors¶\n\nPure has a versatile matrix data structure offering compact storage and efficient random access to its members. Pure matrices work pretty much like in MATLAB or Octave, except that indexes are zero-based and elements are stored in C’s row-major rather than Fortran’s column-major format. They are also binary-compatible with the GNU Scientific Library (GSL) so that they can readily be passed to GSL functions for doing numeric calculations.\n\nPure offers a number of basic matrix operations, such as matrix construction, pattern matching, indexing, slicing, as well as getting the size and dimensions of a matrix. It does not supply built-in support for matrix arithmetic and other linear algebra algorithms, but it’s easy to roll your own if desired, as we’ll see below. (Usually this won’t offer the same performance as the GSL and other carefully optimized C and Fortran routines, however. So if you need to do some heavy-duty number crunching then you might want to take a look at the pure-gsl module available at the Pure website, which is an ongoing project to make the GSL functions available in Pure.)\n\nMatrices are denoted using curly braces in Pure:\n\n```> let x = {1,2,3;4,5,6}; x;\n{1,2,3;4,5,6}\n```\n\nNote that the semicolon is used to separate different rows, while the elements inside each row are separated with commas. Thus the above denotes a 2x3 matrix (2 rows, 3 columns). The dim function lets you check the dimensions, while the ‘#‘ operator gives the total number of elements:\n\n```> dim x; #x;\n2,3\n6\n```\n\nThere’s no separate data type for vectors; row and column vectors are simply represented as 1 x n and n x 1 matrices, respectively:\n\n```> dim {1,2,3}; dim {1;2;3};\n1,3\n3,1\n```\n\nSingleton and empty matrices can be denoted as follows:\n\n```> dim {1}; dim {};\n1,1\n0,0\n```\n\nThe transpose function turns columns into rows and vice versa; in particular, you can also use this to convert between row and column vectors:\n\n```> transpose x;\n{1,4;2,5;3,6}\n> transpose {1,2,3}; transpose {1;2;3};\n{1;2;3}\n{1,2,3}\n```\n\nNote that matrices are immutable in Pure, so matrix functions like transpose always return a new matrix, leaving the original matrix unchanged. (If you need to modify matrices in-place for efficiency, then you can use the GSL or other C or Fortran functions.)\n\nYou can change the dimensions of a matrix with the redim function, provided that the size stays the same. So, for instance, we can turn the matrix x into a row vector as follows:\n\n```> redim (1,6) x;\n{1,2,3,4,5,6}\n```\n\nAgain, this doesn’t change the original matrix, but returns a new matrix with the same contents and the requested dimensions. This operation also allows you to change the dimensions of an empty matrix which, as we’ve seen above, has dimensions 0,0 by default. Of course, this requires that either the number of rows or columns is still zero. For instance:\n\n```> redim (3,0) {};\n{}\n> dim ans;\n3,0\n```\n\nAnother way to do this is to just construct a zero matrix with zero rows or columns directly, see below. (Note that these different kinds of empty matrices are needed to represent the corner cases. E.g., a linear mapping from 3-dimensional vectors to the zero vector space corresponds to a 0x3 matrix which yields a 3x0 matrix when transposed.)\n\nA number of other specific conversion operations are available, such as rowvector and colvector which convert a matrix to a row or column vector, respectively, or diag which extracts the main diagonal of a matrix:\n\n```> rowvector x;\n{1,2,3,4,5,6}\n> colvector x;\n{1;2;3;4;5;6}\n> diag x;\n{1,5}\n```\n\nYou can also extract the rows and columns of a matrix, which yields a list of the corresponding row and column vectors, respectively:\n\n```> rows x; cols x;\n[{1,2,3},{4,5,6}]\n[{1;4},{2;5},{3;6}]\n```\n\nThere are a number of other operations which convert between matrices and different kinds of aggregates; please check the Matrix Functions section in the Pure Library Manual for details.\n\nElement access uses the index operator ‘!‘. You can either specify a pair (i,j) of row and column indices, or a single index i which treats the entire matrix as a single vector in row-major order:\n\n```> x!(0,2);\n3\n> x!3;\n4\n```\n\nSlicing is done with the ‘!!‘ operator. The index range can be specified in different ways. First, a pair of lists of row and column indices cuts a rectangular slice from the matrix:\n\n```> x!!(0..1,1..2);\n{2,3;5,6}\n```\n\nSecond, a pair of a list and a row or column index cuts slices from individual rows or columns:\n\n```> x!!(0,1..2); x!!(0..1,2);\n{2,3}\n{3;6}\n```\n\nThird, a list of pairs of row and column indices, or a list of element indices gives a row vector with all the corresponding elements:\n\n```> x!![(0,2),(1,2)];\n{3,6}\n> x!!(2..3);\n{3,4}\n```\n\nWhile most of the slices above are contiguous (a case which the prelude optimizes for), you can also specify indices in any order, possibly with duplicates. So we may not only cut submatrix slices, but also permute and/or copy rows and columns of a matrix along the way:\n\n```> x!!([1,0,1],0..2);\n{4,5,6;1,2,3;4,5,6}\n```\n\nMatrices can also be constructed from submatrices by arranging the submatrices in rows or columns. In fact, the curly braces accept any combination of submatrices and scalars, provided that all dimensions match up:\n\n```> {1,{2,3};{4,5},6};\n{1,2,3;4,5,6}\n> {{1;4},{2,3;5,6}};\n{1,2,3;4,5,6}\n> {{1;2;3},{4;5;6}};\n{1,4;2,5;3,6}\n```\n\nThe end result must be a rectangular matrix, however, otherwise you’ll get an exception indicating a submatrix whose dimensions don’t match:\n\n```> {1,{2,3};{4,5}};\n<stdin>, line 24: unhandled exception 'bad_matrix_value {4,5}'\nwhile evaluating '{1,{2,3};{4,5}}'\n```\n\nThis “splicing” of submatrices is especially useful when doing linear algebra, where matrices are often composed from smaller “block matrices” or vectors; we’ll see an example of this later. (Sometimes this behaviour also gets in the way, and thus there are ways to disable it; see Symbolic Matrices below.)\n\nPure actually provides several different types of numeric matrices, which correspond to the different GSL matrix types for integer, floating point and complex numbers. (Note that complex numbers aren’t a built-in data type in Pure, but there are ways to specify this kind of numbers and perform calculations with them; see the math module for details.) Which type of matrix is created by the curly braces depends on the element types. Homogeneous matrices which contain only int, double or complex values yield the corresponding type of GSL matrix. Matrices can also hold any other type of Pure value or an arbitrary mix of values, in which case they become symbolic matrices; we’ll discuss these later.\n\nThe functions imatrix, dmatrix and cmatrix can be used to convert between the different kinds of numeric matrices. For instance:\n\n```> dmatrix {1,2,3;4,5,6};\n{1.0,2.0,3.0;4.0,5.0,6.0}\n> imatrix ans;\n{1,2,3;4,5,6}\n> cmatrix ans;\n{1.0+:0.0,2.0+:0.0,3.0+:0.0;4.0+:0.0,5.0+:0.0,6.0+:0.0}\n> dmatrix ans;\n{1.0,0.0,2.0,0.0,3.0,0.0;4.0,0.0,5.0,0.0,6.0,0.0}\n```\n\n(Note that the latter conversion turns a complex into a double matrix, interleaving the real and imaginary parts of the original matrix.)\n\nThe same functions can also be used to construct zero matrices with given dimensions:\n\n```> imatrix (2,3);\n{0,0,0;0,0,0}\n> dmatrix (2,2);\n{0.0,0.0;0.0,0.0}\n> cmatrix (1,1);\n{0.0+:0.0}\n```\n\nAs already mentioned, this also gives you a direct way to create empty matrices with different dimensions. For instance:\n\n```> imatrix (0,3); dim ans;\n{}\n0,3\n```\n\nThe prelude offers matrix versions of the common list operations like map, foldl, zip etc., which provide a way to implement common matrix operations. E.g., multiplying a matrix x with a scalar a amounts to mapping the function (a*) to x, which can be done as follows:\n\n```> type scalar x = ~matrixp x;\n> a::scalar * x::matrix = map (a*) x;\n> 2*{1,2,3;4,5,6};\n{2,4,6;8,10,12}\n```\n\nNote that the matrix type tag or the matrixp predicate can be used to restrict a variable to matrix values. (The prelude provides a few other types and corresponding predicates for various specific kinds of matrices, see the Pure Library Manual for details.) In addition, we also introduced a convenience type scalar for non-matrix values here, so that we can distinguish scalar from matrix multiplication which will be discussed below.\n\nMatrix addition and other element-wise operations can be realized using zipwith, which combines corresponding elements of two matrices using a given binary function:\n\n```> x::matrix + y::matrix = zipwith (+) x y if dim x == dim y;\n> {1,2,3;4,5,6}+{1,2,1;3,2,3};\n{2,4,4;7,7,9}\n```\n\nAnother way to define matrix functions in Pure is to employ a matrix pattern. The Pure language has built-in support for these, so that they work like the other kinds of patterns we’ve already encountered. For instance, to compute the dot product of two 2D vectors, you may write something like:\n\n```> {x1,y1}*{x2,y2} = x1*x2+y1*y2;\n> {2,3}*{1,4};\n14\n```\n\nOr, to compute the determinant of a 2x2 matrix:\n\n```> det {a,b;c,d} = a*d-b*c;\n> det {1,2;3,4};\n-2\n```\n\nThese patterns are convenient if the dimensions of the involved matrices are small and known beforehand. If this isn’t the case then it’s better to use matrix comprehensions instead, which work with arbitrary dimensions and make it easy to express many simple kinds of algorithms which would typically be done using for loops in conventional programming languages.\n\nMatrix comprehensions work pretty much like list comprehensions, but with a special twist: if values are drawn from lists then the generator clauses alternate between row and column generation. (More precisely, the last generator, which varies most quickly, yields a row, the next-to-last one a column of these row vectors, and so on.) This makes matrix comprehensions resemble customary mathematical notation very closely. For instance, here is how we can define an operation to create a square identity matrix of a given dimension (note that the i==j term is just a Pure idiom for the Kronecker symbol):\n\n```> eye n = {i==j | i = 1..n; j = 1..n};\n> eye 3;\n{1,0,0;0,1,0;0,0,1}\n```\n\nOf course, matrix comprehensions can also draw values from other matrices instead of lists. In this case the block layout of the component matrices is preserved. For instance:\n\n```> {x,y | x = {1,2}; y = {a,b;c,d}};\n{(1,a),(1,b),(2,a),(2,b);(1,c),(1,d),(2,c),(2,d)}\n```\n\nNote that a matrix comprehension involving filters may fail because the filtered result isn’t a rectangular matrix any more. E.g., {2*x|x={1,2,3,-4};x>0} works, as does {2*x|x={-1,2;3,-4};x>0}, but {2*x|x={1,2;3,-4};x>0} doesn’t because the rows of the result matrix have different lengths.\n\nAs a slightly more comprehensive example (no pun intended!), here is a definition of matrix multiplication in Pure:\n\n```x::matrix * y::matrix = {dot u v | u = rows x; v = cols y} with\ndot u v = foldl (+) 0 \\$ zipwith (*) u (rowvector v);\nend if m==n when _,m = dim x; n,_ = dim y end;\n```\n\nThe basic building block in this example is the dot product of two vectors, which is defined as a local function. The matrix product is obtained by simply calculating the dot product of all the rows of x with all the columns of y. To make this work, the rows of x should be the same length as the columns of y, we check this condition in the guard of the rule. Let’s give it a try:\n\n```> {1,0;0,1}*{1,2;3,4};\n{1,2;3,4}\n> {0,1;1,0}*{1,2;3,4};\n{3,4;1,2}\n> {0,1;1,0;1,1}*{1,2,3;4,5,6};\n{4,5,6;1,2,3;5,7,9}\n> {1,2;3,4}*{1;1};\n{3;7}\n```\n\nWell, that was easy. So let’s take a look at a more challenging example, Gaussian elimination, which can be used to solve systems of linear equations. The algorithm brings a matrix into “row echelon” form, a generalization of triangular matrices. The resulting system can then be solved quite easily using back substitution.\n\nHere is a Pure implementation of the algorithm. Note that the real meat is in the pivoting and elimination step (step function) which is iterated over all columns of the input matrix. In each step, x is the current matrix, i the current row index, j the current column index, and p keeps track of the current permutation of the row indices performed during pivoting. The algorithm returns the updated matrix x, row index i and row permutation p.\n\n```gauss_elimination x::matrix = p,x\nwhen n,m = dim x; p,_,x = foldl step (0..n-1,0,x) (0..m-1) end;\n\n// One pivoting and elimination step in column j of the matrix:\nstep (p,i,x) j\n= if max_x==0 then p,i,x\nelse\n// updated row permutation and index:\ntransp i max_i p, i+1,\n{// the top rows of the matrix remain unchanged:\nx!!(0..i-1,0..m-1);\n// the pivot row, divided by the pivot element:\n{x!(i,l)/x!(i,j) | l=0..m-1};\n// subtract suitable multiples of the pivot row:\n{x!(k,l)-x!(k,j)*x!(i,l)/x!(i,j) | k=i+1..n-1; l=0..m-1}}\nwhen\nn,m = dim x; max_i, max_x = pivot i (col x j);\nx = if max_x>0 then swap x i max_i else x;\nend with\npivot i x = foldl max (0,0) [j,abs (x!j)|j=i..#x-1];\nmax (i,x) (j,y) = if x<y then j,y else i,x;\nend;\n```\n\nPlease refer to any good textbook on numerical mathematics for a closer description of the algorithm. But here is a brief rundown of what happens in each elimination step: First we find the pivot element in column j of the matrix. (We’re doing partial pivoting here, i.e., we only look for the element with the largest absolute value in column j, starting at row i. That’s usually good enough to achieve numerical stability.) If the pivot is zero then we’re done (the rest of the pivot column is already zeroed out). Otherwise, we bring it into the pivot position (swapping row i and the pivot row), divide the pivot row by the pivot, and subtract suitable multiples of the pivot row to eliminate the elements of the pivot column in all subsequent rows. Finally we update i and p accordingly and return the result.\n\nIn order to complete the implementation, we still need the following little helper functions to swap two rows of a matrix (this is used in the pivoting step) and to apply a transposition to a permutation (represented as a list):\n\n```swap x i j = x!!(transp i j (0..n-1),0..m-1) when n,m = dim x end;\ntransp i j p = [p!tr k | k=0..#p-1]\nwith tr k = if k==i then j else if k==j then i else k end;\n```\n\nFinally, let us define a convenient print representation of double matrices a la Octave (the meaning of the __show__ function is explained in Pretty-Printing):\n\n```using system;\n__show__ x::matrix\n= strcat [printd j (x!(i,j))|i=0..n-1; j=0..m-1] + \"\\n\"\nwith printd 0 = sprintf \"\\n%10.5f\"; printd _ = sprintf \"%10.5f\" end\nwhen n,m = dim x end if dmatrixp x;\n```\n\nExample:\n\n```> let x = dmatrix {2,1,-1,8; -3,-1,2,-11; -2,1,2,-3};\n> x; gauss_elimination x;\n2.00000 1.00000 -1.00000 8.00000\n-3.00000 -1.00000 2.00000 -11.00000\n-2.00000 1.00000 2.00000 -3.00000\n[1,2,0],\n1.00000 0.33333 -0.66667 3.66667\n0.00000 1.00000 0.40000 2.60000\n0.00000 0.00000 1.00000 -1.00000\n```\n\n### Symbolic Matrices¶\n\nAs already mentioned, matrices may contain not just numbers but any kind of Pure values, in which case they become symbolic matrices. For instance:\n\n```> {1,2.0,3L;a,b,c};\n{1,2.0,3L;a,b,c}\n```\n\nThe smatrixp predicate gives you a quick way to check whether a matrix is a symbolic one:\n\n```> smatrixp ans;\n1\n```\n\nNote that this may not always be obvious. For instance, you can use the smatrix function to explicitly convert a numeric matrix:\n\n```> smatrix {1,2;3,4};\n{1,2;3,4}\n```\n\nThis still looks the same as the original matrix, but smatrixp reveals that it’s in fact a symbolic matrix:\n\n```> smatrixp ans;\n1\n```\n\nAlso note that the empty matrix is by default a symbolic matrix, as are matrices containing bigints:\n\n```> smatrixp {};\n1\n> smatrixp {1L,2L;3L,4L};\n1\n```\n\nHowever, you can easily convert these to a numeric type if needed, e.g.:\n\n```> dmatrix {1L,2L;3L,4L};\n{1.0,2.0;3.0,4.0}\n```\n\nSymbolic matrices are a convenient data structure for storing arbitrary collections of values which provides fast random access to its members. In particular, they can also be nested, and thus multidimensional tensors or arrays of arbitrary dimension can be realized as nested symbolic vectors. However, you have to be careful when constructing such values, because the {...} construct normally combines submatrices to larger matrices. For instance:\n\n```> {{1,2},{3,4}};\n{1,2,3,4}\n```\n\nOne way to inhibit this splicing of the submatrices in a larger matrix is to use the quote operator (cf. The Quote):\n\n```> '{{1,2},{3,4}};\n{{1,2},{3,4}}\n```\n\nNote that this result is really different from {1,2;3,4}. The latter is a 2x2 integer matrix, while the former is a symbolic vector a.k.a. 1x2 matrix whose elements happen to be two integer vectors. So a double index will be required to access the subvector elements:\n\n```> ans!0!1;\n2\n```\n\nYou can also match these values with a nested matrix pattern, e.g.:\n\n```> let {{a,b},{c,d}} = '{{1,2},{3,4}};\n> a,b,c,d;\n1,2,3,4\n```\n\nUnfortunately, the quote operator in fact inhibits evaluation of all embedded subterms which may be undesirable if the matrix expression contains arithmetic (as in '{{1+1,2*3}}), so this method works best for constant matrices. A more general way to create a symbolic vector of matrices is provided by the vector function from the prelude, which is applied to a list of the vector elements as follows:\n\n```> vector [{1,2},{3,4}];\n{{1,2},{3,4}}\n```\n\nCalls to the vector function can be nested to an arbitrary depth to obtain higher-dimensional “arrays”:\n\n```> vector [vector [{1,2}],vector [{3,4}]];\n{{{1,2}},{{3,4}}}\n```\n\nThis obviously becomes a bit unwieldy for higher dimensions, but Pure 0.56 and later provide the following shorthand notation:\n\n```> {|{1,2},{3,4}|};\n{{1,2},{3,4}}\n> {|{|{1,2}|},{|{3,4}|}|};\n{{{1,2}},{{3,4}}}\n```\n\nThis makes it much more convenient to denote nested vector values. Note that the {| |} construct doesn’t use any special magic, it’s just a standard outfix operator implemented as a Pure macro. For more details please check the description of the non-splicing vector brackets in the Pure Library Manual.\n\n### Record Data¶\n\nSymbolic matrices also provide a means to represent simple record-like data, by encoding records as symbolic vectors consisting of “hash pairs” of the form key => value. This kind of data structure is very convenient to represent aggregates with lots of different components. Since the components of records can be accessed by indexing with key values, you don’t have to remember which components are stored in which order, just knowing the keys of the required members is enough. In contrast, tuples, lists and other kinds of constructor terms quickly become unwieldy for such purposes.\n\nThe keys used for indexing the record data must be either symbols or strings, while the corresponding values may be arbitrary Pure values. The prelude provides some operations on these special kinds of matrices, which let you retrieve vector elements by indexing and perform non-destructive updates, see the Record Functions section in the Pure Library Manual for details. Here are a few examples which illustrate how to create records and work with them:\n\n```> let r = {x=>5, y=>12};\n> recordp r, member r x;\n1,1\n> r!y; r!![y,x];\n12\n{12,5}\n> insert r (x=>99);\n{x=>99,y=>12}\n> insert ans (z=>77);\n{x=>99,y=>12,z=>77}\n> delete ans z;\n{x=>99,y=>12}\n```\n\nRecords can also be nested:\n\n```> let r = {a => {b=>1,c=>2}, b => 2};\n> r!a, r!b, r!a!b;\n{b=>1,c=>2},2,1\n```\n\nNote the use of the “hash rocket” => which denotes the key=>value associations in a record. The hash rocket is a constructor declared as an infix operator in the prelude, see the Hash Pairs section in the Pure Library Manual for details. There’s one caveat here, however. Since neither ‘=>‘ nor ‘!‘ treat their key operand in a special way, you’ll have to take care that the key symbols do not evaluate to something else, as might be the case if they are bound to a global or local variable or parameterless function:\n\n```> let u = 99;\n> {u=>u};\n{99=>99}\n```\n\nIn the case of global variables and function symbols, you might protect the symbol with a quote (see The Quote):\n\n```> {'u=>u};\n{u=>99}\n> ans!'u;\n99\n```\n\nHowever, even the quote doesn’t save you from local variable substitution:\n\n```> {'u=>u} when u = 99 end;\n{99=>99}\n```\n\nIn such cases you’ll either have to rename the local variable, or use the prelude function val to quote the symbol:\n\n```> {'u=>v} when v = 99 end;\n{u=>99}\n> {val \"u\"=>u} when u = 99 end;\n{u=>99}\n```\n\nIt’s also possible to directly use strings as keys instead, which may actually be more convenient in some cases:\n\n```> let r = {\"x\"=>5, \"y\"=>12};\n> keys r; vals r;\n{\"x\",\"y\"}\n{5,12}\n> update r \"y\" (r!\"y\"+1);\n{\"x\"=>5,\"y\"=>13}\n```\n\nYou can also mix strings and symbols as keys in the same record (but note that strings and symbols are always distinct, so y and \"y\" are really two different keys here):\n\n```> insert r (y=>99);\n{\"x\"=>5,\"y\"=>12,y=>99}\n```\n\nAs records are in fact just special kinds of matrices, the standard matrix operations can be used on record values as well. For instance, the matrix constructor provides an alternative way to quickly augment a record with a collection of new key=>value associations:\n\n```> let r = {x=>5, y=>12};\n> let r = {r, x=>7, z=>3}; r;\n{x=>5,y=>12,x=>7,z=>3}\n> r!x, r!z;\n7,3\n> delete r x;\n{x=>5,y=>12,z=>3}\n> ans!x;\n5\n```\n\nAs the example shows, this may produce duplicate keys, but these are handled gracefully; indexing and updates will always work with the last association for a given key in the record. If necessary, you can remove duplicate entries from a record as follows; this will only keep the last association for each key:\n\n```> record r;\n{x=>7,y=>12,z=>3}\n```\n\nIn fact, the record operation not only removes duplicates, but also orders the record entries by keys. This produces a kind of normalized representation which is useful if you want to compare or combine two record values irrespective of the ordering of the fields. For instance:\n\n```> record {x=>5, y=>12} === record {y=>12, x=>5};\n1\n```\n\nThe record function can also be used to construct a normalized record directly from a list or tuple of hash pairs:\n\n```> record [x=>5, x=>7, y=>12];\n{x=>7,y=>12}\n```\n\nOther matrix operations such as map, foldl, etc., and matrix comprehensions can be applied to records just as easily. This enables you to perform bulk updates of record data in a straightforward way. For instance, here’s how you can define a function maprec which applies a function to all values stored in a record:\n\n```> maprec f = map (\\(u=>v) -> u=>f v);\n> maprec (*2) {x=>5,y=>12};\n{x=>10,y=>24}\n```\n\nAnother example: The following ziprec function collects pairs of values stored under common keys in two records (we also normalize the result here so that duplicate keys are always removed):\n\n```> ziprec x y = record {u=>(x!u,y!u) | u = keys x; member y u};\n> ziprec {a=>3,x=>5,y=>12} {x=>10,y=>24,z=>7};\n{x=>(5,10),y=>(12,24)}\n```\n\nThus the full power of generic matrix operations is available for records, which turns them into a much more versatile data structure than records in conventional programming languages, which are usually limited to constructing records and accessing or modifying their components.\n\nNote that since the values stored in records can be arbitrary Pure values, you can also have records with mutable components by making use of Pure’s expression references. For instance:\n\n```> let r = {x=>ref 1,y=>ref 2}; maprec get r;\n{x=>1,y=>2}\n> put (r!x) 99; maprec get r;\n99\n{x=>99,y=>2}\n```\n\nAnother interesting application of records are the “virtual method tables” used in object-oriented programming. Pure has a built-in __locals__ macro which captures the environment of local functions at the point of the call and returns it as a list of hash pairs of function symbols and the corresponding closures. We can readily convert this into a record data structure which can be used as a virtual method table. For instance:\n\n```> record __locals__ with f x = x+1 end;\n{f=>f}\n> (ans!f) 99;\n100\n```\n\nHere is a little helper macro that we can use to turn the virtual method table into an anonymous function which, when applied to a symbol, returns the appropriate closure:\n\n```def obj = (\\x -> vt!x) when\nvt = record __locals__;\nend;\n```\n\nContinuing our example from Local Functions and Variables, we can now implement the point object as follows:\n\n```point (x,y) = obj with\ncoords () = get x,get y;\nmove (dx,dy) = put x (get x+dx), put y (get y+dy);\nend when\nx,y = ref x,ref y;\nend;\n```\n\nNote that obj really needs to be implemented as a macro so that its body is inserted into the point function and the _locals__ call is executed in the context of the local function environment there. (A macro is like a function which gets evaluated at compile time; see the Macros section for details.) Also note that we changed the coords “method” so that it takes a dummy parameter () now; this prevents premature evaluation of the closure. If coords was a parameterless function then its value would be fixed at the time we construct the virtual method table, which is not what we want here.\n\nNow we can write:\n\n```> let p = point (1,2);\n> p coords ();\n1,2\n> p move (2,3);\n3,5\n> p coords ();\n3,5\n```\n\nThis provides us with an interesting way to represent stateful objects which works very much like object-oriented programming. What’s still missing here is the inheritance of methods from other objects, but this can now be done by just combining virtual method tables using the record operations we’ve already discussed above; we leave this as an exercise for the interested reader.\n\n### The Quote¶\n\nWe’ve already seen some uses of the quote in previous examples, so let’s have a closer look at it now. As described in Special Forms, the quote operation quotes an expression, so that it can be passed around and manipulated freely until its value is needed, in which case you can pass it to the eval function to obtain its value. For instance:\n\n```> let x = '(2*42+2^12); x;\n2*42+2^12\n> eval x;\n4180.0\n```\n\nLisp programmers will be well familiar with this operation which enables some powerful metaprogramming techniques. However, there are some notable differences to Lisp’s quote. In particular, quote only inhibits the evaluation of global variables, local variables are substituted as usual:\n\n```> (\\x -> '(2*x+1)) 99;\n2*99+1\n> foo x = '(2*x+1);\n> foo 99; foo \\$ '(7/y);\n2*99+1\n2*(7/y)+1\n> '(x+1) when x = '(2*3) end;\n2*3+1\n> '(2*42+2^n) when n = 12 end;\n2*42+2^12\n```\n\nLocal parameterless functions are treated in the same fashion:\n\n```> '(2*42+2^n) with n = 12 end;\n2*42+2^12\n```\n\nNote that, in contrast, for global variables (and functions) we have:\n\n```> let n = 12;\n> '(2*42+2^n);\n2*42+2^n\n```\n\nThis discrepancy may come as a surprise (or even annoyance) to real Lisp weenies, but it does have its advantages. As illustrated in the examples above, local variable substitution makes it easy to fill in the variable parts in a quoted “template” expression, without any need for an arguably complex tool like Lisp’s “quasiquote”. (But note that it is quite easy to define the quasiquote in Pure if you want it. See the Recursive Macros section for a simplified version; a full implementation can be found in the Pure library.)\n\nIf you do need to quote a symbol which is already being used as a local variable or function in the current context, you can do this by supplying the symbol as a string to the prelude function val:\n\n```> val \"x\"+x when x = 99 end;\nx+99\n```\n\nAlso note that while local functions are always substituted in a quoted expression, applications involving local functions can still be quoted:\n\n```> 'foo 99 with foo x = 2*x+1 end;\nfoo 99\n> eval ans;\n199\n```\n\nThe quote also inhibits evaluation inside matrix expressions, including the “splicing” of embedded submatrices:\n\n```> '{1,2+3,2*3};\n{1,2+3,2*3}\n> '{1,{2,3},4};\n{1,{2,3},4}\n```\n\nSpecial expressions (conditionals, lambda and the case, when and with constructs) can be quoted as well. But since these constructs cannot be directly represented at runtime, the quote actually produces some ordinary “placeholder” terms for these:\n\n```> '(x+1 when x = '(2*3) end);\nx+1 __when__ [x-->'(2*3)]\n> eval ans;\n2*3+1\n> '(2*42+(f 6 with f n = 2^(2*n) end));\n2*42+(f 6 __with__ [f n-->2^(2*n)])\n> eval ans;\n4180.0\n```\n\nNote that these placeholders are in fact special built-in macros which reconstruct the special expression when evaluated. Moreover, special expressions are implicitly quoted when they occur on the left-hand side of an equation or as an argument of a “quoteargs” macro call. This is often used to implement macros which manipulate these constructs as literals. For instance, the following macro swaps the arguments in a lambda:\n\n```> #! --quoteargs bar\n> def bar (\\x y -> z) = __eval__ ('(\\y x -> z));\n> show bar\ndef bar (__lambda__ [x,y] z) = __eval__ ('__lambda__ [y,x] z);\n> baz = bar (\\a b -> a-b);\n> show baz\nbaz = \\b a -> a-b;\n> baz 2 3;\n1\n```\n\nThe Macros section explains in detail how this meta programming works.\n\n## Declarations¶\n\nPure is a very terse language by design. Usually you don’t declare much stuff, you just define it and be done with it. However, there are a few constructs which let you declare symbols with special attributes and manage programs consisting of several source modules:\n\n• symbol declarations determine “scope” and “fixity” of a symbol;\n• interface declarations specify abstract data types;\n• extern declarations specify external C functions;\n• using clauses let you include other scripts in a Pure script;\n• namespace declarations let you avoid name clashes and thereby make it easier to manage large programs consisting of many separate modules.\n\nThese are toplevel elements (cf. Toplevel):\n\n```item ::= symbol_decl | interface_decl | extern_decl\n| using_decl | namespace_decl\n```\n\nWe defer the discussion of extern declarations to the C Interface section. The other kinds of declarations are described in the following subsections.\n\n### Symbol Declarations¶\n\nSymbol declarations declare special attributes of a symbol, such as their scope (whether they are “public” or “private”) and their fixity (for operator symbols). The syntax of these declarations is as follows:\n\n```symbol_decl ::= scope qualified_symbol+ \";\"\n| [scope] fixity qualified_symbol+ \";\"\nscope ::= \"public\" | \"private\"\nfixity ::= \"nonfix\" | \"outfix\"\n| (\"infix\"|\"infixl\"|\"infixr\"|\"prefix\"|\"postfix\") precedence\nprecedence ::= integer | \"(\" op \")\"\n```\n\nScope declarations take the following form:\n\npublic symbol ...;\nprivate symbol ...;\n\nThis declares the listed symbols as public or private, respectively. Each symbol must either be an identifier or a sequence of punctuation characters. The latter kind of symbols must always be declared before use, whereas ordinary identifiers can be used without a prior declaration in which case they are declared implicitly and default to public scope, meaning that they are visible everywhere in a program. An explicit public declaration of ordinary identifiers is thus rarely needed (unless you want to declare symbols as members of a specific namespace, see Namespaces below). Symbols can also be declared private, meaning that the symbol is visible only in the namespace it belongs to. This is explained in more detail under Private Symbols in the Namespaces section below.\n\nNote\n\nThe declared symbols may optionally be qualified with a namespace prefix, but since new symbols can only be created in the current namespace, the namespace prefix must match the current namespace (see Namespaces). Thus the namespace prefix isn’t really needed, unless you want to declare a symbol which happens to be a reserved Pure keyword (cf. Lexical Matters). In this specific case, it will be necessary to use a qualified name so that the symbol isn’t mistaken for a keyword.\n\nNote that to declare several symbols in a single declaration, you can list them all with whitespace in between. The same syntax applies to the other types of symbol declarations discussed below. (Commas are not allowed as delimiters here, as they may occur as legal symbol constituents in the list of symbols.) The public and private keywords can also be used as a prefix in any of the special symbol declarations discussed below, to specify the scope of the declared symbols (if the scope prefix is omitted, it defaults to public).\n\nThe following “fixity” declarations are available for introducing special operator symbols. This changes the way that these symbols are parsed and thus provides you with a limited means to extend the Pure language at the lexical and syntactical level.\n\ninfix level symbol ...;\ninfixl level symbol ...;\ninfixr level symbol ...;\nprefix level symbol ...;\npostfix level symbol ...;\n\nPure provides you with a theoretically unlimited number of different precedence levels for user-defined infix, prefix and postfix operators. Precedence levels are numbered starting at 0; larger numbers indicate higher precedence. (For practical reasons, the current implementation does require that precedence numbers can be encoded as 24 bit unsigned machine integers, giving you a range from 0 to 16777215, but this should be large enough to incur no real limitations on applications. Also, the operator declarations in the prelude have been set up to leave enough “space” between the “standard” levels so that you can easily sneak in new operator symbols at low, high or intermediate precedences.)\n\nOn each precedence level, you can declare (in order of increasing precedence) infix (binary non-associative), infixl (binary left-associative), infixr (binary right-associative), prefix (unary prefix) and postfix (unary postfix) operators. For instance, here is a typical excerpt from the prelude (the full table can be found in the Prelude section of the Pure Library Manual):\n\n```infix 1800 < > <= >= == ~= ;\ninfixl 2200 + - ;\ninfixl 2300 * / div mod ;\ninfixr 2500 ^ ;\nprefix 2600 # ;\n```\n\nNote\n\nUnary minus plays a special role in the syntax. Like in Haskell and following mathematical tradition, unary minus is the only prefix operator symbol which is also used as an infix operator, and is always on the same precedence level as binary minus, whose precedence may be chosen freely in the prelude. (The minus operator is the only symbol which gets that special treatment; all other operators must have distinct lexical representations.) Thus, with the standard prelude, -x+y will be parsed as (-x)+y, whereas -x*y is the same as -(x*y). Also note that the notation (-) always denotes the binary minus operator; the unary minus operation can be denoted using the built-in neg function.\n\nInstead of denoting the precedence by an explicit integer value, you can also specify an existing operator symbol enclosed in parentheses. Thus the following declaration gives the ++ operator the same precedence as +:\n\n```infixl (+) ++ ;\n```\n\nThe given symbol may be of a different fixity than the declaration, but it must have a proper precedence level (i.e., it must be an infix, prefix or postfix symbol). E.g., the following declaration gives ^^ the same precedence level as the infix ^ symbol, but turns it into a postfix operator:\n\n```postfix (^) ^^ ;\n```\n\nPure also provides unary outfix operators, which work like in Wm Leler’s constraint programming language Bertrand. These can be declared as follows:\n\noutfix left right ...;\n\nOutfix operators let you define your own bracket structures. The operators must be given as pairs of matching left and right symbols (which must be distinct). For instance:\n\n```outfix |: :| BEGIN END;\n```\n\nAfter this declaration you can write bracketed expressions like |:x:| or BEGIN foo, bar END. These are always at the highest precedence level (i.e., syntactically they work like parenthesized expressions). Just like other operators, you can turn outfix symbols into ordinary functions by enclosing them in parentheses, but you have to specify the symbols in matching pairs, such as (BEGIN END).\n\nPure also has a notation for “nullary” operators, that is, “operators without operands”. These are used to denote special literals which simply stand for themselves. They are introduced using a nonfix declaration:\n\nnonfix symbol ...;\n\nFor instance:\n\n```nonfix red green blue;\n```\n\nSemantically, nonfix symbols are a kind of “symbolic constants”. However, it is important to note the difference to defined constants, which are symbols bound to a constant value by means of a const definition. In fact, there are some use cases where a symbol may be both a defined constant and a nonfix symbol, see Constant Definitions in the Caveats and Notes section for details.\n\nSyntactically, nonfix symbols work just like ordinary identifiers, so they may stand whereever an identifier is allowed (no parentheses are required to “escape” them). However, just like other kinds of operators, they may also consist of punctuation (which isn’t allowed in ordinary identifiers). The other difference to ordinary identifiers is that nonfix symbols are always interpreted as literals, even if they occur in a variable position on the left-hand side of a rule. So, with the above declaration, you can write something like:\n\n```> foo x = case x of red = green; green = blue; blue = red end;\n> map foo [red,green,blue];\n[green,blue,red]\n```\n\nThus nonfix symbols are pretty much like nullary constructor symbols in languages like Haskell. Non-fixity is just a syntactic attribute, however. Pure doesn’t enforce that such values are irreducible, so you can still write a “constructor equation” like the following:\n\n```> red = blue;\n> map foo [red,green,blue];\n[blue,blue,blue]\n```\n\nExamples for all types of symbol declarations can be found in the prelude which declares a bunch of standard (arithmetic, relational, logical) operator symbols as well as the list and pair constructors ‘:‘ and ‘,‘, and a few nonfix symbols (true and false, as well as different kinds of exceptions).\n\n### Interface Types¶\n\nBesides the “concrete” types already described in the Type Rules section, Pure provides another, more abstract way to characterize a type through the collection of operations it supports. These interface types work pretty much like in Google’s Go programming language. They provide a safe form of Duck typing in which the operations available on a type are stated explicitly, and hence members of the type are always known to provide all of the listed operations.\n\nAn interface declaration gives the type name along with a collection of patterns, the so-called signature which specifies the manifest operations of the type:\n\n```interface_decl ::= \"interface\" qualified_identifier\n\"with\" interface_item* \"end\" \";\"\ninterface_item ::= pattern \";\"\n| \"interface\" qualified_identifier \";\"\n```\n\nInterfaces thus consist of two kinds of items:\n\n• The patterns, which indicate which operations are supported by the type, and which arguments they expect. This may be anything that can occur as the left-hand side of an ordinary function definition, cf. General Rules.\n• The name of another interface type. This causes the signature of the named interface type to be included in the interface type being defined, which effectively turns the new interface type into a subtype of the existing one.\n\nThe gist of an interface is in its patterns, more precisely: in the pattern variables which have the name of the interface as a type tag. The precise meaning of the patterns is as follows:\n\n• The patterns are matched against the left-hand sides of ordinary function definitions. If a left-hand side matches, any argument pattern substituted for a variable tagged with the interface type becomes a “candidate pattern” of the type.\n• The type consists of all candidate patterns which can be matched by some candidate pattern of each interface function. That is, candidate patterns which are only supported by some but not all of the interface functions, are eliminated.\n• Finally, all trivial candidate patterns (x where x is just a variable without any type tag, which thus matches any value) are eliminated as well.\n\nInterface patterns often take a simple form like the following,\n\n```interface foo with foo x::foo y z; end;\n```\n\nspecifying the number of arguments of the interface function along with the position of the interface type argument. However, general patterns are permitted, in order to further restrict the left-hand sides of the function definitions to be taken into consideration. Specifically, note that type tags other than the interface type must always be matched literally on the left-hand sides of equations. Thus,\n\n```interface foo with foo x::foo y::int; end;\n```\n\nmatches any rule of the form\n\n```foo x y::int = ...;\n```\n\nbut not:\n\n```foo x 0 = ...;\nfoo x y::bar = ...;\n```\n\n(unless bar happens to be an alias of the int type, of course). In such cases it is necessary to explicitly add these patterns to the interface if you want them to be included.\n\nInterface patterns may contain the interface type tag any number of times, yielding candidate patterns for each occurrence of the interface type tag in the pattern. For instance, here is a quick way to determine the type of all “addable” data structures in the prelude (this uses the interactive show interface command to list the patterns actually matched by an interface type, cf. The show Command):\n\n```> interface addable with x::addable + y::addable; end;\n```\n\nOn the other hand, interfaces may also contain “static” patterns which do not include the interface type as a tag at all, such as:\n\n```interface foo with bar x::bar y; end;\n```\n\nThese do not contribute anything to the candidate patterns of the type, but do restrict the type just like the other patterns, in that the type will be empty unless the static patterns are all “implemented”. In the example above, this means that the foo type will be empty unless the bar function is defined and takes an element of the bar type as its first argument.\n\nAn interface may also be empty, in which case it matches any value. Thus,\n\n```interface any with end;\n```\n\nis just a fancy way to define the type:\n\n```type any _;\n```\n\nInterfaces can be composed in a piecemeal fashion, by adding more interface patterns. Thus,\n\n```interface foo with foo x::foo; end;\ninterface foo with bar x::foo; end;\n```\n\nis equivalent to:\n\n```interface foo with foo x::foo; bar x::foo; end;\n```\n\nIt is also possible to include one interface in another, which effectively establishes a subtype relationship. For instance, here’s yet another way to define the foo interface above:\n\n```interface bar with\nbar x::bar;\nend;\n\ninterface foo with\nfoo x::foo;\ninterface bar;\nend;\n```\n\nThis has the effect of including the signature of bar in foo (while renaming the interface type tags in the bar signature accordingly):\n\n```> show foo\ninterface foo with\nfoo x::foo;\nbar x::foo;\nend;\n```\n\nNote\n\nIncluding interfaces is a static operation. Only the interface patterns known at the point of inclusion become part of the including interface; refining the included interface later has no effect on the set of included patterns. In particular, this also prevents circular interface definitions.\n\nWhen composing interfaces in this fashion, it is easy to end up with duplicate interface patterns from various sources. The compiler removes such duplicates, even if they only match up to the renaming of variables. For instance:\n\n```> show bar foo\ninterface bar with\nbar x::bar;\nend;\ninterface foo with\nfoo x::foo;\nbar x::foo;\nend;\n> interface baz with\n> interface foo; interface bar;\n> foo y::baz;\n> end;\n> show baz\ninterface baz with\nfoo x::baz;\nbar x::baz;\nend;\n```\n\nAlso note that, despite the obvious similarities between interfaces and classes in object-oriented programming, they are really different things. The former are essentially just signatures of functions living elsewhere, whereas the latter also include data layouts and method implementations. More on the similarities and differences of interfaces and classes can be found in the Go FAQ.\n\nLet’s now take a look at the example of a stack data structure to see how this all works in practice:\n\n```interface stack with\npush s::stack x;\npop s::stack;\ntop s::stack;\nend;\n```\n\nNote the use of the type tag stack in the operation patterns, which marks the positions of stack arguments of the interface operations. The interface tells us that a stack provides three operations push, pop and top which each take a stack as their first argument; also, push takes two arguments, while pop and top just take a single (stack) argument.\n\nThis information is all that the compiler needs to figure out which terms are members of the stack data type. To these ends, the compiler looks at existing definitions of push, pop and top and extracts the patterns for arguments marked with the stack tag in the interface. The stack patterns implemented by all of the interface operations make up the stack type; i.e., the members of the type are all the instances of these patterns.\n\nRight now our stack type doesn’t have any members, because we didn’t implement the interface operations yet, so let’s do this now. For instance, to implement stacks as lists, we might define:\n\n```push xs@[] x | push xs@(_:_) x = x:xs;\npop (x:xs) = xs;\ntop (x:xs) = x;\n```\n\nThis is also known as “instantiating” the type. In addition, we will need an operation to create an initial stack value. The following will do for our purposes:\n\n```stack xs::list = xs;\n```\n\nThis yields a stack with the given initial contents. Let’s give it a go:\n\n```> top (push (stack []) 99);\n99\n```\n\nLooks good so far. We can also check the actual definition of the type in terms of its type rules using the show interface command:\n\n```> show interface stack\ntype stack xs@(_:_);\n```\n\nWait, something seems to be wrong there. The empty list pattern of the push function is missing, where did it go? Let’s restart the interpreter with warnings enabled (-w) and retype the above definitions. The compiler then tells us:\n\n```> show interface stack\nwarning: interface 'stack' may be incomplete\nwarning: function 'pop' might lack a rule for 'xs@[]'\nwarning: function 'top' might lack a rule for 'xs@[]'\ntype stack xs@(_:_);\n```\n\nSee? A pattern is only considered part of the type if it is supported by all the interface operations. Since the pop and top operations don’t have any rules for empty list arguments, empty lists are excluded from the type. We can fix this quite easily by adding the following “error rules” which handle this case:\n\n```> pop [] = throw \"empty stack\";\n> top [] = throw \"empty stack\";\n> show interface stack\ntype stack xs@[];\ntype stack xs@(_:_);\n```\n\nThis looks fine now, so let’s see how we can put our new stack data structure to good use. Operations on the type are defined as usual, employing stack as a type tag for stack arguments so that we can be sure that the push, pop and top operations are all supported. For instance, let’s implement a little RPN (“Reverse Polish Notation”) calculator:\n\n```rpn xs::stack ops::list = foldl (call []) xs ops with\ncall ys xs op = push xs (foldl (\\$) op ys) if nargs op<=#ys;\n= call (top xs:ys) (pop xs) op otherwise;\nend;\n```\n\nThis takes an initial stack xs and a list ops of operands and operations as inputs and returns the resulting stack after processing ops. Examples:\n\n```> rpn (stack []) [10,4,3,(+),2,(*),(-)];\n[-4]\n> using math;\n> rpn (stack []) [1,2,ln,(/)];\n[1.44269504088896]\n> rpn (stack []) [4,1,atan,(*)];\n[3.14159265358979]\n> rpn (stack []) [2,(*)];\n<stdin>, line 5: unhandled exception '\"empty stack\"' while evaluating\n'rpn (stack []) [2,(*)]'\n```\n\nOk, this is all very nice, but it seems that so far we haven’t done much more than we could have achieved just as easily with plain lists instead. So what are the benefits of having an interface type?\n\nFirst, an interface provides a fair amount of safety. As long as we stick to the interface functions, we can be sure that the data is capable of carrying out the requested operations. At the same time, the interface also serves as a valuable piece of documentation, since it tells us at a glance exactly which operations are supported by the type.\n\nSecond, an interface provides data abstraction. We don’t need to know how the interface operations are implemented, and in fact functions coded against the interface will work with any implementation of the interface. For instance, suppose that we’d like to provide a “bounded stacks” data structure, i.e., stacks which don’t grow beyond a certain limit. These can be implemented as follows:\n\n```push (n,xs@[]) x | push (n,xs@(_:_)) x =\nif n>0 then (n-1,x:xs) else throw \"full stack\";\npop (n,x:xs) = n+1,xs;\ntop (n,x:xs) = x;\npop (n,[]) = throw \"empty stack\";\ntop (n,[]) = throw \"empty stack\";\n```\n\nNote that we represent a bounded stack by a pair (n,xs) here, where xs is the list of elements and n is the “free space” (number of elements we still allow to be pushed). We also add a function to construct such values:\n\n```bstack n::int xs::list = (n-#xs,xs);\n```\n\nWithout any further ado, our little RPN calculator works just fine with the new variation of the data structure:\n\n```> rpn (bstack 3 []) [10,4,3,(+),2,(*),(-)];\n2,[-4]\n> rpn (bstack 2 []) [10,4,3,(+),2,(*),(-)];\n<stdin>, line 7: unhandled exception '\"full stack\"' while evaluating\n'rpn (bstack 2 []) [10,4,3,(+),2,(*),(-)]'\n```\n\nWhile they’re quite useful in general, Pure’s interface types also have their limitations. In particular, the guarantees provided by an interface are of a purely syntactic nature; the signature doesn’t tell us anything about the actual meaning of the provided operations, so unit testing is still needed to ensure certain semantic properties of the implementation. Some further issues due to Pure’s dynamically typed nature are discussed under Interfaces in the Caveats and Notes section.\n\n### Modules and Imports¶\n\nPure doesn’t offer separate compilation, but the following type of declaration provides a simple but effective way to assemble a Pure program from several source modules.\n\n```using_decl ::= \"using\" name (\",\" name)* \";\"\nname ::= qualified_identifier | string\n```\n\nThe using declaration takes the following form (note that in contrast to symbol declarations, the comma is used as a delimiter symbol here):\n\nusing name, ...;\n\nThis causes each given script to be included in the Pure program at the given point (if it wasn’t already included before), which makes available all the definitions of the included script in your program. Note that each included script is loaded only once, when the first using clause for the script is encountered. Nested imports are allowed, i.e., an imported module may itself import other modules, etc. A Pure program then basically is the concatenation of all the source modules given as command line arguments, with other modules listed in using clauses inserted at the corresponding source locations.\n\n(The using clause also has an alternative form which allows dynamic libraries and LLVM bitcode modules to be loaded, this will be discussed in the C Interface section.)\n\nFor instance, the following declaration causes the math.pure script from the standard library to be included in your program:\n\n```using math;\n```\n\nYou can also import multiple scripts in one go:\n\n```using array, dict, set;\n```\n\nMoreover, Pure provides a notation for qualified module names which can be used to denote scripts located in specific package directories, e.g.:\n\n```using examples::libor::bits;\n```\n\nIn fact this is equivalent to the following using clause which spells out the real filename of the script between double quotes (the .pure suffix can also be omitted in which case it is added automatically):\n\n```using \"examples/libor/bits.pure\";\n```\n\nBoth notations can be used interchangeably; the former is usually more convenient, but the latter allows you to denote scripts whose names aren’t valid Pure identifiers.\n\nScript identifiers are translated to the corresponding filenames by replacing the ‘::‘ symbol with the pathname separator ‘/‘ and tacking on the ‘.pure‘ suffix. The following table illustrates this with a few examples.\n\nScript identifier Filename\nmath \"math.pure\"\nexamples::libor::bits \"examples/libor/bits.pure\"\n::pure::examples::hello \"/pure/examples/hello.pure\"\n\nNote the last example, which shows how an absolute pathname can be denoted using a qualifier starting with ‘::‘.\n\nUnless an absolute pathname is given, the interpreter performs a search to locate the script. The search algorithm considers the following directories in the given order:\n\n• the directory of the current script, which is the directory of the script containing the using clause, or the current working directory if the clause was read from standard input (as is the case, e.g., in an interactive session);\n• the directories named in -I options on the command line (in the given order);\n• the colon-separated list of directories in the PURE_INCLUDE environment variable (in the given order);\n• finally the directory named by the PURELIB environment variable.\n\nNote that the current working directory is not searched by default (unless the using clause is read from standard input), but of course you can force this by adding the option -I. to the command line, or by including ‘.’ in the PURE_INCLUDE variable.\n\nThe directory of the current script (the first item above) can be skipped by specifying the script to be loaded as a filename in double quotes, prefixed with the special sys: tag. The search then starts with the “system” directories (-I, PURE_INCLUDE and PURELIB) instead. This is useful, e.g., if you want to provide your own custom version of a standard library script which in turn imports that library script. For instance, a custom version of math.pure might employ the following using clause to load the math.pure script from the Pure library:\n\n```using \"sys:math\";\n// custom definitions go here\nlog2 x = ln x/ln 2;\n```\n\nThe interpreter compares script names (to determine whether two scripts are actually the same) by using the canonicalized full pathname of the script, following symbolic links to the destination file (albeit only one level). Thus different scripts with the same basename, such as foo/utils.pure and bar/utils.pure can both be included in the same program (unless they link to the same file).\n\nMore precisely, canonicalizing a pathname involves the following steps:\n\n• relative pathnames are expanded to absolute ones, using the search rules discussed above;\n• the directory part of the pathname is normalized to the form returned by the getcwd system call;\n• the ”.pure” suffix is added if needed;\n• if the resulting script name is actually a symbolic link, the interpreter follows that link to its destination, albeit only one level. (This is only done on Unix-like systems.)\n\nThe directory of the canonicalized pathname is also used when searching other scripts included in a script. This makes it possible to have an executable script with a shebang line in its own directory, which is then executed via a symbolic link placed on the system PATH. In this case the script search performed in using clauses will use the real script directory and thus other required scripts can be located there. This is the recommended practice for installing standalone Pure applications in source form which are to be run directly from the shell.\n\n### Namespaces¶\n\nTo facilitate modular development, Pure also provides namespaces as a means to avoid name clashes between symbols, and to keep the global namespace tidy and clean. Namespaces serve as containers holding groups of related identifiers and other symbols. Inside each namespace, symbols must be unique, but the same symbol may be used to denote different objects (variables, functions, etc.) in different namespaces. (Pure’s namespace system was heavily inspired by C++ and works in a very similar fashion. So if you know C++ you should feel right at home and skimming this section to pick up Pure’s syntax of the namespace constructs should be enough to start using it.)\n\nThe global namespace is always available. By default, new symbols are created in this namespace, which is also called the default namespace. Additional namespaces can be created with the namespace declaration, which also switches to the given namespace (makes it the current namespace), so that new symbols are then created in that namespace rather than the default one. The current namespace also applies to all kinds of symbol declarations, including operator and nonfix symbol declarations, as well as extern declarations (the latter are described in the C Interface section).\n\nThe syntax of namespace declarations is captured by the following grammar rules:\n\n```namespace_decl ::= \"namespace\" [name] [brackets] \";\"\n| \"namespace\" name [brackets] \"with\" item+ \"end\" \";\"\n| \"using\" \"namespace\" [name_spec (\",\" name_spec)*] \";\"\nbrackets ::= \"(\" left_op right_op \")\"\nname_spec ::= name [\"(\" qualified_symbol+ \")\"]\n```\n\nThe basic form of the namespace declaration looks as follows (there’s also a “scoped” form of the namespace declaration which will be discussed in Scoped Namespaces at the end of this section):\n\n```namespace name;\n// declarations and definitions in namespace 'name'\nnamespace;\n```\n\nThe second form switches back to the default namespace. For instance, in order to define two symbols with the same print name foo in two different namespaces foo and bar, you can write:\n\n```namespace foo;\nfoo x = x+1;\nnamespace bar;\nfoo x = x-1;\nnamespace;\n```\n\nWe can now refer to the symbols we just defined using qualified symbols of the form namespace::symbol:\n\n```> foo::foo 99;\n100\n> bar::foo 99;\n98\n```\n\nThis avoids any potential name clashes, since the qualified identifier notation always makes it clear which namespace the given identifier belongs to.\n\nA namespace can be “reopened” at any time to add new symbols and definitions to it. This allows namespaces to be created that span several source modules. You can also create several different namespaces in the same module.\n\nSimilar to the using declaration, a namespace declaration accepts either identifiers or double-quoted strings as namespace names. E.g., the following two declarations are equivalent:\n\n```namespace foo;\nnamespace \"foo\";\n```\n\nThe latter form also allows more descriptive labels which aren’t identifiers, e.g.:\n\n```namespace \"Private stuff, keep out!\";\n```\n\nNote that the namespace prefix in a qualified identifier must be a legal identifier, so it isn’t possible to access symbols in namespaces with such descriptive labels in a direct fashion. The only way to get at the symbols in this case is with namespace brackets or by using a namespace or using namespace declaration (for the latter see Using Namespaces below).\n\n#### Using Namespaces¶\n\nSince it is rather inconvenient if you always have to write identifiers in their qualified form outside of their “home” namespace, Pure allows you to specify a list of search namespaces which are used to look up symbols not in the default or the current namespace. This is done with the using namespace declaration, which takes the following form:\n\n```using namespace name1, name2, ...;\n// ...\nusing namespace;\n```\n\nAs with namespace declarations, the second form without any namespace arguments gets you back to the default empty list of search namespaces.\n\nFor instance, consider this example:\n\n```namespace foo;\nfoo x = x+1;\nnamespace bar;\nfoo x = x-1;\nbar x = x+1;\nnamespace;\n```\n\nThe symbols in these namespaces can be accessed unqualified as follows:\n\n```> using namespace foo;\n> foo 99;\n100\n> using namespace bar;\n> foo 99;\n98\n> bar 99;\n100\n```\n\nThis method is often to be preferred over opening a namespace with the namespace declaration, since using namespace only gives you “read access” to the imported symbols, so you can’t accidentally mess up the definitions of the namespace you’re using. Another advantage is that the using namespace declaration also lets you search multiple namespaces at once:\n\n```using namespace foo, bar;\n```\n\nBe warned, however, that this brings up the very same issue of name clashes again:\n\n```> using namespace foo, bar;\n> foo 99;\n<stdin>, line 15: symbol 'foo' is ambiguous here\n```\n\nIn such a case you’ll have to resort to using namespace qualifiers again, in order to resolve the name clash:\n\n```> foo::foo 99;\n100\n```\n\nTo avoid this kind of mishap, you can also selectively import just a few symbols from a namespace instead. This can be done with a declaration of the following form:\n\n```using namespace name1 ( sym1 sym2 ... ), name2 ... ;\n```\n\nAs indicated, the symbols to be imported can optionally be placed as a whitespace-delimited list inside parentheses, following the corresponding namespace name. (As with symbol declarations, the symbols may optionally be qualified with a namespace prefix, which must match the imported namespace here.) For instance:\n\n```> using namespace foo, bar (bar);\n> foo 99;\n100\n> bar 99;\n100\n> bar::foo 99;\n98\n```\n\nNote that now we have no clash on the foo symbol any more, because we restricted the import from the bar namespace to the bar symbol, so that bar::foo has to be denoted with a qualified symbol now.\n\n#### Symbol Lookup and Creation¶\n\nPure’s rules for looking up and creating symbols are fairly straightforward and akin to those in other languages featuring namespaces. However, there are some intricacies involved, because the rewriting rule format of definitions allows “referential” use of symbols not only in the “body” (right-hand side) of a definition, but also in the left-hand side patterns. We discuss this in detail below.\n\nThe compiler searches for symbols first in the current namespace (if any), then in the currently active search namespaces (if any), and finally in the default (i.e., the global) namespace, in that order. This automatic lookup can be bypassed by using an absolute namespace qualifier of the form ::foo::bar. In particular, ::bar always denotes the symbol bar in the default namespace, while ::foo::bar denotes the symbol bar in the foo namespace. (Normally, the latter kind of notation is only needed if you have to deal with nested namespaces, see Hierarchical Namespaces below.)\n\nIf no existing symbol is found, a new symbol is created automatically, by implicitly declaring a public symbol with default attributes. New unqualified symbols are always created in the current namespace, while new qualified symbols are created in the namespace given by the namespace prefix of the symbol.\n\nNote\n\nPure’s implicit symbol declarations are a mixed blessing. They are convenient, especially in interactive usage, but they also let missing or mistyped symbols go unnoticed much too easily. As a remedy, in the case of qualified symbols the compiler checks that the given namespace prefix matches the current namespace, in order to catch typos and other silly mistakes and prevent you from accidentally clobbering the contents of other namespaces. For instance:\n\n```> namespace foo;\n> namespace;\n> foo::bar x = 1/x;\n<stdin>, line 3: undeclared symbol 'foo::bar'\n```\n\nTo make these errors go away it’s enough to just declare the symbols in their proper namespaces.\n\nIn addition, you can run the interpreter with the -w option (see Invoking Pure) to check your scripts for (non-defining) uses of undeclared unqualified function symbols. This is highly recommended. For instance, in the following example we forgot to import the system module which defines the puts function. Running the interpreter with -w highlights such potential errors:\n\n```\\$ pure -w\n> puts \"bla\"; // missing import of system module\n<stdin>, line 1: warning: implicit declaration of 'puts'\nputs \"bla\"\n```\n\nFor legitimate uses (such as forward uses of a symbol which is defined later), you can make these warnings go away by declaring the symbol before using it.\n\nNew symbols are also created if a global unqualified (and yet undeclared) symbol is being “defined” in a rewriting rule or let/const definition, even if a symbol with the same print name from another namespace is already visible in the current scope. To distinguish “defining” from “referring” uses of a global symbol, Pure uses the following (purely syntactic) notions:\n\n• A defining occurrence of a global function, macro or type symbol is any occurrence of the symbol as the (leftmost) head symbol on the left-hand side of a rewriting rule.\n• A defining occurrence of a global variable or constant symbol is any occurrence of the symbol in a variable position (as given by the “head = function” rule, cf. Variables in Equations) on the left-hand side of a let or const definition.\n• All other occurrences of global symbols on the left-hand side, as well as all symbol occurrences on the right-hand side of a definition are referring occurrences. (Note that this also subsumes all occurrences of type tags on the left-hand side of an equation.)\n\nThe following example illustrates these notions:\n\n```namespace foo;\nbar (bar x) = bar x;\nlet x,y = 1,2;\nnamespace;\n```\n\nHere, the first occurrence of bar on the left-hand side bar (bar x) of the first rule is a defining occurrence, as are the occurrences of x and y on the left-hand side of the let definition. Hence these symbols are created as new symbols in the namespace foo. On the other hand, the other occurrences of bar in the first rule, as well as the ‘,‘ symbol on the left-hand side of the let definition are referring occurrences. In the former case, bar refers to the bar symbol defined by the rule, while in the latter case the ‘,‘ operator is actually declared in the prelude and thus imported from the global namespace.\n\nThe same rules of lookup also apply to type tags on the left-hand side of an equation, but in this case the interpreter will look specifically for type symbols, avoiding any other kinds of symbols which might be visible in the same context. Thus, in the following example, the type tag bar is correctly resolved to bar::bar, even though the (function) symbol foo::bar is visible at this point:\n\n```> namespace bar;\n> type bar;\n> namespace foo;\n> public bar;\n> using namespace bar;\n> foo x::bar = bar x;\n> show foo::foo\nfoo::foo x :: bar::bar = foo::bar x;\n```\n\nNote that special operator (and nonfix) symbols always require an explicit declaration. This works as already discussed in the Symbol Declarations section, except that you first switch to the appropriate namespace before declaring the symbols. For instance, here is how you can create a new + operation which multiplies its operands rather than adding them:\n\n```> namespace my;\n> infixl 2200 +;\n> x+y = x*y;\n> 5+7;\n35\n```\n\nNote that the new + operation really belongs to the namespace we created. The + operation in the default namespace works as before, and in fact you can use qualified symbols to pick the version that you need:\n\n```> namespace;\n> 5+7;\n12\n> 5 ::+ 7;\n12\n> 5 my::+ 7;\n35\n```\n\nHere’s what you get if you happen to forget the declaration of the + operator:\n\n```> namespace my;\n> x+y = x*y;\n<stdin>, line 2: infixl symbol '+' was not declared in this namespace\n```\n\nThus the compiler will never create a new instance of an operator symbol on the fly, an explicit declaration is always needed in such cases.\n\nNote that if you really wanted to redefine the global + operator, you can do this even while the my namespace is current. You just have to use a qualified identifier in this case, as follows:\n\n```> namespace my;\n> x ::+ y = x*y;\n> a+b;\na*b\n```\n\nThis should rarely be necessary (in the above example you might just as well enter this rule while in the global namespace), but it can be useful in some circumstances. Specifically, you might want to “overload” a global function or operator with a definition that makes use of private symbols of a namespace (which are only visible inside that namespace; see Private Symbols below). For instance:\n\n```> namespace my;\n> private bar;\n> bar x y = x*y;\n> x ::+ y = bar x y;\n> a+b;\na*b\n```\n\n(The above is a rather contrived example, since the very same functionality can be accomplished much easier, but there are some situations where this method is needed.)\n\n#### Private Symbols¶\n\nPure also allows you to have private symbols, as a means to hide away internal operations which shouldn’t be accessed directly outside the namespace in which they are declared. The scope of a private symbol is confined to its namespace, i.e., the symbol is only visible when its “home” namespace is current. Symbols are declared private by using the private keyword in the symbol declaration:\n\n```> namespace secret;\n> private baz;\n> // 'baz' is a private symbol in namespace 'secret' here\n> baz x = 2*x;\n> // you can use 'baz' just like any other symbol here\n> baz 99;\n198\n> namespace;\n```\n\nNote that, at this point, secret::baz is now invisible, even if you have secret in the search namespace list:\n\n```> using namespace secret;\n> // this actually creates a 'baz' symbol in the default namespace:\n> baz 99;\nbaz 99\n> secret::baz 99;\n<stdin>, line 27: symbol 'secret::baz' is private here\n```\n\nThe only way to bring the symbol back into scope is to make the secret namespace current again:\n\n```> namespace secret;\n> baz 99;\n198\n> secret::baz 99;\n198\n```\n\n#### Namespace Brackets¶\n\nAll the namespace-related constructs we discussed so far only provide a means to switch namespaces on a per-rule basis. Sometimes it is convenient if you can switch namespaces on the fly inside an expression. This is especially useful if you want to embed a domain-specific sublanguage (DSL) in Pure. DSLs typically provide their own system of operators which differ from the standard Pure operators and thus need to be declared in their own namespace.\n\nTo make this possible, Pure allows you to associate a namespace with a corresponding pair of outfix symbols. This turns the outfix symbols into special namespace brackets which can then be used to quickly switch namespaces in an expression by just enclosing a subexpression in the namespace brackets.\n\nTo these ends, the syntax of namespace declarations allows you to optionally specify a pair of outfix symbols inside parentheses after the namespace name. The outfix symbols to be used as namespace brackets must have been declared beforehand. For instance:\n\n```outfix « »;\nnamespace foo (« »);\ninfixr (::^) ^;\nx^y = 2*x+y;\nnamespace;\n```\n\nThe code above introduces a foo namespace which defines a special variation of the (^) operator. It also associates the namespace with the « » brackets so that you can write:\n\n```> (a+b)^c+10;\n(a+b)^c+10\n> «(a+b)^c»+10;\n2*(a+b)+c+10\n```\n\nNote the use of the namespace brackets in the second input line. This changes the meaning of the ^ operator, which now refers to foo::^ instead. Also note that the namespace brackets themselves are removed from the resulting expression; they are only used to temporarily switch the namespace to foo inside the bracketed subexpression. This works pretty much like a namespace declaration (so any active search namespaces remain in effect), but is limited in scope to the bracketed subexpression and only gives access to the public symbols of the namespace (like a using namespace declaration would do).\n\nThe rules of visibility for the namespace bracket symbols themselves are the same as for any other symbols. So they need to be in scope if you want to denote them in unqualified form (which is always the case if they are declared in the default namespace, as in the example above). If necessary, you can also specify them in their qualified form as usual.\n\nNamespace brackets can be used anywhere inside an expression, even on the left-hand side of a rule. So, for instance, we might also have written the example above as follows:\n\n```outfix « »;\nnamespace foo (« »);\ninfixr (::^) ^;\nnamespace;\n\n«x^y» = 2*x+y;\n```\n\nNote the use of the namespace brackets on the last line. This rule actually expands to:\n\n```x foo::^ y = 2*x+y;\n```\n\nThe special meaning of namespace brackets can be turned off and back on again at any time with a corresponding namespace declaration. For instance:\n\n```> namespace (« »); // turn off the special meaning of « »\n> «(a+b)^c»+10;\n« (a+b)^c »+10\n> namespace foo (« »); // turn it on again\n> namespace;\n> «(a+b)^c»+10;\n2*(a+b)+c+10\n```\n\n(Note that as a side effect these declarations also change the current namespace, so that we use the namespace; declaration in the second last line to change back to the default namespace.)\n\nAs shown in the first line of the example above, a namespace brackets declaration without a namespace just turns off the special processing of the brackets. In order to define a namespace bracket for the default namespace, you need to explicitly specify an empty namespace instead, as follows:\n\n```> outfix «: :»;\n> namespace \"\" («: :»);\n> «(a+b)^«:x^y:»»;\n2*(a+b)+x^y\n```\n\nAs this example illustrates, namespace brackets can also be nested, which is useful, e.g., if you need to combine subexpressions from several DSLs in a single expression. In this example we employ the «:x^y:» subexpression to temporarily switch back to the default namespace inside the « »-bracketed expression which is parsed in the foo namespace.\n\n#### Hierarchical Namespaces¶\n\nNamespace identifiers can themselves be qualified identifiers in Pure, which enables you to introduce a hierarchy of namespaces. This is useful, e.g., to group related namespaces together under a common “umbrella” namespace:\n\n```namespace my;\nnamespace my::old;\nfoo x = x+1;\nnamespace my::new;\nfoo x = x-1;\n```\n\nNote that the namespace my, which serves as the parent namespace, must be created before the my::old and my::new namespaces, even if it does not contain any symbols of its own. After these declarations, the my::old and my::new namespaces are part of the my namespace and will be considered in name lookup accordingly, so that you can write:\n\n```> using namespace my;\n> old::foo 99;\n100\n> new::foo 99;\n98\n```\n\nThis works pretty much like a hierarchy of directories and files, where the namespaces play the role of the directories (with the default namespace as the root directory), the symbols in each namespace correspond to the files in a directory, and the using namespace declaration functions similar to the shell’s PATH variable.\n\nSometimes it is necessary to tell the compiler to use a symbol in a specific namespace, bypassing the usual symbol lookup mechanism. For instance, suppose that we introduce another global old namespace and define yet another version of foo in that namespace:\n\n```namespace old;\nfoo x = 2*x;\nnamespace;\n```\n\nNow, if we want to access that function, with my still active as the search namespace, we cannot simply refer to the new function as old::foo, since this name will resolve to my::old::foo instead. As a remedy, the compiler accepts an absolute qualified identifier of the form ::old::foo. This bypasses name lookup and thus always yields exactly the symbol in the given namespace (if it exists; as mentioned previously, the compiler will complain about an undeclared symbol otherwise):\n\n```> old::foo 99;\n100\n> ::old::foo 99;\n198\n```\n\nAlso note that, as a special case of the absolute qualifier notation, ::foo always denotes the symbol foo in the default namespace.\n\n#### Scoped Namespaces¶\n\nPure also provides an alternative scoped namespace construct which makes nested namespace definitions more convenient. This construct takes the following form:\n\n```namespace name with ... end;\n```\n\nThe part between with and end may contain arbitrary declarations and definitions, using the same syntax as the toplevel. These are processed in the context of the given namespace, as if you had written:\n\n```namespace name;\n...\nnamespace;\n```\n\nHowever, the scoped namespace construct always returns you to the namespace which was active before, and thus these declarations may be nested:\n\n```namespace foo with\n// declarations and definitions in namespace foo\nnamespace bar with\n// declarations and definitions in namespace bar\nend;\n// more declarations and definitions in namespace foo\nend;\n```\n\nNote that this kind of nesting does not necessarily imply a namespace hierarchy as discussed in Hierarchical Namespaces. However, you can achieve this by using the appropriate qualified namespace names:\n\n```namespace foo with\n// ...\nnamespace foo::bar with\n// ...\nend;\n// ...\nend;\n```\n\nAnother special feature of the scoped namespace construct is that using namespace declarations are always local to the current namespace scope (and other nested namespace scopes inside it). Thus the previous setting is restored at the end of each scope:\n\n```using namespace foo;\nnamespace foo with\n// still using namespace foo here\nusing namespace bar;\n// now using namespace bar\nnamespace bar with\n// still using namespace bar here\nusing namespace foo;\n// now using namespace foo\nend;\n// back to using namespace bar\nend;\n// back to using namespace foo at toplevel\n```\n\nFinally, here’s a more concrete example which shows how scoped namespaces might be used to declare two namespaces and populate them with various functions and operators:\n\n```namespace foo with\ninfixr (::^) ^;\nfoo x = x+1;\nbar x = x-1;\nx^y = 2*x+y;\nend;\n\nnamespace bar with\noutfix <: :>;\nfoo x = x+2;\nbar x = x-2;\nend;\n\nusing namespace foo(^ foo), bar(bar <: :>);\n\n// namespace foo\nfoo x;\nx^y;\n\n// namespace bar\nbar x;\n<: x,y :>;\n```\n\nPure’s namespaces can thus be used pretty much like “packages” or “modules” in languages like Ada or Modula-2. They provide a structured way to describe program components offering collections of related data and operations, which can be brought into scope in a controlled way by making judicious use of using namespace declarations. They also provide an abstraction barrier, since internal operations and data structures can be hidden away employing private symbols.\n\nPlease note that these facilities are not Pure’s main focus and thus they are somewhat limited compared to programming languages specifically designed for big projects and large teams of developers. Nevertheless they should be useful if your programs grow beyond a small collection of simple source modules, and enable you to manage most Pure projects with ease.\n\n## Macros¶\n\nMacros are a special type of functions to be executed as a kind of “preprocessing stage” at compile time. In Pure these are typically used to define custom special forms and to perform inlining of function calls and other kinds of source-level optimizations.\n\nWhereas the macro facilities of most programming languages simply provide a kind of textual substitution mechanism, Pure macros operate on symbolic expressions and are implemented by the same kind of rewriting rules that are also used to define ordinary functions in Pure. This makes them robust and easy to use for most common preprocessing purposes.\n\nSyntactically, a macro definition looks just like a function definition with the def keyword in front of it. Only unconditional rewriting rules are permitted here, i.e., rules without guards and multiple right-hand sides. However, multiple left-hand sides can be employed as usual to abbreviate a collection of rules with the same left-hand side, as described in the General Rules section.\n\nThe major difference between function and macro definitions is that the latter are processed at compile time rather than run time. To these ends, macro calls on the right-hand sides of function, constant and variable definitions are evaluated by reducing them to normal form using the available macro rules. The resulting expressions are then substituted for the macro calls. All macro substitution happens before constant substitutions and the actual compilation step. Macros can be defined in terms of other macros (also recursively), and are normally evaluated using call by value (i.e., macro calls in macro arguments are expanded before the macro gets applied to its parameters).\n\nIn the first half of this section we start out with some common uses of macros which should cover most aspects of macro programming that the average Pure programmer will need. The remainder of this section then discusses some more advanced features of Pure’s macro system intended for power users.\n\n### Optimization Rules¶\n\nLet’s begin with a simple example of an optimization rule from the prelude, which eliminates saturated instances of the right-associative function application operator (you can find this near the beginning of prelude.pure):\n\n```def f \\$ x = f x;\n```\n\nLike in Haskell, ‘\\$‘ in fact just denotes function application, but it is a low-priority operator which is handy to write cascading function calls. With the above macro rule, these will be “inlined” as ordinary function applications automatically. Example:\n\n```> foo x = bar \\$ bar \\$ 2*x;\n> show foo\nfoo x = bar (bar (2*x));\n```\n\nNote that a macro may have the same name as an ordinary Pure function, which is essential if you want to inline calls to an existing function. (Just like ordinary functions, the number of parameters in each rule for a given macro must be the same, but a macro may have a different number of arguments than the corresponding function.)\n\nWhen running interactively, you can follow the reduction steps the compiler performs during macro evaluation. To these ends, you have to set “tracepoints” on the relevant macros, using the trace command with the -m option; see Interactive Commands. (This works even if the interpreter is run in non-debugging mode.) Note that since macro expansion is performed at compile time, you’ll have to do this before entering the definitions in which the macro is used. However, in many cases you can also just enter the right-hand side of the equation at the interpreter prompt to see how it gets expanded. For instance:\n\n```> trace -m \\$\n> bar \\$ bar \\$ 2*x;\n-- macro (\\$): bar\\$2*x --> bar (2*x)\n-- macro (\\$): bar\\$bar (2*x) --> bar (bar (2*x))\nbar (bar (2*x))\n```\n\nNow let’s see how we can add our own optimization rules. Suppose we’d like to expand saturated calls of the succ function. This function is defined in the prelude; it just adds 1 to its single argument. We can inline such calls as follows:\n\n```> def succ (x+y) = x+(y+1);\n> def succ x = x+1;\n> foo x = succ (succ (succ x));\n> show foo\nfoo x = x+3;\n```\n\nAgain, let’s see exactly what’s going on there:\n\n```> trace -m succ\n> succ (succ (succ x));\n-- macro succ: succ x --> x+1\n-- macro succ: succ (x+1) --> x+(1+1)\n-- macro succ: succ (x+(1+1)) --> x+(1+1+1)\nx+3\n```\n\nNote that the contraction of the subterm 1+1+1 to the integer constant 3 is actually done by the compiler after macro expansion has been performed. This is also called “constant folding”, see Constant Definitions in the Caveats and Notes section for details. It is also the reason that we added the first rule for succ. This rule may seem superflous at first sight, but actually it is needed to massage the sum into a form which enables constant folding.\n\nRules like these can help the compiler generate better code. Of course, the above examples are still rather elementary. Pure macros can do much more elaborate optimizations, but for this we first need to discuss how to write recursive macros, as well as macros which take apart special terms like lambdas. After that we’ll return to the subject of optimization rules in Advanced Optimization below.\n\n### Recursive Macros¶\n\nMacros can also be recursive, in which case they usually consist of multiple rules and make use of pattern-matching just like ordinary function definitions.\n\nNote\n\nPure macros are just as powerful as (unconditional) term rewriting systems and thus they are Turing-complete. This implies that a badly written macro may well send the Pure compiler into an infinite recursion, which results in a stack overflow at compile time.\n\nAs a simple example, let’s see how we can inline invocations of the # size operator on list constants:\n\n```def #[] = 0;\ndef #(x:xs) = #xs+1;\n```\n\nAs you can see, the definition is pretty straightforward; exactly the same rules might also be used for an ordinary function definition, although the standard library actually implements # a bit differently to make good use of tail recursion. Let’s check that this actually works:\n\n```> foo = #[1,2,3,4];\n> show foo\nfoo = 4;\n```\n\nNote that the result of macro expansion is actually 0+1+1+1+1 here, you can check that by running the macro with trace -m #. Constant folding contracts this to 4 after macro expansion, as explained in the previous subsection.\n\nThis was rather easy. So let’s implement a more elaborate example: a basic Pure version of Lisp’s quasiquote which allows you to create a quoted expression from a “template” while substituting variable parts of the template. (For the sake of brevity, we present a somewhat abridged version here which does not cover all corner cases. The full version of this macro can be found as lib/quasiquote.pure in the Pure distribution.)\n\n```def quasiquote (unquote x) = x;\ndef quasiquote (f@_ (splice x)) = foldl (\\$) (quasiquote f) x;\ndef quasiquote (f@_ x) = quasiquote f (quasiquote x);\ndef quasiquote x = quote x;\n```\n\n(Note the f@_, which is an anonymous “as” pattern forcing the compiler to recognize f as a function variable, rather than a literal function symbol. See “As” Patterns in the Caveats and Notes section for an explanation of this trick.)\n\nThe first rule above takes care of “unquoting” embedded subterms. The second rule “splices” an argument list into an enclosing function application. The third rule recurses into subterms of a function application, and the fourth and last rule takes care of quoting the “atomic” subterms. Note that unquote and splice themselves are just passive constructor symbols, the real work is done by quasiquote, using foldl at runtime to actually perform the splicing. (Putting off the splicing until runtime makes it possible to splice argument lists computed at runtime.)\n\nIf we want, we can also add some syntactic sugar for Lisp weenies. (Note that we cannot have ‘,‘ for unquoting, so we use ‘,\\$‘ instead.)\n\n```prefix 9 ` ,\\$ ,@ ;\ndef `x = quasiquote x; def ,\\$x = unquote x; def ,@x = splice x;\n```\n\nExamples:\n\n```> `(2*42+2^12);\n2*42+2^12\n> `(2*42+,\\$(2^12));\n2*42+4096.0\n> `foo 1 2 (,@'[2/3,3/4]) (5/6);\nfoo 1 2 (2/3) (3/4) (5/6)\n> `foo 1 2 (,@args) (5/6) when args = '[2/3,3/4] end;\nfoo 1 2 (2/3) (3/4) (5/6)\n```\n\n### User-Defined Special Forms¶\n\nThe quasiquote macro in the preceding subsection also provides an example of how you can use macros to define your own special forms. This works because the actual evaluation of macro arguments is put off until runtime, and thus we can safely pass them to built-in special forms and other constructs which defer their evaluation at runtime. In fact, the right-hand side of a macro rule may be an arbitrary Pure expression involving conditional expressions, lambdas, binding clauses, etc. These are never evaluated during macro substitution, they just become part of the macro expansion (after substituting the macro parameters).\n\nHere is another useful example of a user-defined special form, the macro timex which employs the system function clock to report the cpu time in seconds needed to evaluate a given expression, along with the computed result:\n\n```> using system;\n> def timex x = (clock-t0)/CLOCKS_PER_SEC,y when t0 = clock; y = x end;\n> sum = foldl (+) 0L;\n> timex \\$ sum (1L..100000L);\n0.43,5000050000L\n```\n\nNote that the above definition of timex wouldn’t work as an ordinary function definition, since by virtue of Pure’s basic eager evaluation strategy the x parameter would have been evaluated already before it is passed to timex, making timex always return a zero time value. Try it!\n\n### Macro Hygiene¶\n\nPure macros are lexically scoped, i.e., the binding of symbols in the right-hand-side of a macro definition is determined statically by the text of the definition, and macro parameter substitution also takes into account binding constructs, such as with and when clauses, in the right-hand side of the definition. Macro facilities with these pleasant properties are also known as hygienic macros. They are not susceptible to so-called “name capture,” which makes macros in less sophisticated languages bug-ridden and hard to use.\n\nMacro hygiene is a somewhat esoteric topic for most programmers, so let us take a brief look at what it’s all about. The problem avoided by hygienic macros is that of name capture. There are actually two kinds of name capture which may occur in unhygienic macro systems:\n\n• A free symbol in the macro body inadvertently becomes bound to the value of a local symbol in the context in which the macro is called.\n• A free symbol in the macro call inadvertently becomes bound to the value of a local symbol in the macro body.\n\nPure’s hygienic macros avoid both pitfalls. Here is an example for the first form of name capture:\n\n```> def G x = x+y;\n> G 10 when y = 99 end;\n10+y\n```\n\nNote that the expansion of the G macro correctly uses the global instance of y, even though y is locally defined in the context of the macro call. (In some languages this form of name capture is sometimes used deliberately in order to make the macro use the binding of the symbol which is active at the point of the macro call. Normally, this won’t work in Pure, although there is a way to force this behaviour in Pure as well, see Name Capture in the Caveats and Notes section.)\n\nIn contrast, the second form of name capture is usually not intended, and is therefore more dangerous. Consider the following example:\n\n```> def F x = x+y when y = x+1 end;\n> F y;\ny+(y+1)\n```\n\nPure again gives the correct result here. You’d have to be worried if you got (y+1)+(y+1) instead, which would result from the literal expansion y+y when y = y+1 end, where the (free) variable y passed to F gets captured by the local binding of y. In fact, that’s exactly what you get with C macros:\n\n```#define F(x) { int y = x+1; return x+y; }\n```\n\nHere F(y) expands to { int y = y+1; return y+y; } which is usually not what you want.\n\nThis completes our little introduction to Pure’s macro facilities. The above material should in fact cover all the common uses of macros in Pure. However, if you want to become a real Pure macro wizard then read on. In the following subsections we’re going to discover some more advanced features of Pure’s macro system which let you write macros for manipulating special forms and give you access to Pure’s reflection capabilities.\n\n### Built-in Macros and Special Expressions¶\n\nAs already mentioned in The Quote, special expressions such as conditionals and lambdas cannot be directly represented as runtime data in Pure. But they can be quoted in which case they are replaced by corresponding “placeholder terms”. These placeholder terms are in fact implemented as built-in macros which, when evaluated, construct the corresponding specials.\n\nmacro __ifelse__ x y z\n\nThis macro expands to the conditional expression if x then y else z during macro evaluation.\n\nmacro __lambda__ [x1,...,xn] y\n\nExpands to the lambda expression \\x1 ... xn -> y.\n\nmacro __case__ x [(x1 --> y1),...,(xn --> yn)]\n\nExpands to the case expression case x of x1 = y1; ...; xn = yn end. Note that the --> symbol is used to separate the left-hand side and the right-hand side of each rule (see below).\n\nmacro x __when__ [(x1 --> y1),...,(xn --> yn)]\n\nExpands to the when expression x when x1 = y1; ...; xn = yn end. Here the left-hand side of a rule may be omitted if it is just the anonymous variable; i.e., x __when__ [foo y] is the same as x __when__ [_ --> foo y].\n\nmacro x __with__ [(x1 --> y1),...,(xn --> yn)]\n\nExpands to the with expression x with x1 = y1; ...; xn = yn end.\n\nNote that the following low-priority infix operators are used to denote equations in the __case__, __when__ and __with__ macros:\n\nconstructor x --> y\n\nDenotes an equation x = y.\n\nconstructor x __if__ y\n\nAttaches a guard to the right-hand side of an equation. That is, x --> y __if__ z denotes the conditional equation x = y if z. This symbol is only recognized in __case__ and __with__ calls.\n\nIn addition, patterns on the left-hand side of equations or in lambda arguments may be decorated with the following constructor terms to indicate “as” patterns and type tags (these are infix operators with a very high priority):\n\nconstructor x __as__ y\n\nDenotes an “as” pattern x @ y.\n\nconstructor x __type__ y\n\nDenotes a type tag x :: y.\n\nNote that all these symbols are in fact just constructors which are only interpreted in the context of the built-in macros listed above; they aren’t macros themselves.\n\nIt’s good to remember the above when you’re doing macro programming. However, to see the placeholder term of a special, you can also just type a quoted expression in the interpreter:\n\n```> '(\\x->x+1);\n__lambda__ [x] (x+1)\n> '(f with f x = y when y = x+1 end end);\nf __with__ [f x-->y __when__ [y-->x+1]]\n```\n\nList and matrix comprehensions can also be quoted. These are basically syntactic sugar for lambda applications, cf. Primary Expressions. The compiler expands them to their “unsugared” form already before macro substitution, so no special kinds of built-in macros are needed to represent them. When quoted, comprehensions are thus denoted in their unsugared form, which consists of a pile of lambda expressions and list or matrix construction functions for the generation clauses, and possibly some conditionals for the filter clauses of the comprehension. For instance:\n\n```> '[2*x | x = 1..3];\nlistmap (__lambda__ [x] (2*x)) (1..3)\n```\n\nHere’s how type tags and “as” patterns in quoted specials look like:\n\n```> '(\\x::int->x+1);\n__lambda__ [x __type__ int] (x+1)\n> '(dup (1..3) with dup xs@(x:_) = x:xs end);\ndup (1..3) __with__ [dup (xs __as__ (x:_))-->x:xs]\n```\n\nNote that the placeholder terms for the specials are quoted here, and hence they are not evaluated (quoting inhibits macro expansion, just like it prevents the evaluation of ordinary function calls). Evaluating the placeholder terms executes the corresponding specials:\n\n```> '(dup (1..3) with dup xs@(x:_) = x:xs end);\ndup (1..3) __with__ [dup (xs __as__ (x:_))-->x:xs]\n> eval ans;\n[1,1,2,3]\n```\n\nOf course, you can also just enter the macros directly (without quoting) to have them evaluated:\n\n```> dup (1..3) __with__ [dup (xs __as__ (x:_))-->x:xs];\n[1,1,2,3]\n> __lambda__ [x __type__ int] (x+1);\n#<closure 0x7f1934158dc8>\n> ans 99;\n100\n```\n\nThe __str__ function can be used to pretty-print quoted specials:\n\n```> __str__ ('__lambda__ [x __type__ int] (x+1));\n\"\\\\x::int -> x+1\"\n> __str__ ('(dup (1..3) __with__ [dup (xs __as__ (x:_))-->x:xs]));\n\"dup (1..3) with dup xs@(x:_) = x:xs end\"\n```\n\nThis is useful to see which expression a quoted special will expand to. Note that __str__ can also be used to define print representations for quoted specials with __show__ (described in Pretty-Printing) if you always want to have them printed that way by the interpreter.\n\nAs quoted specials are just ordinary Pure expressions, they can be manipulated by functions just like any other term. For instance, here’s how you can define a function which takes a quoted lambda and swaps its two arguments:\n\n```> swap (__lambda__ [x,y] z) = '(__lambda__ [y,x] z);\n> swap ('(\\a b->a-b));\n__lambda__ [b,a] (a-b)\n> eval ans 2 3; // same as (\\b a->a-b) 2 3\n1\n```\n\nFor convenience, a literal special expression can also be used on the left-hand side of an equation, in which case it actually denotes the corresponding placeholder term. So the swap function can also be defined like this (note that we first scratch the previous definition of swap with the clear command, see Interactive Commands):\n\n```> clear swap\n> swap (\\x y -> z) = '(\\y x -> z);\n> swap ('(\\a b->a-b));\n__lambda__ [b,a] (a-b)\n```\n\nThis is usually easier to write and improves readability. However, there are cases in which you want to work with the built-in macros in a direct fashion. In particular, this becomes necessary when writing more generic rules which deal, e.g., with lambdas involving a variable number of arguments, or if you need real (i.e., unquoted) type tags or “as” patterns in a placeholder pattern. We’ll see examples of these later.\n\nQuoted specials can be manipulated with macros just as well as with functions. In fact, this is quite common and thus the macro evaluator has some special support to make this more convenient. Specifically, it is possible to make a macro quote its arguments in an automatic fashion, by means of the --quoteargs pragma. To illustrate this, let’s redefine swap as a macro:\n\n```> clear swap\n> #! --quoteargs swap\n> def swap (\\x y -> z) = '(\\y x -> z);\n> swap (\\a b->a-b);\n__lambda__ [b,a] (a-b)\n```\n\nThe --quoteargs pragma makes the swap macro receive its argument unevaluated, as if it was quoted (but without a literal quote around it). Therefore the quote on the lambda argument of swap can now be omitted. However, the result is still a quoted lambda. It’s tempting to just omit the quote on the right-hand side of the macro definition as well, in order to get a real lambda instead:\n\n```> clear swap\n> def swap (\\x y -> z) = \\y x -> z;\n> swap (\\a b->a-b);\n#<closure 0x7f1934156f00>\n> ans 2 3;\na-b\n```\n\nWe got a closure all right, but apparently it’s not the right one. Let’s use trace -m to figure out what went wrong:\n\n```> trace -m swap\n> swap (\\a b->a-b);\n-- macro swap: swap (\\a b -> a-b) --> \\y x -> a-b\n#<closure 0x7f1934157248>\n```\n\nOk, so the result is the lambda \\y x -> a-b, not \\b a -> a-b as we expected. This happens because we used a literal (unquoted) lambda on the right-hand side, which does its own variable binding; consequently, the variables x and y are bound by the lambda in this context, not by the left-hand side of the macro rule.\n\nSo just putting an unquoted lambda on the right-hand side doesn’t do the job. One way to deal with the situation is to just employ the __lambda__ macro in a direct way, as we’ve seen before:\n\n```> clear swap\n> def swap (__lambda__ [x,y] z) = __lambda__ [y,x] z;\n> swap (\\a b->a-b);\n-- macro swap: swap (\\a b -> a-b) --> __lambda__ [b,a] (a-b)\n-- macro __lambda__: __lambda__ [b,a] (a-b) --> \\b a -> a-b\n#<closure 0x7f1934156f00>\n> ans 2 3;\n1\n```\n\nThis works, but doesn’t look very nice. Often it’s more convenient to first construct a quoted term involving the necessary specials and then have it evaluated during macro evaluation. Pure provides yet another built-in macro for this purpose:\n\nmacro __eval__ x\n\nEvaluate x at macro expansion time. This works by stripping one level of (outermost) quotes from x and performing macro expansion on the resulting unquoted subexpressions.\n\nUsing __eval__, we can implement the swap macro as follows:\n\n```> clear swap\n> def swap (\\x y -> z) = __eval__ ('(\\y x -> z));\n> swap (\\a b->a-b);\n-- macro swap: swap (\\a b -> a-b) --> __eval__ ('__lambda__ [b,a] (a-b))\n-- macro __lambda__: __lambda__ [b,a] (a-b) --> \\b a -> a-b\n-- macro __eval__: __eval__ ('__lambda__ [b,a] (a-b)) --> \\b a -> a-b\n#<closure 0x7f7e1f867dc8>\n> ans 2 3;\n1\n```\n\nLisp programmers should note the difference. In Lisp, macros usually yield a quoted expression which is evaluated implicitly during macro expansion. This is never done automatically in Pure, since many Pure macros work perfectly well without it. Instead, quotes in a macro expansion are treated as literals, and you’ll have to explicitly call __eval__ to remove them during macro evaluation.\n\nA final caveat: Placeholder terms for specials are just simple expressions; they don’t do any variable binding by themselves. Thus the rules of macro hygiene don’t apply to them, which makes it possible to manipulate lambdas and local definitions in any desired way. On the other hand, this means that it is the programmer’s responsibility to avoid accidental name capture when using these facilities. Most macro code will work all right when written in a straightforward way, but there are some corner cases which need special attention (cf. Name Capture).\n\nSometimes the only convenient way to avoid name capture is to create new symbols on the fly. This will often be necessary if a macro generates an entire block construct (case, when, with or lambda) from scratch. The following built-in macro is provided for this purpose:\n\nmacro __gensym__\n\nCreate a new unqualified symbol which is guaranteed to not exist at the time of the macro call. These symbols typically look like __x123__ and can be used for any purpose (i.e., as global or local as well as function or variable symbols).\n\nFor instance, here’s how we can implement a macro foo which creates a lambda from a given argument, using __gensym__ to generate a fresh local variable for the lambda argument. This guarantees that variables in the argument expression don’t get captured by the lambda variable when the closure is created with a call to the built-in __lambda__ macro.\n\n```> def foo x = bar __gensym__ x;\n> def bar x y = __lambda__ [x] (x+y);\n> trace -m foo\n> foo (a*b);\n-- macro foo: foo (a*b) --> bar __gensym__ (a*b)\n-- macro __gensym__: __gensym__ --> __x1__\n-- macro bar: bar __x1__ (a*b) --> __lambda__ [__x1__] (__x1__+a*b)\n-- macro __lambda__: __lambda__ [__x1__] (__x1__+a*b) --> \\__x1__ -> __x1__+a*b\n#<closure 0x7f66f6c88db0>\n> ans 77;\n77+a*b\n```\n\nThe __gensym__ macro returns a new variable for each invocation, and always ensures that it doesn’t accidentally reuse a symbol already introduced by the user (even if it looks like a symbol that __gensym__ might itself create):\n\n```> foo (a*__x2__);\n-- macro foo: foo (a*__x2__) --> bar __gensym__ (a*__x2__)\n-- macro __gensym__: __gensym__ --> __x3__\n-- macro bar: bar __x3__ (a*__x2__) --> __lambda__ [__x3__] (__x3__+a*__x2__)\n-- macro __lambda__: __lambda__ [__x3__] (__x3__+a*__x2__) --> \\__x3__ -> __x3__+a*__x2__\n#<closure 0x7f66f6c887e8>\n> ans 77;\n77+a*__x2__\n```\n\nWe are now in a position to have a look at some of the trickier optimization macros defined in the prelude. The following __do__ macro can be found near the end of the prelude.pure module; it is used to optimize the case of “throwaway” list and matrix comprehensions. This is useful if a comprehension is evaluated solely for its side effects. To keep things simple, we discuss a slightly abridged version of the __do__ macro which only deals with list comprehensions and ignores some obscure corner cases. You can find this version in the examples/do.pure script. Please also check the prelude for the full version of this macro.\n\nNote that we define our own versions of void and __do__ here which are placed into the my namespace to avoid conflicts with the prelude.\n\n```namespace my;\n\nvoid _ = ();\n\n#! --quoteargs my::__do__\n\ndef void [x] = void x;\ndef void (catmap f x) | void (listmap f x) = __do__ f x;\n\n// Recurse into embedded generator clauses.\ndef __do__ (__lambda__ [x] y@(listmap _ _)) |\n__do__ (__lambda__ [x] y@(catmap _ _)) =\n__do__ \\$ (__lambda__ [x] (void y));\n\n// Recurse into embedded filter clauses.\ndef __do__ (__lambda__ [x] (__ifelse__ y z [])) =\n__do__ \\$ (__lambda__ [x] (__ifelse__ y (void z) ()));\n\n// Eliminate extra calls to 'void' in generator clauses.\ndef __do__ (__lambda__ [x] (void y)) = __do__ (__lambda__ [x] y);\n\n// Eliminate extra calls to 'void' in filter clauses.\ndef __do__ (__lambda__ [x] (__ifelse__ y (void z) ())) =\n__do__ (__lambda__ [x] (__ifelse__ y z ()));\n\n// Any remaining instances reduce to a plain 'do' (this must come last).\ndef __do__ f = do f;\n```\n\nFirst, note that the void function simply throws away its argument and returns () instead. The do function applies a function to every member of a list (like map), but throws away all intermediate results and just returns (), which is much more efficient if you don’t need those results anyway. These are both defined in the prelude, but we define our own version of void here so that we can hook it up to our simplified version of the __do__ macro.\n\nThe __do__ macro eventually reduces to just a plain do call, but applies some optimizations along the way. While the above rules for __do__ are always valid optimizations for do, it’s a good idea to use a separate macro here instead of clobbering do itself, so that these optimizations do not interfere with calls to do in ordinary user code. The prelude handles this in an analogous fashion.\n\nBefore we further delve into this example, a few remarks are in order about the way list comprehensions are implemented in Pure. As already mentioned, list comprehensions are just syntactic sugar; the compiler immediately transforms them to an equivalent expression involving only lambdas and a few other list operations. The latter are essentially equivalent to piles of nested filters and maps, but for various reasons they are actually implemented using two special helper operations, catmap and listmap.\n\nThe catmap operation combines map and cat; this is needed, in particular, to accumulate the results of nested generators, such as [i,j | i = 1..n; j = 1..m]. The same operation is also used to implement filter clauses, you can see this below in the examples. However, for efficiency simple generators like [2*i | i = 1..n] are translated to a listmap instead (which is basically just map, but works with different aggregate types, so that list comprehensions can draw values from aggregates other than lists, such as matrices).\n\nNow let’s see how the rules above transform a list comprehension if we “void” it. (Remember to switch to the my namespace when trying the following examples.)\n\n```> using system;\n> using namespace my;\n> f = [printf \"%g\\n\" (2^x+1) | x=1..5; x mod 2];\n> g = void [printf \"%g\\n\" (2^x+1) | x=1..5; x mod 2];\n> show f g\nf = catmap (\\x -> if x mod 2 then [printf \"%g\\n\" (2^x+1)] else []) (1..5);\ng = do (\\x -> if x mod 2 then printf \"%g\\n\" (2^x+1) else ()) (1..5);\n```\n\nAs you can see, the catmap got replaced with a do, and the list brackets inside the lambda were eliminated as well. These optimizations are just what’s needed to make this code go essentially as fast as a for loop in traditional programming languages (up to constant factors, of course). Here’s how it looks like when we run the g function:\n\n```> g;\n3\n9\n33\n()\n```\n\nIt’s also instructive to have a look at how the above macro rules work in concert to rewrite a “voided” comprehension. To these ends, you can rerun the right-hand side of g with some tracing enabled, as follows (we omit the tracing output here for brevity):\n\n```> trace -m my::void\n> void [printf \"%g\\n\" (2^x+1) | x=1..5; x mod 2];\n```\n\nThe above optimization rules also take care of nested list comprehensions, since they recurse into the lambda bodies of generator and filter clauses. For instance:\n\n```> h = void [puts \\$ str (x,y) | x=1..2; y=1..3];\n> show h\nh = do (\\x -> do (\\y -> puts (str (x,y))) (1..3)) (1..2);\n```\n\nAgain, you should run this with macro tracing enabled to see how the __do__ macro recurses into the outer lambda body of the list comprehension. Here’s the rule which actually does this:\n\n```def __do__ (__lambda__ [x] y@(catmap _ _)) =\n__do__ \\$ (__lambda__ [x] (void y));\n```\n\nNote that in order to make this work, __do__ is implemented as a “quoteargs” macro so that it can inspect and recurse into the lambda terms in its argument. Also note the \\$ on the right-hand side of this rule; this is also implemented as a macro in the prelude. Here the \\$ operator is used to forcibly evaluate the macro argument __lambda__ [x] (void y), so that the embedded call to the void macro gets expanded. (Without the \\$ the argument to __do__ would be quoted and thus not be evaluated.) A similar rule is used to recurse into embedded filter clauses, as in the example of the function g above.\n\nIt should be mentioned that, while our version of the __do__ macro will properly handle most list comprehensions, there is a rather obscure corner case which it still refuses to optimize: outermost filter clauses. For instance, consider:\n\n```> let c = 2;\n> k = void [printf \"%g\\n\" (2^x+1) | c>0; x=1..3];\n> show k\nk = my::void (if c>0 then listmap (\\x -> printf \"%g\\n\" (2^x+1)) (1..3) else []);\n```\n\nIt’s possible to handle this case as well, but we have to go to some lengths to achieve that. The complication here is that we don’t want to mess with calls to void in ordinary user code, so void itself cannot be a “quoteargs” macro. But the quoted form of void‘s argument is needed to detect the “outermost filter clause” situation. The interested reader may refer to the prelude code to see how the prelude implementation of __do__ uses some helper macros to make this work. Another detail of the full version of __do__ is the handling of patterns on the left-hand side of generator clauses, which requires some special magic to filter out unmatched list elements; we also omitted this here for brevity.\n\n### Reflection¶\n\nThe meta representation of specials discussed in Built-in Macros and Special Expressions is also useful to obtain information about the running program and even modify it. Pure’s runtime provides some built-in operations to implement these reflection capabilities, which are comparable in scope to what the Lisp programming language offers.\n\nSpecifically, the get_fundef function allows you to retrieve the definition of a global Pure function. Given the symbol denoting the function, get_fundef returns the list of rewriting rules implementing the functions, using the same lhs --> rhs format used by the __case__, __when__ and __with__ macros discussed above. For instance:\n\n```> fact n = 1 if n<=1;\n> = n*fact (n-1) otherwise;\n> get_fundef fact;\n[(fact n-->1 __if__ n<=1),(fact n-->n*fact (n-1))]\n```\n\nDefining a new function or extending an existing function definition can be done just as easily, using the add_fundef function:\n\n```> add_fundef \\$ '[(fib n-->1 __if__ n<=1),(fib n-->fib (n-2)+fib (n-1))];\n()\n> show fib\nfib n = 1 if n<=1;\nfib n = fib (n-2)+fib (n-1);\n> map fib (0..10);\n[1,1,2,3,5,8,13,21,34,55,89]\n```\n\nNote that, to be on the safe side, we quoted the rule list passed to add_fundef to prevent premature evaluation of symbols used in the rules. This is necessary because add_fundef is an ordinary function, not a macro. (Of course, you could easily define a macro which would take care of this, if you like. We leave this as an exercise to the reader.)\n\nAlso note that add_fundef doesn’t override existing function definitions. It simply keeps on adding rules to the current program, just as if you typed the equations at the command prompt of the interpreter. It is possible to delete individual equations with del_fundef:\n\n```> del_fundef \\$ '(fib n-->fib (n-2)+fib (n-1));\n()\n> show fib\nfib n = 1 if n<=1;\n```\n\nMoreover, the clearsym function allows you to completely get rid of an existing function:\n\n```> clearsym fib 0;\n()\n> show fib\n> fib 9;\nfib 9\n```\n\nThere’s also a companion function, globsym, which enables you to get a list of defined symbols which match a given glob pattern:\n\n```> globsym \"fact\" 0;\n[fact]\n> globsym \"*\" 0;\n[(!),(!!),(#),(\\$),(\\$\\$),...]\n> #globsym \"*\" 0;\n304\n```\n\nNote that globsym also returns symbols defined as types, macros, variables or constants. But we can easily check for a given type of symbol by using the appropriate function to retrieve the rules defining the symbol, and filter out symbols with an empty rule list:\n\n```> #[sym | sym = globsym \"*\" 0; ~null (get_fundef sym)];\n253\n```\n\nPure also provides the operations get_typedef, get_macdef, get_vardef and get_constdef, which are completely analogous to get_fundef, but return the definitions of types, macros, (global) variables and constants. Note that in the latter two cases the rule list takes the form [var-->val] if the symbol is defined, [] if it isn’t.\n\nFor instance, let’s check the definition of the \\$ macro (cf. Optimization Rules) and the list type (cf. Recursive Types):\n\n```> get_macdef (\\$);\n[f\\$x-->f x]\n> get_typedef list;\n[(list []-->1),(list (_:_)-->1)]\n```\n\nOr let’s lists all global variables along with their values:\n\n```> catmap get_vardef (globsym \"*\" 0);\n[(argc-->0),(argv-->[]),(compiling-->0),\n(sysinfo-->\"x86_64-unknown-linux-gnu\"),(version-->\"0.66\")]\n```\n\nThe counterparts of add_fundef and del_fundef are provided as well. Not very surprisingly, they are named add_typedef, del_typedef, etc. For instance:\n\n```> add_vardef ['x-->3*33];\n()\n> show x\nlet x = 99;\n> del_vardef ('x);\n()\n> show x\n```\n\nThe above facilities should cover most metaprogramming needs. For even more exotic requirements, you can also use the eval and evalcmd primitives to execute arbitrary Pure code in text form; please see the Pure Library Manual for details.\n\nFinally, a word of caution: The use of add_fundef, del_fundef and similar operations to modify a running program breaks referential transparency and hence these functions should be used with care. Moreover, at present the JIT compiler doesn’t support truly self-modifying code (i.e., functions modifying themselves while they’re executing); this results in undefined behaviour. Also, note that none of the inspection and mutation capabilities provided by these operations will work in batch-compiled programs, please check the Batch Compilation section for details.\n\n## Exception Handling¶\n\nPure also offers a useful exception handling facility. To raise an exception, you just invoke the built-in function throw with the value to be thrown as the argument. Exceptions are caught with the built-in special form catch which is invoked as follows:\n\ncatch handler x\n\nCatch an exception. The first argument denotes the exception handler (a function to be applied to the exception value). The second (call-by-name) argument is the expression to be evaluated.\n\nFor instance:\n\n```> catch error (throw hello_world);\nerror hello_world\n```\n\nExceptions are also generated by the runtime system if the program runs out of stack space, when a guard does not evaluate to a truth value, and when the subject term fails to match the pattern in a pattern-matching lambda abstraction, or a let, case or when construct. These types of exceptions are reported using the symbols stack_fault, failed_cond and failed_match, respectively, which are declared as nonfix symbols in the standard prelude. You can use catch to handle these kinds of exceptions just like any other. For instance:\n\n```> fact n = if n>0 then n*fact(n-1) else 1;\n> catch error (fact foo);\nerror failed_cond\n> catch error (fact 1000000);\nerror stack_fault\n```\n\nUnhandled exceptions are reported by the interpreter with a corresponding error message:\n\n```> fact foo;\n<stdin>, line 2: unhandled exception 'failed_cond' while evaluating 'fact foo'\n```\n\nNote that since the right-hand side of a type definition (cf. Type Rules) is just ordinary Pure code, it may be susceptible to exceptions, too. Such exceptions are reported or caught just like any other. In particular, if you want to make a type definition just fail silently in case of an exception, you’ll have to wrap it up in a suitable catch clause:\n\n```> foo x = throw foo; // dummy predicate which always throws an exception\n> type bar x = foo x;\n> type baz x = catch (cst false) (foo x);\n> test_bar x::bar = x;\n> test_baz x::baz = x;\n> test_bar ();\n<stdin>, line 6: unhandled exception 'foo' while evaluating 'test_bar ()'\n> test_baz ();\ntest_baz ()\n```\n\nExceptions also provide a way to handle asynchronous signals. Pure’s system module provides symbolic constants for common POSIX signals and also defines the operation trap which lets you rebind any signal to a signal exception. For instance, the following lets you handle the SIGQUIT signal:\n\n```> using system;\n> trap SIG_TRAP SIGQUIT;\n```\n\nYou can also use trap to just ignore a signal or revert to the system’s default handler (which might take different actions depending on the type of signal, see signal(7) for details):\n\n```> trap SIG_IGN SIGQUIT; // signal is ignored\n> trap SIG_DFL SIGQUIT; // reinstalls the default signal handler\n```\n\nNote that when the interpreter runs interactively, for convenience most standard termination signals (SIGINT, SIGTERM, etc.) are already set up to produce corresponding Pure exceptions of the form signal SIG where SIG is the signal number. If a script is to be run non-interactively then you’ll have to do this yourself (otherwise most signals will terminate the program).\n\nWhile exceptions are normally used to report abnormal error conditions, they also provide a way to implement non-local value returns. For instance, here’s a variation of our n queens algorithm (cf. List Comprehensions) which only returns the first solution. Note the use of throw in the recursive search routine to bail out with a solution as soon as we found one. The value thrown there is caught in the main routine. Also note the use of void in the second equation of search. This effectively turns the list comprehension into a simple loop which suppresses the normal list result and just returns () instead. Thus, if no value gets thrown then the function regularly returns with () to indicate that there is no solution.\n\n```queens n = catch reverse (search n 1 []) with\nsearch n i p = throw p if i>n;\n= void [search n (i+1) ((i,j):p) | j = 1..n; safe (i,j) p];\nsafe (i,j) p = ~any (check (i,j)) p;\ncheck (i1,j1) (i2,j2)\n= i1==i2 || j1==j2 || i1+j1==i2+j2 || i1-j1==i2-j2;\nend;\n```\n\nE.g., let’s compute a solution for a standard 8x8 board:\n\n```> queens 8;\n[(1,1),(2,5),(3,8),(4,6),(5,3),(6,7),(7,2),(8,4)]\n```\n\n## Standard Library¶\n\nPure comes with a collection of Pure library modules, which includes the standard prelude (loaded automatically at startup time) and some other modules which can be loaded explicitly with a using clause. The prelude offers the necessary functions to work with the built-in types (including arithmetic and logical operations) and to do most kind of list processing you can find in ML- and Haskell-like languages. It also provides a collection of basic string and matrix operations. Please refer to the Pure Library Manual for details on the provided operations. Here is a very brief summary of some of the prelude operations which, besides the usual arithmetic and logical operators, are probably used most frequently:\n\nx+y\n\nThe arithmetic + operation is also used to denote list and string concatenation in Pure.\n\nx:y\n\nThis is the list-consing operation. x becomes the head of the list, y its tail. As ‘:‘ is a constructor symbol, you can use it in patterns on the left hand side of rewriting rules.\n\nx..y\n\nConstructs arithmetic sequences. x:y..z can be used to denote sequences with arbitrary stepsize y-x. Infinite sequences can be constructed using an infinite bound (i.e., inf or -inf). E.g., 1:3..inf denotes the stream of all odd integers starting at 1.\n\nx,y\n\nThis is the pair constructor, used to create tuples of arbitrary sizes. Tuples provide an alternative way to represent aggregate values in Pure. In contrast to lists, tuples are always “flat”, so that (x,y),z and x,(y,z) denote the same triple x,y,z. (This is explained in more detail in the Primary Expressions section.)\n\n#x\n\nThe size (number of elements) of the list, tuple, matrix or string x. In addition, dim x yields the dimensions (number of rows and columns) of a matrix.\n\nx!y\n\nThis is Pure’s indexing operation, which applies to lists, tuples, matrices and strings. Note that all indices in Pure are zero-based, thus x!0 and x!(#x-1) are the first and last element of x. In the case of matrices, the subscript may also be a pair of row and column indices, such as x!(1,2).\n\nx!!ys\n\nThis is the “slicing” operation, which returns the list, tuple, matrix or string of all x!y while y runs through the elements of the list or matrix ys. Thus, e.g., x!!(i..j) returns all the elements between i and j (inclusive). Indices which fall outside the valid index range are quietly discarded. The index range ys may contain any number of indices (also duplicates), in any order. Thus x!![0|i=1..n] returns the first element of x n times, and, if ys is a permutation of the range 0..#x-1, then x!!ys yields the corresponding permutation of the elements of x. In the case of matrices the index range may also contain two-dimensional subscripts, or the index range itself may be specified as a pair of row/column index lists such as x!!(i..j,k..l).\n\nThe prelude also offers support operations for the implementation of list and matrix comprehensions, as well as the customary list operations like head, tail, drop, take, filter, map, foldl, foldr, scanl, scanr, zip, unzip, etc., which make list programming so much fun in modern FPLs. In Pure, these also work on strings as well as matrices, although, for reasons of efficiency, these data structures are internally represented as arrays.\n\nBesides the prelude, Pure’s standard library also comprises a growing number of additional library modules which we can only mention in passing here. In particular, the math module provides additional mathematical functions as well as Pure’s complex and rational number data types. Common container data structures like sets and dictionaries are implemented in the set and dict modules, among others. Moreover, the system interface can be found in the system module. In particular, this module also provides operations to do basic C-style I/O, including printf and scanf.\n\n## C Interface¶\n\nPure makes it very easy to call C functions (as well as functions in a number of other languages supported by the GNU compiler collection). To call an existing C function, you just need an extern declaration of the function, as described below. By these means, all functions in the standard C library and the Pure runtime are readily available to Pure scripts. Functions can also be loaded from dynamic libraries and LLVM bitcode files at runtime. In the latter case, you don’t even need to write any extern declarations, the interpreter will do that for you. As of Pure 0.45, you can also add inline C/C++ and Fortran code to your Pure scripts and have the Pure interpreter compile them on the fly, provided that you have the corresponding compilers from the LLVM project installed.\n\nIn some cases you will still have to rely on big and complicated third-party and system libraries which aren’t readily available in bitcode form. It goes without saying that writing all the extern declarations for such libraries can be a daunting task. Fortunately, there is a utility to help with this, by extracting the extern declarations automatically from C headers. Please see External C Functions in the Caveats and Notes section for details.\n\n### Extern Declarations¶\n\nTo access an existing C function in Pure, you need an extern declaration of the function, which is a simplified kind of C prototype. The syntax of these declarations is described by the following grammar rules:\n\n```extern_decl ::= [scope] \"extern\" prototype (\",\" prototype) \";\"\nprototype ::= c_type identifier \"(\" [parameters | \"...\"] \")\" [\"=\" identifier]\nparameters ::= parameter (\",\" parameter)* [\",\" \"...\"]\nparameter ::= c_type [identifier]\nc_type ::= identifier \"*\"*\n```\n\nExtern functions can be called in Pure just like any other. For instance, the following commands, entered interactively in the interpreter, let you use the sin function from the C library (of course you could just as well put the extern declaration into a script):\n\n```> extern double sin(double);\n> sin 0.3;\n0.29552020666134\n```\n\nAn extern declaration can also be prefixed with a public/private scope specifier:\n\n```private extern double sin(double);\n```\n\nMultiple prototypes can be given in one extern declaration, separating them with commas:\n\n```extern double sin(double), double cos(double), double tan(double);\n```\n\nFor clarity, the parameter types can also be annotated with parameter names (these only serve informational purposes and are for the human reader; they are effectively treated as comments by the compiler):\n\n```extern double sin(double x);\n```\n\nPointer types are indicated by following the name of the element type with one or more asterisks, as in C. For instance:\n\n```> extern char* strchr(char *s, int c);\n> strchr \"foo bar\" (ord \"b\");\n\"bar\"\n```\n\nAs you can see in the previous example, some pointer types get special treatment, allowing you to pass certain kinds of Pure data (such as Pure strings as char* in this example). This is discussed in more detail in C Types below.\n\nThe interpreter makes sure that the parameters in a call match; if not, then by default the call is treated as a normal form expression:\n\n```> extern double sin(double);\n> sin 0.3;\n0.29552020666134\n> sin 0;\nsin 0\n```\n\nThis gives you the opportunity to augment the external function with your own Pure equations. To make this work, you have to make sure that the extern declaration of the function comes first. For instance, we might want to extend the sin function with a rule to handle integers:\n\n```> sin x::int = sin (double x);\n> sin 0;\n0.0\n```\n\nSometimes it is preferable to replace a C function with a wrapper function written in Pure. In such a case you can specify an alias under which the original C function is known to the Pure program, so that you can still call the C function from the wrapper. An alias is introduced by terminating the extern declaration with a clause of the form = alias. For instance:\n\n```> extern double sin(double) = c_sin;\n> sin x::double = c_sin x;\n> sin x::int = c_sin (double x);\n> sin 0.3; sin 0;\n0.29552020666134\n0.0\n```\n\nAliases are just one way to declare a synonym of an external function. As an alternative, you can also declare the C function in a special namespace (cf. Namespaces in the Declarations section):\n\n```> namespace c;\n> extern double sin(double);\n> c::sin 0.3;\n0.29552020666134\n```\n\nNote that the namespace qualification only affects the Pure side; the underlying C function is still called under the unqualified name as usual. The way in which such qualified externs are accessed is the same as for ordinary qualified symbols. In particular, the using namespace declaration applies as usual, and you can declare such symbols as private if needed. It is also possible to combine a namespace qualifier with an alias:\n\n```> namespace c;\n> extern double sin(double) = mysin;\n> c::mysin 0.3;\n0.29552020666134\n```\n\nIn either case, different synonyms of the same external function can be declared in slightly different ways, which makes it possible to adjust the interpretation of pointer values on the Pure side. This is particularly useful for string arguments which, as described below, may be passed both as char* (which implies copying and conversion to or from the system encoding) and as void* (which simply passes through the character pointers). For instance:\n\n```> extern char *strchr(char *s, int c) = foo;\n> extern void *strchr(void *s, int c) = bar;\n> foo \"foo bar\" 98; bar \"foo bar\" 98;\n\"bar\"\n#<pointer 0x12c2f24>\n```\n\nAlso note that, as far as Pure is concerned, different synonyms of an external function are really different functions. In particular, they can each have their own set of augmenting Pure equations. For instance:\n\n```> extern double sin(double);\n> extern double sin(double) = mysin;\n> sin === sin;\n1\n> sin === mysin;\n0\n> sin 1.0; mysin 1.0;\n0.841470984807897\n0.841470984807897\n> sin x::int = sin (double x);\n> sin 1; mysin 1;\n0.841470984807897\nmysin 1\n```\n\nVariadic C functions are declared as usual by terminating the parameter list with an ellipsis (...):\n\n```> extern int printf(char*, ...);\n> printf \"Hello, world\\n\";\nHello, world\n13\n```\n\nNote that the variadic prototype is mandatory here, since the compiler needs to know about the optional arguments so that it can generate the proper code to call the function. However, in Pure a function always has a fixed arity, so, as far as Pure is concerned, the function is still treated as if it had no extra arguments. Thus the above declaration only allows you to call printf with a single argument.\n\nTo make it possible to pass optional arguments to a variadic function, you must explicitly give the (non-variadic) prototypes with which the function is to be called. To these ends, the additional prototypes are declared as synonyms of the original variadic function. This works because the compiler only checks the non-variadic parameters for conformance. For instance:\n\n```> extern int printf(char*, char*) = printf_s;\n> printf_s \"Hello, %s\\n\" \"world\";\nHello, world\n13\n> extern int printf(char*, int) = printf_d;\n> printf_d \"Hello, %d\\n\" 99;\nHello, 99\n10\n```\n\n### C Types¶\n\nAs indicated in the previous section, the data types in extern declarations are either C type names or pointer types derived from these. The special expr* pointer type is simply passed through; this provides a means to deal with Pure data in C functions in a direct fashion. For all other C types, Pure values are “marshalled” (converted) from Pure to C when passed as arguments to C functions, and the result returned by the C function is then converted back from C to Pure. All of this is handled by the runtime system in a transparent way, of course.\n\nNote that, to keep things simple, Pure does not provide any notations for C structs or function types, although it is possible to represent pointers to such objects using void* or some other appropriate pointer types. In practice, this simplified system should cover most kinds of calls that need to be done when interfacing to C libraries, but there are ways to work around these limitations if you need to access C structs or call back from C to Pure, see External C Functions in the Caveats and Notes section for details.\n\n#### Basic C Types¶\n\nPure supports the usual range of basic C types: void, bool, char, short, int, long, float, double, and converts between these and the corresponding Pure data types (machine ints, bigints and double values) in a straightforward way.\n\nThe void type is only allowed in function results. It is converted to the empty tuple ().\n\nBoth float and double are supported as floating point types. Single precision float arguments and return values are converted from/to Pure’s double precision floating point numbers.\n\nA variety of C integer types (bool, char, short, int, long) are provided which are converted from/to the available Pure integer types in a straightforward way. In addition, the synonyms int8, int16 and int32 are provided for char, short and int, respectively, and int64 denotes 64 bit integers (a.k.a. ISO C99 long long). Note that long is equivalent to int32 on 32 bit systems, whereas it is the same as int64 on most 64 bit systems. To make it easier to interface to various system routines, there’s also a special size_t integer type which usually is 4 bytes on 32 bit and 8 bytes on 64 bit systems.\n\nAll integer parameters take both Pure ints and bigints as actual arguments; truncation or sign extension is performed as needed, so that the C interface behaves as if the argument was “cast” to the C target type. Returned integers use the smallest Pure type capable of holding the result, i.e., int for the C char, short and int types, bigint for int64.\n\nPure considers all integers as signed quantities, but it is possible to pass unsigned integers as well (if necessary, you can use a bigint to pass positive values which are too big to fit into a machine int). Also note that when an unsigned integer is returned by a C routine, which is too big to fit into the corresponding signed integer type, it will “wrap around” and become negative. In this case, depending on the target type, you can use the ubyte, ushort, uint, ulong and uint64 functions provided by the prelude to convert the result back to an unsigned quantity.\n\n#### Pointer Types¶\n\nThe use of pointer types is also fairly straightforward, but Pure has some special rules for the conversion of certain pointer types which make it easy to pass aggregate Pure data to and from C routines, while also following the most common idioms for pointer usage in C. The following types of pointers are recognized both as arguments and return values of C functions.\n\nBidirectional pointer conversions:\n\n• char* is used for string arguments and return values which are converted from Pure’s internal utf-8 based string representation to the system encoding and vice versa. (Thus a C routine can never modify the raw Pure string data in-place; if this is required then you’ll have to pass the string argument as a void*, see below.)\n• void* is for any generic pointer value, which is simply passed through unchanged. When used as an argument, you can also pass Pure strings, matrices and bigints. In this case the raw underlying data pointer (char* in the case of strings, int*, double* or expr* in the case of numeric and symbolic matrices, and the GMP type mpz_t in the case of bigints) is passed, which allows the data to be modified in place (with care). In particular, passing bigints as void* makes it possible to call most GMP integer routines directly from Pure.\n• dmatrix*, cmatrix* and imatrix* allow you to pass numeric Pure matrices of the appropriate types (double, complex, int). Here a pointer to the underlying GSL matrix structure is passed (not just the data itself). This makes it possible to transfer GSL matrices between Pure and GSL routines in a direct fashion without any overhead. (For convenience, there are also some other pointer conversions for marshalling matrix arguments to numeric C vectors, which are described in Pointers and Matrices below.)\n• expr* is for any kind of Pure value. A pointer to the expression node is passed to or from the C function. This type is to be used for C routines which are prepared to deal with pristine Pure data, using the corresponding functions provided by the runtime. You can find many examples of this in the standard library.\n\nAll other pointer types are simply taken at face value, allowing you to pass Pure pointer values as is, without any conversions. This also includes pointers to arbitrary named types which don’t have a predefined meaning in Pure, such as FILE*. As of Pure 0.45, the interpreter keeps track of the actual names of all pointer types and checks (at runtime) that the types match in an external call, so that you can’t accidentally get a core dump by passing, say, a FILE* for a char*. (The call will then simply fail and yield a normal form, which gives you the opportunity to hook into the function with your own Pure definitions which may supply any desired data conversions.) Typing information about pointer values is also available to Pure scripts by means of corresponding library functions, please see the Tagged Pointers section in the Pure Library Manual for details.\n\n#### Pointers and Matrices¶\n\nThe following additional pointer conversions are provided to deal with Pure matrix values in arguments of C functions, i.e., on the input side. These enable you to pass Pure matrices for certain kinds of C vectors. Note that in any case, you can also simply pass a suitable plain pointer value instead. Also, these types aren’t special in return values, where they will simply yield a pointer value (with the exception of char* which gets special treatment as explained in the previous subsection). Thus you will have to decode such results manually if needed. The standard library provides various routines to do this, please see the String Functions and Matrix Functions sections in the Pure Library Manual for details.\n\nNumeric pointer conversions (input only):\n\n• char*, short*, int*, int64*, float*, double* can be used to pass numeric matrices as C vectors. This kind of conversion passes just the matrix data (not the GSL matrix structure, as the dmatrix* et al conversions do) and does conversions between integer or floating point data of different sizes on the fly. You can either pass an int matrix as a char*, short* int* or int64* argument, or a double or complex matrix as a float* or double* argument (complex values are then represented as two separate double numbers, first the real, then the imaginary part, for each matrix element).\n• char**, short**, int**, int64**, float**, double** provide yet another way to pass numeric matrix arguments. This works analogously to the numeric vector conversions above, but here a temporary C vector of pointers is passed to the C function, whose elements point to the rows of the matrix.\n\nArgv-style conversions (input only):\n\n• char** and void** can be used to pass argv-style vectors as arguments to C functions. In this case, the Pure argument must be a symbolic vector of strings or generic pointer values. char** converts the string elements to the system encoding, whereas void** passes through character string data and other pointers unchanged (and allows in-place modification of the data). A temporary C vector of these elements is passed to the C function, which is always NULL-terminated and can thus be used for almost any purpose which requires such argv-style vectors.\n\nNote that in the numeric pointer conversions, the matrix data is passed “per reference” to C routines, i.e., the C function may modify the data “in place”. This is true even for target data types such as short* or float** which involve automatic conversions and hence need temporary storage. In this case the data from the temporary storage is written back to the original matrix when the function returns, to maintain the illusion of in-place modification. Temporary storage is also needed when the GSL matrix has the data in non-contiguous storage. You may want to avoid this if performance is critical, by always using “packed” matrices (see pack in Matrix Functions) of the appropriate types.\n\n#### Pointer Examples¶\n\nLet’s finally have a look at some instructive examples to explain some of the trickier pointer types.\n\nFirst, the matrix pointer types dmatrix*, cmatrix* and imatrix* can be used to pass double, complex double and int matrices to GSL functions taking pointers to the corresponding GSL types (gsl_matrix, gsl_matrix_complex and gsl_matrix_int) as arguments or returning them as results. (Note that there is no special marshalling of Pure’s symbolic matrix type, as these aren’t supported by GSL anyway.) Also note that matrices are always passed by reference. Thus, if you need to pass a matrix as an output parameter of a GSL matrix routine, you should either create a zero matrix or a copy of an existing matrix to hold the result. The prelude provides various operations for that purpose (in particular, see the dmatrix, cmatrix, imatrix and pack functions in matrices.pure). For instance, here is how you can quickly wrap up GSL’s double matrix addition function in a way that preserves value semantics:\n\n```> using \"lib:gsl\";\n> x::matrix + y::matrix = gsl_matrix_add x y \\$\\$ x when x = pack x end;\n> let x = dmatrix {1,2,3}; let y = dmatrix {2,3,2}; x; y; x+y;\n{1.0,2.0,3.0}\n{2.0,3.0,2.0}\n{3.0,5.0,5.0}\n```\n\nMost GSL matrix routines can be wrapped in this fashion quite easily. A ready-made GSL interface providing access to all of GSL’s numeric functions is in the works; please check the Pure website for details.\n\nFor convenience, it is also possible to pass any kind of numeric matrix for a char*, short*, int*, int64*, float* or double* parameter. This requires that the pointer and the matrix type match up; conversions between char, short, int64 and int data and, likewise, between float and double are handled automatically, however. For instance, here is how you can call the puts routine from the C library with an int matrix encoding the string \"Hello, world!\" as byte values (ASCII codes):\n\n```> extern int puts(char*);\n> puts {72,101,108,108,111,44,32,119,111,114,108,100,33,0};\nHello, world!\n14\n```\n\nPure 0.45 and later also support char**, short**, int**, int64**, float** and double** parameters which encode a matrix as a vector of row pointers instead. This kind of matrix representation is often found in audio and video processing software (where the rows of the matrix might denote different audio channels, display lines or video frames), but it’s also fairly convenient to do any kind of matrix processing in C. For instance, here’s how to do matrix multiplication (the naive algorithm):\n\n```void matmult(int n, int l, int m, double **x, double **y, double **z)\n{\nint i, j, k;\nfor (i = 0; i < n; i++)\nfor (j = 0; j < m; j++) {\nz[i][j] = 0.0;\nfor (k = 0; k < l; k++)\nz[i][j] += x[i][k]*y[k][j];\n}\n}\n```\n\nAs you can see, this multiplies a n times l matrix x with a l times m matrix y and puts the result into the n times m matrix z:\n\n```> extern void matmult(int, int, int, double**, double**, double**);\n> let x = {0.11,0.12,0.13;0.21,0.22,0.23};\n> let y = {1011.0,1012.0;1021.0,1022.0;1031.0,1032.0};\n> let z = dmatrix (2,2);\n> matmult 2 3 2 x y z \\$\\$ z;\n{367.76,368.12;674.06,674.72}\n```\n\nAlso new in Pure 0.45 is the support for passing argv-style vectors as arguments. For instance, here is how you can use fork and execvp to implement a poor man’s version of the C system function. (This is Unix-specific and doesn’t do much error-checking, but you get the idea.)\n\n```extern int fork();\nextern int execvp(char *path, char **argv);\nextern int waitpid(int pid, int *status, int options);\n\nsystem cmd::string = case fork of\n// child: execute the program, bail out if error\n0 = execvp \"/bin/sh\" {\"/bin/sh\",\"-c\",cmd} \\$\\$ exit 1;\n// parent: wait for the child and return its exit code\npid = waitpid pid status 0 \\$\\$ status!0 >> 8\nwhen status = {0} end if pid>=0;\nend;\n\nsystem \"echo Hello, world!\";\nsystem \"ls -l *.pure\";\nsystem \"exit 1\";\n```\n\n### Importing Dynamic Libraries¶\n\nBy default, external C functions are resolved by the LLVM runtime, which first looks for the symbol in the C library and Pure’s runtime library (or the interpreter executable, if the interpreter was linked statically). Thus all C library and Pure runtime functions are readily available in Pure programs. Other functions can be provided by adding them to the runtime, or by linking them into the runtime or the interpreter executable. Better yet, you can just “dlopen” shared libraries at runtime with a special form of the using clause:\n\n```using \"lib:libname[.ext]\";\n```\n\nFor instance, if you want to call the functions from library libxyz directly from Pure:\n\n```using \"lib:libxyz\";\n```\n\nAfter this declaration the functions from the given library will be ready to be imported into your Pure program by means of corresponding extern declarations.\n\nShared libraries opened with using clauses are searched for in the same way as source scripts (see section Modules and Imports above), using the -L option and the PURE_LIBRARY environment variable in place of -I and PURE_INCLUDE. If the library isn’t found by these means, the interpreter will also consider other platform-specific locations searched by the dynamic linker, such as the system library directories and LD_LIBRARY_PATH on Linux. The necessary filename suffix (e.g., .so on Linux or .dll on Windows) will be supplied automatically when needed. Of course you can also specify a full pathname for the library if you prefer that. If a library file cannot be found, or if an extern declaration names a function symbol which cannot be resolved, an appropriate error message is printed.\n\n### Importing LLVM Bitcode¶\n\nAs of Pure 0.44, the interpreter also provides a direct way to import LLVM bitcode modules in Pure scripts. The main advantage of this method over the “plain” C interface explained above is that the bitcode loader knows all the call interfaces and generates the necessary extern declarations automatically. This is more than just a convenience, as it also eliminates at least some of the mistakes in extern declarations that may arise when importing functions manually from dynamic libraries.\n\nNote\n\nThe facilities described below require that you have an LLVM-capable C/C++ compiler installed. The available options right now are clang, llvm-gcc and dragonegg. Please check the Pure installation instructions on how to get one of these (or all of them) up and running. Note that clang and llvm-gcc are standalone compilers, while dragonegg is supplied as a gcc plugin which hooks into your existing system compiler (gcc 4.5 or later is required for that). Any of these enable you to compile C/C++ source to LLVM assembler or bitcode. The clang compiler is recommended for C/C++ development, as it offers faster compilation times and has much better diagnostics than gcc. On the other hand, llvm-gcc and dragonegg have the advantage that they also support alternative frontends so that you can compile Fortran and Ada code as well. (But note that, as of LLVM 3.x, llvm-gcc is not supported any more.)\n\nLLVM bitcode is loaded in a Pure script using the following special format of the using clause:\n\n```using \"bc:modname[.bc]\";\n```\n\n(Here the bc tag indicates a bitcode file, and the default .bc bitcode filename extension is supplied automatically. Also, the bitcode file is searched for on the usual library search path.)\n\nThat’s it, no explicit extern declarations are required on the Pure side. The Pure interpreter automatically creates extern declarations (in the current namespace) for all the external functions defined in the LLVM bitcode module, and generates the corresponding wrappers to make the functions callable from Pure. (This also works when batch-compiling a Pure script. In this case, the bitcode file actually gets linked into the output code, so the loaded bitcode module only needs to be present at compile time.)\n\nBy default the imported symbols will be public. You can also specify the desired scope of the symbols explicitly, by placing the public or private keyword before the module name. For instance:\n\n```using private \"bc:modname\";\n```\n\nYou can also import the same bitcode module several times, possibly in different namespaces. This will not actually reload the module, but it will create synonyms for the external functions in different namespaces:\n\n```namespace foo;\nusing \"bc:modname\";\nnamespace bar;\nusing private \"bc:modname\";\n```\n\nYou can load any number of bitcode modules along with shared libraries in a Pure script, in any order. The JIT will try to satisfy external references in modules and libraries from other loaded libraries and bitcode modules. This is deferred until the code is actually JIT-compiled, so that you can make sure beforehand that all required libraries and bitcode modules have been loaded. If the JIT fails to resolve a function, the interpreter will print its name and also raise an exception at runtime when the function is being called from other C code. (You can then run your script in the debugger to locate the external visible in Pure from which the unresolved function is called.)\n\nLet’s take a look at a concrete example to see how this actually works. Consider the following C code which defines a little function to compute the greatest common divisor of two (machine) integers:\n\n```int mygcd(int x, int y)\n{\nif (y == 0)\nreturn x;\nelse\nreturn mygcd(y, x%y);\n}\n```\n\nLet’s say that this code is in the file mygcd.c, then you’d compile it to a bitcode module using clang as follows:\n\n```clang -emit-llvm -c mygcd.c -o mygcd.bc\n```\n\nNote that the -emit-llvm -c options instruct clang to build an LLVM bitcode module. Of course, you can also add optimizations and other options to the compile command as desired.\n\nUsing dragonegg is somewhat more involved, as it doesn’t provide a direct way to produce a bitcode file yet. However, you can create an LLVM assembler file which can then be translated to bitcode using the llvm-as program as follows:\n\n```gcc -fplugin=dragonegg -flto -S mygcd.c -o mygcd.ll\nllvm-as mygcd.ll -o mygcd.bc\n```\n\n(Note that the -fplugin option instructs gcc to use the dragonegg plugin, which in conjunction with the -flto flag switches it to LLVM output. Please check the dragonegg website for details.)\n\nIn either case, you can now load the resulting bitcode module and run the mygcd function in the Pure interpreter simply as follows:\n\n```> using \"bc:mygcd\";\n> mygcd 75 105;\n15\n```\n\nTo actually see the generated extern declaration of the imported function, you can use the interactive show command:\n\n```> show mygcd\nextern int mygcd(int, int);\n```\n\nSome more examples showing how to use the bitcode interface can be found in the Pure sources. In particular, the interface also works with Fortran (using llvm-gfortran or gfortran with dragonegg), and there is special support for interfacing to Grame’s functional DSP programming language Faust (the latter uses a special variant of the bitcode loader, which is selected with the dsp tag in the using clause). Further details about these can be found below.\n\nPlease note that at this time the LLVM bitcode interface is still somewhat experimental, and there are some known limitations:\n\n• LLVM doesn’t distinguish between char* and void* in bitcode, so all void* parameters and return values in C code will be promoted to char* on the Pure side. Also, pointers to types which neither have a predefined meaning in Pure nor a proper type name in the bitcode file, will become a generic pointer type (void*, void**, etc.) in Pure. If this is a problem then you can just redeclare the corresponding functions under a synonym after loading the bitcode module, giving the proper argument and result types (see Extern Declarations above). For instance:\n\n```> using \"bc:foo\";\n> show foo\nextern char* foo(char*);\n> extern void *foo(void*) = myfoo;\n> show myfoo\nextern void* foo(void*) = myfoo;\n```\n• The bitcode interface is limited to the same range of C types as Pure’s plain C interface. In practice, this should cover most C code, but it’s certainly possible that you run into unsupported types for arguments and return values. The compiler will then print a warning; the affected functions will still be linked in, but they will not be callable from Pure. Also note that calling conventions for passing C structs by value depend on the host ABI, so you should have a look at the resulting extern declaration (using show) to determine how the function is actually to be called from Pure.\n\n### Inline Code¶\n\nInstead of manually compiling source files to bitcode modules, you can also just place the source code into a Pure script, enclosing it in %< ... %>. (Optionally, the opening brace may also be preceded with a public or private scope specifier, which is used in the same way as the scope specifier following the using keyword when importing bitcode files.)\n\nFor instance, here is a little script showing inline code for the mygcd function from the previous subsection:\n\n```%<\nint mygcd(int x, int y)\n{\nif (y == 0)\nreturn x;\nelse\nreturn mygcd(y, x%y);\n}\n%>\n\nmygcd 75 105;\n```\n\nThe interpreter automatically compiles the inlined code to LLVM bitcode which is then loaded as usual. (Of course, this will only work if you have the corresponding LLVM compilers installed.) This method has the advantage that you don’t have to write a Makefile and you can create self-contained Pure scripts which include all required external functions. The downside is that the inline code sections will have to be recompiled every time you run the script with the interpreter which may considerably increase startup times. If this is a problem then it’s usually better to import a separate bitcode module instead (see Importing LLVM Bitcode), or batch-compile your script to an executable (see Batch Compilation).\n\nAt present, C, C++, Fortran, ATS and Faust are supported as foreign source languages, with clang, clang++, gfortran (with the dragonegg plugin), patscc and faust as the corresponding (default) compilers. C is the default language. The desired source language can be selected by placing an appropriate tag into the inline code section, immediately after the opening brace. (The tag is removed before the code is submitted to compilation.) For instance:\n\n```%< -*- Fortran90 -*-\nfunction fact(n) result(p)\ninteger n, p\np = 1\ndo i = 1, n\np = p*i\nend do\nend function fact\n%>\n\nfact n::int = fact_ {n};\nmap fact (1..10);\n```\n\nAs indicated, the language tag takes the form -*- lang -*- where lang can currently be any of c, c++, fortran, ats and dsp (the latter indicates the Faust language). Case is insignificant here, so you can also write C, C++, Fortran, ATS, DSP etc. For the fortran tag, you may also have to specify the appropriate language standard, such as fortran90 which is used in the example above. The language tag can also be followed by a module name, using the format -*- lang:name -*-. This is optional for all languages except Faust (where the module name specifies the namespace for the interface routines of the Faust module; see Interfacing to Faust below). So, e.g., a Faust DSP named test would be specified with a dsp:test tag. Case is significant in the module name.\n\nThe Pure interpreter has some built-in knowledge on how to invoke the LLVM compilers to produce a working bitcode file ready to be loaded by the interpreter, so the examples above should work out of the box if you have the required compilers installed on your PATH. However, there are also some environment variables you can set for customization purposes. Specifically, PURE_CC is the command to invoke the C compiler. This variable lets you specify the exact name of the executable along with any debugging and optimization options that you may want to add. Likewise, PURE_CXX, PURE_FC, PURE_ATS and PURE_FAUST are used for the C++, Fortran, ATS and Faust compilers, respectively.\n\nFor instance, if you prefer to use llvm-gcc as your C compiler, and you’d like to invoke it with the -O3 optimization option, you would set PURE_CC to \"llvm-gcc -O3\". (To verify the settings you made, you can have the interpreter echo the compilation commands which are actually executed, by running Pure with the -v0100 option, see Verbosity and Debugging Options. Also note that the options necessary to produce LLVM bitcode will be added automatically, so you don’t have to specify these.)\n\nBeginning with Pure 0.48, the dragonegg gcc plugin is also fully supported. To make this work, you need to explicitly specify the name of the plugin in the compilation command, so that the Pure interpreter can add the proper set of options needed for bitcode compilation. For instance:\n\n```PURE_CC=\"gcc -fplugin=dragonegg -O3\"\n```\n\nSome further details on the bitcode support for specific target languages can be found in the subsections below.\n\n### Interfacing to C++¶\n\nInterfacing to C++ code requires additional preparations because of the name mangling performed by C++ compilers. Usually, you won’t be able to call C++ functions and methods directly, so you’ll have to expose the required functionality using functions with C binding (extern \"C\"). For instance, the following example shows how to work with STL maps from Pure.\n\n```%< -*- C++ -*-\n\n#include <pure/runtime.h>\n#include <string>\n#include <map>\n\n// An STL map mapping strings to Pure expressions.\n\nusing namespace std;\ntypedef map<string,pure_expr*> exprmap;\n\n// Since we can't directly deal with C++ classes in Pure, provide some C\n// functions to create, destroy and manipulate these objects.\n\nextern \"C\" exprmap *map_create()\n{\nreturn new exprmap;\n}\n\nextern \"C\" void map_add(exprmap *m, const char *key, pure_expr *x)\n{\nexprmap::iterator it = m->find(string(key));\nif (it != m->end()) pure_free(it->second);\n(*m)[key] = pure_new(x);\n}\n\nextern \"C\" void map_del(exprmap *m, const char *key)\n{\nexprmap::iterator it = m->find(key);\nif (it != m->end()) {\npure_free(it->second);\nm->erase(it);\n}\n}\n\nextern \"C\" pure_expr *map_get(exprmap *m, const char *key)\n{\nexprmap::iterator it = m->find(key);\nreturn (it != m->end())?it->second:0;\n}\n\nextern \"C\" pure_expr *map_keys(exprmap *m)\n{\nsize_t i = 0, n = m->size();\npure_expr **xs = new pure_expr*[n];\nfor (exprmap::iterator it = m->begin(); it != m->end(); ++it)\nxs[i++] = pure_string_dup(it->first.c_str());\npure_expr *x = pure_listv(n, xs);\ndelete[] xs;\nreturn x;\n}\n\nextern \"C\" void map_destroy(exprmap *m)\n{\nfor (exprmap::iterator it = m->begin(); it != m->end(); ++it)\npure_free(it->second);\ndelete m;\n}\n\n%>\n\n// Create the STL map and add a sentry so that it garbage-collects itself.\nlet m = sentry map_destroy map_create;\n\n// Populate the map with some arbitrary Pure data.\ndo (\\(x=>y) -> map_add m x y) [\"foo\"=>99, \"bar\"=>bar 4711L, \"baz\"=>1..5];\n\n// Query the map.\nmap_keys m; // => [\"bar\",\"baz\",\"foo\"]\nmap (map_get m) (map_keys m); // => [bar 4711L,[1,2,3,4,5],99]\n\n// Delete an element.\nmap_del m \"foo\";\nmap_keys m; // => [\"bar\",\"baz\"]\nmap (map_get m) (map_keys m); // => [bar 4711L,[1,2,3,4,5]]\n```\n\n### Interfacing to ATS¶\n\nATS is a statically typed functional programming language somewhat similar to ML, which also offers imperative and concurrent programming features. One of ATS’s most unusual and interesting aspects is its highly expressive Applied Type System, which gives the language its name. ATS has a very elaborate C interface which lets you expose functions written in the language using C linkage. This makes it easy to call ATS functions from Pure via Pure’s C interface.\n\nHere is a simple example which illustrates how to implement the factorial in ATS and call that function from Pure:\n\n```%< -*- ATS -*-\n\n// A recursive definition of the factorial relation.\n// FACT (n, r) means ‘the factorial of n equals r’.\n// MUL (i, j, k) means ‘the product of i and j equals k’.\ndataprop FACT (int, int) =\n| FACT_base (0, 1)\n| {n : nat} {r1, r : int}\nFACT_induction (n, r) of\n(FACT (n-1, r1), MUL (n, r1, r))\n\n// Declare ifact as an ATS function that is referred to in C by the\n// name ‘ifact_nonneg’. The ‘ifact_nonneg’ function returns an integer\n// equal to r, where r satisfies the relation FACT (n, r).\nextern fun ifact :\n{n : nat} (int n) -<> [r : int] (FACT (n, r) | int r) =\n\"ext#ifact_nonneg\"\n\nimplement ifact (n) =\nlet\nfun fact {n : nat} .<n>. (n : int n) :<>\n[r : int] (FACT (n, r) | int r) =\nbegin\nif n > 0 then\nlet\nval (pf1 | r1) = ifact (n - 1)\nval (pfmul | r) = g1int_mul2 (n, r1)\nin\n(FACT_induction (pf1, pfmul) | r)\nend\nelse\n(FACT_base () | 1)\nend\nin\nfact n\nend\n\n%>\n\nifact n::int = ifact_nonneg n if 0 <= n;\n\nmap ifact (0..9);\n```\n\nTo make this work in Pure, you need to have ATS2 (the current version of the ATS compiler) installed. ATS2 in turn needs a suitable C compiler for generating LLVM bitcode. By default, Pure uses clang for that purpose. If you have gcc’s dragonegg plugin installed, you can also use gcc as the C compiler instead, by setting the PURE_ATS environment variable to patscc -fplugin=dragonegg. Also make sure that you have the PATSHOME environment variable set to ATS’s library directory, as explained in the ATS installation instructions.\n\nMore information about ATS, as well as sources and binary packages of the ATS compiler can be found on the ATS website.\n\n### Interfacing to Faust¶\n\nFaust is a functional dsp (digital signal processing) programming language developed at Grame, which is tailored to the task of generating and transforming streams of numeric data at the sample level. It is typically used to program sound synthesis and audio effect units, but can in fact be employed to process any kind of numeric vector and matrix data. The Faust compiler is capable of generating very efficient code for such tasks which is comparable in performance with carefully handcrafted C routines. Pure’s Faust interface lets you use these capabilities in order to process sample data stored in Pure matrices.\n\nPure’s LLVM bitcode loader has some special knowledge about Faust built into it, which makes interfacing to Faust programs simple and efficient. At present, you’ll need a special LLVM-capable version of Faust to make this work, which is available under the “faust2” branch in Faust’s git repository. Some information on how to get this up and running can be found on the LLVM backend for Faust website.\n\nNote\n\nThere’s also an alternative interface to Faust which is available as a separate package and works with either Faust2 or the stable Faust version. Please check the pure-faust package for details. This package also provides the faust2 compatibility module which implements the pure-faust API on top of Pure’s built-in Faust interface, so that you can also use the operations of this module instead. (The pure-faust API can in fact be more convenient to use in some cases, especially if you want to load a lot of different Faust modules dynamically at runtime.)\n\nThe -lang llvm option instructs the Faust compiler to output LLVM bitcode. Also, you want to add the -double option to make the compiled Faust module use double precision floating point values for samples and control values. So you’d compile an existing Faust module in the source file example.dsp as follows:\n\n```faust -double -lang llvm example.dsp -o example.bc\n```\n\nThe -double option isn’t strictly necessary, but it makes interfacing between Pure and Faust easier and more efficient, since Pure uses double as its native floating point format.\n\nAlternatively, you can also use the Faust pure.c architecture (included in recent Faust2 revisions and also in the pure-faust package) to compile a Faust program to corresponding C source which can then be fed into an LLVM-capable C compiler to produce bitcode which is compatible with Pure’s Faust bitcode loader. This is useful, in particular, if you want to make use of special optimization options provided by the C compiler, or if the Faust module needs to be linked against additional C/C++ code. For instance:\n\n```faust -double -a pure.c -lang c example.dsp -o example.c\nclang -emit-llvm -O3 -c example.c -o example.bc\n```\n\nA third possibility is to just inline Faust code in a Pure script, as described in the Inline Code section. The compilation step is then handled by the Pure compiler and the -double option is added automatically. The PURE_FAUST environment variable can be used to specify a custom Faust command to be invoked by the Pure interpreter. This is useful if you’d like to invoke the Faust compiler with some special options, e.g.:\n\n```PURE_FAUST=\"faust -single -vec\"\n```\n\n(Note that you do not have to include the -lang llvm option; the inline compiler will supply it automatically.)\n\nMoreover, you can also set the FAUST_OPT environment variable to specify any needed postprocessing of the output of the Faust compiler; this is typically used to invoke the LLVM opt utility in a pipeline, in order to have some additional optimizations performed on the Faust-generated code:\n\n```FAUST_OPT=\"| opt -O3\"\n```\n\nAfter loading or inlining the Faust module, the Pure compiler makes the interface routines of the Faust module available in its own namespace. Thus, e.g., the interface routines for the example.dsp module will end up in the example namespace.\n\nPure’s Faust interface offers another useful feature not provided by the general bitcode interface, namely the ability to reload Faust modules on the fly. If you repeat the import clause for a Faust module, the compiler checks whether the module was modified and, if so, replaces the old module with the new one. Retyping an inline Faust code section has the same effect. This is mainly intended as a convenience for interactive usage, so that you can test different versions of a Faust module without having to restart the Pure interpreter. But it is also put to good use in addon packages like pd-faust which allows Faust dsps to be reloaded at runtime.\n\nFor instance, consider the following little Faust program, which takes a stereo audio signal as input, mixes the two channels and multiplies the resulting mono signal with a gain value given by a corresponding Faust control variable:\n\n```gain = nentry(\"gain\", 0.3, 0, 10, 0.01);\nprocess = + : *(gain);\n```\n\nThe interface routines of this Faust module look as follows on the Pure side:\n\n```> show -g example::*\nextern void buildUserInterface(struct_dsp_example*, struct_UIGlue*) = example::buildUserInterface;\nextern void classInit(int) = example::classInit;\nextern void compute(struct_dsp_example*, int, double**, double**) = example::compute;\nextern void delete(struct_dsp_example*) = example::delete;\nextern void destroy(struct_dsp_example*) = example::destroy;\nextern int getNumInputs(struct_dsp_example*) = example::getNumInputs;\nextern int getNumOutputs(struct_dsp_example*) = example::getNumOutputs;\nextern int getSampleRate(struct_dsp_example*) = example::getSampleRate;\nextern expr* info(struct_dsp_example*) = example::info;\nextern void init(struct_dsp_example*, int) = example::init;\nextern void instanceInit(struct_dsp_example*, int) = example::instanceInit;\nextern expr* meta() = example::meta;\nextern struct_dsp_example* new() = example::new;\nextern struct_dsp_example* newinit(int) = example::newinit;\n```\n\nThe most important interface routines are new, init and delete (used to create, initialize and destroy an instance of the dsp) and compute (used to apply the dsp to a given block of samples). Some useful convenience functions are added by the Pure compiler:\n\n• newinit combines new and init;\n• info yields pertinent information about the dsp as a Pure tuple containing the number of input and output channels and the Faust control descriptions;\n• meta yields metadata about the dsp, as declared in the Faust source.\n\nThe latter two are provided in a symbolic format ready to be used in Pure; more about that below.\n\nNote that there’s usually no need to explicitly invoke the delete routine in Pure programs; the Pure compiler makes sure that this routine is added automatically as a finalizer (see sentry) to all dsp pointers created through the new and newinit routines so that dsp instances are destroyed automatically when the corresponding Pure objects are garbage-collected. (If you prefer to do the finalization manually then you must also remove the sentry from the dsp object, so that it doesn’t get deleted twice.)\n\nAnother point worth mentioning here is that the Pure compiler always generates code that ensures that the Faust dsp instances (the struct_dsp pointers) are fully typechecked at runtime. Thus it is only possible to pass a dsp struct pointer to the interface routines of the Faust module it was created with.\n\nLet’s have a brief look at how we can actually run a Faust module in Pure to process some audio samples.\n\nStep 1: Load the Faust dsp. This assumes that the Faust source has already been compiled to a bitcode file, as shown above. You can then load the module in Pure as follows:\n\n```> using \"dsp:example\";\n```\n\nNote that the .bc bitcode extension is supplied automatically. Also note the special dsp tag; this tells the compiler that this is a Faust-generated module, so that it does some Faust-specific processing while linking the module.\n\nAlternatively, you can also just inline the code of the Faust module. For the example above, the inline code section looks as follows:\n\n```%< -*- dsp:example -*-\ngain = nentry(\"gain\", 0.3, 0, 10, 0.01);\nprocess = + : *(gain);\n%>\n```\n\nYou can either add this code to a Pure script, or just type it directly in the Pure interpreter.\n\nFinally, you may want to verify that the module has been properly loaded by typing show -g example::*. The output should look like the listing above.\n\nStep 2: Create and initialize a dsp instance. After importing the Faust module you can now create an instance of the Faust signal processor using the newinit routine, and assign it to a Pure variable as follows:\n\n```> let dsp = example::newinit 44100;\n```\n\nNote that the constant 44100 denotes the desired sample rate in Hz. This can be an arbitrary integer value, which is available in the Faust program by means of the SR variable. It’s completely up to the dsp whether it actually uses this value in some way (our example doesn’t, but we need to specify a value anyway).\n\nThe dsp is now fully initialized and we can use it to compute some samples. But before we can do this, we’ll need to know how many channels of audio data the dsp consumes and produces, and which control variables it provides. This information can be extracted with the info function, and be assigned to some Pure variables as follows:\n\n```> let k,l,ui = example::info dsp;\n```\n\n(We’ll have a closer look at the contents of the ui variable below.)\n\nIn a similar fashion, the meta function provides some “metadata” about the Faust dsp, as a list of key=>val string pairs. This is static data which doesn’t belong to any particular dsp instance, so it can be extracted without actually creating an instance. In our case the metadata will be empty, since we didn’t supply any in the Faust program. If needed, we can add some metadata as follows:\n\n```declare descr \"Faust Hello World\";\ndeclare author \"Faust Guru\";\ndeclare version \"1.0\";\ngain = nentry(\"gain\", 0.3, 0, 10, 0.01);\nprocess = + : *(gain);\n```\n\nIf we now reload the Faust dsp, we’ll get:\n\n```> test::meta;\n[\"descr\"=>\"Faust Hello World\",\"author\"=>\"Faust Guru\",\"version\"=>\"1.0\"]\n```\n\nStep 3: Prepare input and output buffers. Pure’s Faust interface allows you to pass Pure double matrices as sample buffers, which makes this step quite convenient. For given numbers k and l of input and output channels, respectively, we’ll need a k x n matrix for the input and a l x n matrix for the output, where n is the desired block size (the number of samples to be processed per channel in one go). Note that the matrices have one row per input or output channel. Here’s how we can create some suitable input and output matrices using a Pure matrix comprehension and the dmatrix function available in the standard library:\n\n```> let n = 10; // the block size\n> let in = {i*10.0+j | i = 1..k; j = 1..n};\n> let out = dmatrix (l,n);\n```\n\nIn our example, k=2 and l=1, thus we obtain the following matrices:\n\n```> in;\n{11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0;\n21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0}\n> out;\n{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}\n```\n\nStep 4: Apply the dsp to compute some samples. With the in and out matrices as given above, we can now apply the dsp by invoking its compute routine:\n\n```> example::compute dsp n in out;\n```\n\nThis takes the input samples specified in the in matrix and stores the resulting output in the out matrix. The output matrix now looks as follows:\n\n```> out;\n{9.6,10.2,10.8,11.4,12.0,12.6,13.2,13.8,14.4,15.0}\n```\n\nNote that the compute routine also modifies the internal state of the dsp instance so that a subsequent call will continue with the output stream where the previous call left off. (This isn’t relevant in this specific example, but in general a Faust dsp may contain delays and similar constructions which need a memory of past samples to be maintained between different invocations of compute.) Thus we can now just keep on calling compute (possibly with different in buffers) to compute as much of the output signal as we need.\n\nStep 5: Inspecting and modifying control variables. Recall that our sample dsp also has a Faust control variable gain which lets us change the amplification of the output signal. We’ve already assigned the corresponding information to the ui variable, let’s have a look at it now:\n\n```> ui;\nvgroup [] (\"test\",[nentry #<pointer 0x1611f00> [] (\"gain\",0.3,0.0,10.0,0.01)])\n```\n\nIn general, this data structure takes the form of a tree which corresponds to the hierarchical layout of the control groups and values in the Faust program. In this case, we just have one toplevel group containing a single gain parameter, which is represented as a Pure term containing the relevant information about the type, name, initial value, range and stepsize of the control, along with a double pointer which can be used to inspect and modify the control value. While it’s possible to access this information in a direct fashion, there’s also a faustui.pure module in the standard library which makes this easier. First we extract the mapping of control variable names to the corresponding double pointers as follows:\n\n```> using faustui;\n> let ui = control_map \\$ controls ui; ui;\n{\"gain\"=>#<pointer 0xd81820>}\n```\n\nThe result is a record value indexed by control names, thus the pointer which belongs to our gain control can now be obtained with ui!\"gain\". The faustui.pure module also provides convenience functions to inspect a control and change its value:\n\n```> let gain = ui!\"gain\";\n> get_control gain;\n0.3\n> put_control gain 1.0;\n()\n> get_control gain;\n1.0\n```\n\nLet’s rerun compute to get another block of samples from the same input data, using the new gain value:\n\n```> example::compute dsp n in out;\n> out;\n{32.0,34.0,36.0,38.0,40.0,42.0,44.0,46.0,48.0,50.0}\n```\n\nFaust also allows metadata to be attached to individual controls and control groups, which is available in the same form of a list of key=>val string pairs that we have seen already with the meta operation. This metadata is used to provide auxiliary information about a control to specific applications. It’s completely up to the application how to interpret this metadata. Typical examples are style hints about GUI renderings of a control, or the assignment of external “MIDI” controllers. (MIDI is the “Musical Instruments Digital Interface”, a standardized hardware and software interface for electronic music instruments and other digital multimedia equipment.)\n\nIn our example these metadata lists are all empty. Control metadata is specified in a Faust program in the labels of the controls using the syntax [key:val], please see the Faust documentation for details. For instance, if we’d like to assign MIDI controller 7 (usually the “volume controller” on MIDI keyboards) to our gain control, this might be done as follows:\n\n```gain = nentry(\"gain [midi:ctrl 7]\", 0.3, 0, 10, 0.01);\n```\n\nAfter reloading the dsp and creating a new instance, this metadata is available in the ui structure and can be extracted with the control_meta function of the faustui module as follows:\n\n```> let dsp = test::newinit SR;\n> let k,l,ui = example::info dsp;\n> controls ui!0;\nnentry #<pointer 0x1c97070> [\"midi\"=>\"ctrl 7\"] (\"gain\",0.3,0.0,10.0,0.01)\n> control_meta ans;\n[\"midi\"=>\"ctrl 7\"]\n```\n\nAs you can see, all these steps are rather straightforward. Of course, in a real program we would probably run compute in a loop which reads some samples from an audio device or sound file, applies the dsp, and writes back the resulting samples to another audio device or file. We might also have to process MIDI controller input and change the control variables accordingly. This can all be done quite easily using the appropriate addon modules available on the Pure website.\n\nWe barely scratched the surface here, but it should be apparent that the programming techniques sketched out in this section open the door to the realm of sophisticated multimedia and signal processing applications. More Faust-related examples can be found in the Pure distribution. Also, have a look at the pd-pure and pd-faust packages to see how these facilities can be used in Pd modules written in Pure.\n\n## Interactive Usage¶\n\nIn interactive mode, the interpreter reads definitions and expressions and processes them as usual. You can use the -i option to force interactive mode when invoking the interpreter with some script files. Additional scripts can be loaded interactively using either a using declaration or the interactive run command (see the description of the run command below for the differences between these). Or you can just start typing away, entering your own definitions and expressions to be evaluated.\n\nThe input language is mostly the same as for source scripts, and hence individual definitions and expressions must be terminated with a semicolon before they are processed. For instance, here is a simple interaction which defines the factorial and then uses that definition in some evaluations. Input lines begin with “> ”, which is the interpreter’s default command prompt:\n\n```> fact 1 = 1;\n> fact n = n*fact (n-1) if n>1;\n> let x = fact 10; x;\n3628800\n> map fact (1..10);\n[1,2,6,24,120,720,5040,40320,362880,3628800]\n```\n\nAs indicated, in interactive mode the normal forms of toplevel expressions are printed after each expression is entered. This is also commonly known as the read-eval-print loop. Normal form expressions are usually printed in the same form as you’d enter them. However, there are a few special kinds of objects like anonymous closures, thunks (“lazy” values to be evaluated when needed) and pointers which don’t have a textual representation in the Pure syntax and will be printed in the format #<object description> by default. It is also possible to override the print representation of any kind of expression by means of the __show__ function, see Pretty-Printing below for details.\n\nA number of other special features of Pure’s command line interface are discussed in the following subsections.\n\n### Command Syntax¶\n\nBesides Pure definitions and expressions, the interpreter also understands a number of special interactive commands for performing basic maintenance tasks, such as loading source scripts, exiting and restarting the interpreter, changing the working directory, escaping to the shell, getting help and displaying definitions. In contrast to the normal input language, the command language is line-oriented; it consists of special command words to be typed at the beginning of an input line, which may be followed by some parameters as required by the command. The command language is intended solely for interactive purposes and thus doesn’t offer any programming facilities of its own. However, it can be extended with user-defined commands implemented as ordinary Pure functions; this is described in the User-Defined Commands section below.\n\nIn fact, as of Pure 0.56 the interpreter actually provides two slightly different command syntaxes, which we’ll refer to as “default” and “escape mode”. The manual assumes that you’re running the interpreter in its traditional default mode where interactive commands are typed simply as they are shown in the following subsections, with the command word at the very beginning of the line. However, this mode has its pitfalls, especially for beginners. As most of the commands look just like ordinary identifiers, you may run into situations where the beginning of an expression or definition to be typed at the prompt can be mistaken for a command word. In such cases the default mode requires that you insert one or more spaces at the beginning of the line, so that the interpreter reads the line as normal Pure code. Unfortunately, it’s much too easy to forget this if you’re not familiar with the command language.\n\nTherefore there is an alternative escape mode available which handles special command input more like some other popular programming language interpreters. In escape mode all interactive commands have to be escaped by prefixing them with a special character at the very beginning of the line. The command itself must follow the prefix character, without any intervening whitespace. Any line not prefixed with the prefix character will then be considered normal Pure code. This mode can be enabled with the --escape option, which takes the desired prefix character as an argument, or you can just set the PURE_ESCAPE variable in your environment to enable escape mode by default.\n\nFor example, to set the escape character to ‘:‘ you’ll invoke the interpreter as follows:\n\n```\\$ pure --escape=':'\n```\n\nAlternatively, you could also set the PURE_ESCAPE environment variable like this (using Bourne shell syntax):\n\n```\\$ export PURE_ESCAPE=':'\n```\n\nNote that specifying the prefix character with the --escape option overrides the value of the environment variable, and only the initial character in the value of --escape or PURE_ESCAPE will be used. If the specified value is empty, the interpreter reverts to the default mode. The following prefix characters can be used: !\\$%&*,:<>@\\|. Note that these all belong to 7 bit ASCII, and only some of the ASCII punctuation characters are permitted in order to prevent conflicts with ordinary Pure code. In any case, all of these characters can also occur in ordinary Pure code, so you should use a prefix that you aren’t likely to type at the beginning of a line in your usual coding style.\n\nMany Pure programmers prefer escape mode, and in fact we recommend it for Pure novices even though it’s not the default (yet). Others may prefer default mode because it’s less effort to type. For the manual we stick to the default mode syntax. This means that if you’re running the interpreter in escape mode then you’ll have to do the necessary translation of the command syntax yourself. For instance, if the manual tells you to type the following command,\n\n```> show foldl\n```\n\nand you are using ‘:‘ as the command prefix, then you will have to type this in escape mode instead:\n\n```> :show foldl\n```\n\nNote that in this case ‘!‘ continues to serve as a shell escape:\n\n```> ! find . '*.pure'\n```\n\nThis will not work, however, if you use ‘!‘ as your command prefix. In this case you will have to type two exclamation marks instead (the same caveat applies if you escape a shell command in the debugger, cf. Debugging):\n\n```> !! find . '*.pure'\n```\n\nThis should be rather straightforward, so in the following we just use the default mode command syntax throughout without further notice.\n\nNote\n\nEscape mode only applies to the interactive command line. It doesn’t affect the evalcmd function in any way, so interactive commands in the string argument of evalcmd are always specified without the escape character prefix no matter which mode the interpreter is running in.\n\nOnline help is available in the interpreter with the interactive help command, which gives you access to all the available documentation in html format; this includes the present manual, the Pure Library Manual, as well as all manuals of the addon modules available from the Pure website.\n\nYou need to have a html browser installed to make this work. By default, the help command uses w3m, but you can change this by setting either the PURE_HELP or the BROWSER environment variable accordingly.\n\nWhen invoked without arguments, the help command displays an overview of the available documentation, from which you can follow the links to the provided manuals:\n\n```> help\n```\n\n(If the interpreter gives you an error message when you do this then you haven’t installed the documentation yet. The complete set of manuals is provided as a separate package at the Pure website, please see the Pure installation instructions for details.)\n\nThe help command also accepts a parameter which lets you specify a search term which is looked up in the global index, e.g.:\n\n```> help foldl\n```\n\nBesides Pure functions, macros, variables and constants described in the manual you can also look up program options and environment variables, e.g.:\n\n```> help -x\n> help pure-gen -x\n> help PURE_STACK\n```\n\n(Note that you can specify the program name to disambiguate between options for different utilities, such as the -x option which is accepted both by the Pure interpreter and the pure-gen program.)\n\nIf the search term doesn’t appear in the index, it is assumed to be a topic (a link target, usually a section title) in the Pure manual. Note that the docutils tools used to generate the html source of the Pure documentation mangle the section titles so that they are in lowercase and blanks are replaced with hyphens. So to look up the present section in this manual you’d have to type:\n\n```> help online-help\n```\n\nThe help files are in html format and located in the docs subdirectory of the Pure library directory (i.e., /usr/local/lib/pure/docs by default). You can look up topics in any of the help files with a command like the following:\n\n```> help pure-gsl#matrices\n```\n\nHere pure-gsl is the basename of the help file (library path and .html suffix are supplied automatically), and matrices is a link target in that document. To just read the pure-gsl.html file without specifying a target, type the following:\n\n```> help pure-gsl#\n```\n\n(Note that just help pure-gsl won’t work, since it would look for a search term in the index or a topic in the Pure manual.)\n\nLast but not least, you can also point the help browser to any html document (either a local file or some website) denoted by a proper URL, provided that your browser program can handle these. For instance:\n\n```> help file:mydoc.html#foo\n> help http://purelang.bitbucket.org\n```\n\n### Interactive Commands¶\n\nThe following built-in commands are always understood by the interpreter. (In addition, you can define your own commands for frequently-used operations; see User-Defined Commands below.)\n\n! command\n\nShell escape.\n\nbreak [symbol ...]\n\nSets breakpoints on the given function or operator symbols. All symbols must be specified in fully qualified form, see the remarks below. If invoked without arguments, prints all currently defined breakpoints. This requires that the interpreter was invoked with the -g option to enable debugging support. See Debugging below for details.\n\nbt\n\nPrints a full backtrace of the call sequence of the most recent evaluation, if that evaluation ended with an unhandled exception. This requires that the interpreter was invoked with the -g option to enable debugging support. See Debugging below for details.\n\ncd dir\n\nChange the current working dir.\n\nclear [option ...] [symbol ...]\n\nPurge the definitions of the given symbols (functions, macros, constants or global variables). All symbols must be specified in fully qualified form, see the remarks below. If invoked as clear ans, clears the ans value (see Last Result below). When invoked without any arguments, clear purges all definitions at the current interactive “level” (after confirmation) and returns you to the previous level, if any. (It might be a good idea to first check your current definitions with show or back them up with dump before you do that.) The desired level can be specified with the -t option. See the description of the save command and Definition Levels below for further details. A description of the common options accepted by the clear, dump and show commands can be found in Specifying Symbol Selections below.\n\ndel [-b|-m|-t] [symbol ...]\n\nDeletes breakpoints and tracepoints on the given function or operator symbols. If the -b option is specified then only breakpoints are deleted; similarly, del -t only deletes tracepoints. If none of these are specified then both breakpoints and tracepoints are deleted. All symbols must be specified in fully qualified form, see the remarks below. If invoked without non-option arguments, del clears all currently defined breakpoints and/or tracepoints (after confirmation); see Debugging below for details.\n\nThe -m option works similarly to -t, but deletes macro rather than function tracepoints, see the description of the trace command below.\n\ndump [-n filename] [option ...] [symbol ...]\n\nDump a snapshot of the current function, macro, constant and variable definitions in Pure syntax to a text file. All symbols must be specified in fully qualified form, see the remarks below. This works similar to the show command (see below), but writes the definitions to a file. The default output file is .pure in the current directory, which is then reloaded automatically the next time the interpreter starts up in interactive mode in the same directory. This provides a quick-and-dirty way to save an interactive session and have it restored later, but note that this isn’t perfect. In particular, declarations of extern symbols won’t be saved unless they’re specified explicitly, and some objects like closures, thunks and pointers don’t have a textual representation from which they could be reconstructed. To handle these, you’ll probably have to prepare a corresponding .purerc file yourself, see Interactive Startup below.\n\nA different filename can be specified with the -n option, which expects the name of the script to be written in the next argument, e.g: dump -n myscript.pure. You can then edit that file and use it as a starting point for an ordinary script or a .purerc file, or you can just run the file with the run command (see below) to restore the definitions in a subsequent interpreter session.\n\nhelp [topic]\n\nDisplay online documentation. If a topic is given, it is looked up in the index. Alternatively, you can also specify a link target in any of the installed help files, or any other html document denoted by a proper URL. Please see Online Help above for details.\n\nls [args]\n\nList files (shell ls command).\n\nmem\n\nPrint current memory usage. This reports the number of expression cells currently in use by the program, along with the size of the freelist (the number of allocated but currently unused expression cells). Note that the actual size of the expression storage may be somewhat larger than this, since the runtime always allocates expression memory in bigger chunks. Also, this figure does not reflect other heap-allocated memory in use by the program, such as strings or malloc’ed pointers.\n\noverride\n\nEnter “override” mode. This allows you to add equations “above” existing definitions in the source script, possibly overriding existing equations. See Definition Levels below for details.\n\npwd\n\nPrint the current working dir (shell pwd command).\n\nquit\n\nExits the interpreter.\n\nrun [-g|script]\n\nWhen invoked without arguments or with the -g option, run does a “cold” restart of the interpreter, with the scripts and options given on the interpreter’s original command line. If just -g is specified as the argument, the interpreter is run with debugging enabled. Otherwise the interpreter is invoked without debugging support. (This overrides the corresponding option from the interpreter’s command line.) This command provides a quick way to rerun the interpreter after changes in some of the loaded script files, or if you want to enable or disable debugging on the fly (which requires a restart of the interpreter). You’ll also loose any definitions that you entered interactively in the interpreter, so you may want to back them up with dump beforehand.\n\nWhen invoked with a script name as argument, run loads the given script file and adds its definitions to the current environment. This works more or less like a using clause, but only searches for the script in the current directory and places the definitions in the script at the current temporary level, so that clear can be used to remove them again. Also note that namespace and pragma settings of scripts loaded with run stick around after loading the script. This allows you to quickly set up your environment by just running a script containing the necessary namespace declarations and compiler directives. (Alternatively, you can also use the interpreter’s startup files for that purpose, see Interactive Startup below.)\n\nsave\n\nBegin a new level of temporary definitions. A subsequent clear command (see above) will purge the definitions made since the most recent save command. See Definition Levels below for details.\n\nshow [option ...] [symbol ...]\n\nShow the definitions of symbols in various formats. See The show Command below for details. All symbols must be specified in fully qualified form, see the remarks below. A description of the common options accepted by the clear, dump and show commands can be found in Specifying Symbol Selections below.\n\nstats [-m] [on|off]\n\nEnables (default) or disables “stats” mode, in which some statistics are printed after an expression has been evaluated. Invoking just stats or stats on only prints the cpu time in seconds for each evaluation. If the -m option is specified, memory usage is printed along with the cpu time, which indicates the maximum amount of expression memory (in terms of expression cells) used during the computation. Invoking stats off disables stats mode, while stats -m off just disables the printing of the memory usage statistics.\n\ntrace [-a] [-m] [-r] [-s] [symbol ...]\n\nSets tracepoints on the given function or operator symbols. Without the -m option, this works pretty much like the break command (see above) but only prints rule invocations and reductions without actually interrupting the evaluation; see Debugging below for details.\n\nThe -m option allows you to trace macro (rather than function) calls. If this option is specified, the compiler prints reduction sequences involving the given macro symbol, which is useful when debugging macros; see the Macros section for details and examples. Note that macro tracing works even if the interpreter was invoked without debugging mode.\n\nIf the -a option is specified, tracepoints are set on all global function or macro symbols, respectively (in this case the symbol arguments are ignored). This is convenient if you want to see any and all reductions performed in a computation.\n\nTracing can actually be performed in two different modes, recursive mode in which the trace is triggered by any of the active tracepoints and continues until the corresponding call is finished, or skip mode in which only calls by the active tracepoints are reported. The former is usually more helpful and is the default. The -s option allows you to switch to skip mode, while the -r option switches back to recursive mode.\n\nFinally, if neither symbols nor any of the -a, -r and -s options are specified then the currently defined tracepoints are printed. Note that, as with the break command, existing tracepoints can be deleted with the del command (see above).\n\nunderride\n\nExits “override” mode. This returns you to the normal mode of operation, where new equations are added “below” previous rules of an existing function. See Definition Levels below for details.\n\nCommands that accept options generally also understand the -h (help) option which prints a brief summary of the command syntax and the available options.\n\nNote that symbols (identifiers, operators etc.) must always be specified in fully qualified form. No form of namespace lookup is performed by commands like break, clear, show etc. Thus the specified symbols always work the same no matter what namespace and using namespace declarations are currently in effect.\n\nBesides the commands listed above, the interpreter also provides some special commands for the benefit of other programs such as emacs driving the interpreter; currently these are completion_matches, help_matches and help_index. These aren’t supposed to be invoked directly by the user, although they may sometimes be useful to implement custom functionality, see User-Defined Commands.\n\n### Specifying Symbol Selections¶\n\nThe clear, dump and show commands all accept the following options for specifying a subset of symbols and definitions on which to operate. All symbols must be specified in fully qualified form. Options may be combined, thus, e.g., show -mft is the same as show -m -f -t. Some options specify optional numeric parameters; these must follow immediately behind the option character if present, as in -t0.\n\n -c Select defined constants. -f Select defined functions. -g Indicates that the following symbols are actually shell glob patterns and that all matching symbols should be selected. -m Select defined macros. -pflag Select only private symbols if flag is nonzero (the default), otherwise (flag is zero) select only public symbols. If this option is omitted then both private and public symbols are selected. -tlevel Select symbols and definitions at the given “level” of definitions and above. This is described in more detail below. Briefly, the executing program and all imported modules (including the prelude) are at level 0, while “temporary” definitions made interactively in the interpreter are at level 1 and above. Thus a level of 1 restricts the selection to all temporary definitions, whereas 0 indicates all definitions (i.e., everything, including the prelude). If level is omitted, it defaults to the current definitions level. -v Select defined variables. -y Select defined types.\n\nIn addition, the -h option prints a short help message describing all available options of the command at hand.\n\nIf none of the -c, -f, -m, -v and -y options are specified, then all kinds of symbols (constants, functions, macros, variables and types) are selected, otherwise only the specified categories will be considered.\n\nA reasonable default is used if the -t option is omitted. By default, if no symbols are specified, only temporary definitions are considered, which corresponds to -t1. Otherwise the command applies to all corresponding definitions, no matter whether they belong to the executing program, the prelude, or some temporary level, which has the same effect as -t0. This default choice can be overridden by specifying the desired level explicitly.\n\nAs a special case, just clear (without any other options or symbol arguments) always backs out to the previous definitions level (instead of level #1). This is inconsistent with the rules set out above, but is implemented this way for convenience and backward compatibility. Thus, if you really want to delete all your temporary definitions, use clear -t1 instead. When used in this way, the clear command will only remove temporary definitions; if you need to remove definitions at level #0, you must specify those symbols explicitly.\n\nNote that clear -g * will have pretty much the same disastrous consequences as the Unix command rm -rf *, so don’t do that. Also note that a macro or function symbol may well have defining equations at different levels, in which case a command like clear -tn foo might only affect some part of foo‘s definition. The dump and show commands work analogously (albeit less destructively). See Definition Levels below for some examples.\n\n### The show Command¶\n\nThe show command can be used to obtain information about defined symbols in various formats. Besides the common selection options discussed above, this command recognizes the following additional options for specifying the content to be listed and the format to use.\n\n -a Disassembles pattern matching automata. Works like the -v4 option of the interpreter. -d Disassembles LLVM IR, showing the generated LLVM assembler code of a function. Works like the -v8 option of the interpreter. -e Annotate printed definitions with lexical environment information (de Bruijn indices, subterm paths). Works like the -v2 option of the interpreter. -l Long format, prints definitions along with the summary symbol information. This implies -s. -s Summary format, print just summary information about listed symbols.\n\nSymbols are always listed in lexicographic order. Note that some of the options (in particular, -a and -d) may produce excessive amounts of information. By setting the PURE_MORE environment variable, you can specify a shell command to be used for paging, usually more or less.\n\nFor instance, to list all temporary definitions made in an interactive session, simply say:\n\n```> show\n```\n\nYou can also list a specific symbol, no matter whether it comes from the interactive command line, the executing script or the prelude:\n\n```> show foldl\nfoldl f a x::matrix = foldl f a (list x);\nfoldl f a s::string = foldl f a (chars s);\nfoldl f a [] = a;\nfoldl f a (x:xs) = foldl f (f a x) xs;\n```\n\nWildcards can be used with the -g option, which is useful if you want to print an entire family of related functions, e.g.:\n\n```> show -g foldl*\nfoldl f a x::matrix = foldl f a (list x);\nfoldl f a s::string = foldl f a (chars s);\nfoldl f a [] = a;\nfoldl f a (x:xs) = foldl f (f a x) xs;\nfoldl1 f x::matrix = foldl1 f (list x);\nfoldl1 f s::string = foldl1 f (chars s);\nfoldl1 f (x:xs) = foldl f x xs;\n```\n\nOr you can just specify multiple symbols as follows (this also works with multiple glob patterns when you add the -g option):\n\n```> show min max\nmax x y = if x>=y then x else y;\nmin x y = if x<=y then x else y;\n```\n\nYou can also select symbols by category. E.g., the following command shows summary information about all the variable symbols along with their current values (using the “long” format):\n\n```> show -lvg *\nargc var argc = 0;\nargv var argv = [];\ncompiling var compiling = 0;\nsysinfo var sysinfo = \"x86_64-unknown-linux-gnu\";\nversion var version = \"0.66\";\n5 variables\n```\n\nOr you can list just private symbols of the namespace foo, as follows:\n\n```> show -pg foo::*\n```\n\nThe following command will list each and every symbol that’s currently defined (instead of -g * you can also use the -t0 option):\n\n```> show -g *\n```\n\nThis usually produces a lot of output and is rarely needed, unless you’d like to browse through an entire program including all library imports. (In that case you might consider to use the dump command instead, which writes the definitions to a file which can then be loaded into a text editor for easier viewing. This may occasionally be useful for debugging purposes.)\n\nThe show command also has the following alternate forms which are used for special purposes:\n\n• show interface lists the actual type rules for an interface type. This is useful if you want to verify which patterns will be matched by an interface type, see Interface Types for details. For instance:\n\n```> interface stack with\n> push xs::stack x;\n> pop xs::stack;\n> top xs::stack;\n> end;\n> push xs@[] x |\n> push xs@(_:_) x = x:xs;\n> pop (x:xs) = xs;\n> top (x:xs) = x;\n> show interface stack\ntype stack xs@(_:_);\n> pop [] = throw \"empty stack\";\n> top [] = throw \"empty stack\";\n> show interface stack\ntype stack xs@[];\ntype stack xs@(_:_);\n```\n• show namespace lists the current and search namespaces, while show namespaces lists all declared namespaces. These come in handy if you have forgotten what namespaces are currently active and which other namespaces are available in your program. For instance:\n\n```> show namespace\n> show namespaces\nnamespace C;\nnamespace matrix;\n> using namespace C;\n> namespace my;\n> show namespace\nnamespace my;\nusing namespace C;\n```\n\n### Definition Levels¶\n\nTo help with incremental development, the interpreter offers some commands to manipulate the current set of definitions interactively. To these ends, definitions are organized into different subsets called levels. As already mentioned, the prelude, as well as other source programs specified when invoking the interpreter, are always at level 0, while the interactive environment starts at level 1. Each save command introduces a new temporary level, and each subsequent clear command (without any arguments) “pops” the definitions on the current level and returns you to the previous one (if any). This gives you a “stack” of temporary environments which enables you to “plug and play” in a (more or less) safe fashion, without affecting the rest of your program.\n\nFor all practical purposes, this stack is unlimited, so that you can create as many levels as you like. However, this facility also has its limitations. The interpreter doesn’t really keep a full history of everything you entered interactively, it only records the level a variable, constant, and function or macro rule belongs to so that the corresponding definitions can be removed again when the level is popped. On the other hand, intermediate changes in variable values are not recorded anywhere and cannot be undone. Moreover, global declarations (which encompasses using clauses, extern declarations and special symbol declarations) always apply to all levels, so they can’t be undone either.\n\nThat said, the temporary levels can still be pretty useful when you’re playing around with the interpreter. Here’s a little example which shows how to use clear to quickly get rid of a definition that you entered interactively:\n\n```> foo (x:xs) = x+foo xs;\n> foo [] = 0;\n> show\nfoo (x:xs) = x+foo xs;\nfoo [] = 0;\n> foo (1..10);\n55\n> clear\nThis will clear all temporary definitions at level #1.\nContinue (y/n)? y\n> show\n> foo (1..10);\nfoo [1,2,3,4,5,6,7,8,9,10]\n```\n\nWe’ve seen already that normally, if you enter a sequence of equations, they will be recorded in the order in which they were written. However, it is also possible to override definitions in lower levels with the override command:\n\n```> foo (x:xs) = x+foo xs;\n> foo [] = 0;\n> show\nfoo (x:xs) = x+foo xs;\nfoo [] = 0;\n> foo (1..10);\n55\n> save\nsave: now at temporary definitions level #2\n> override\n> foo (x:xs) = x*foo xs;\n> show\nfoo (x:xs) = x*foo xs;\nfoo (x:xs) = x+foo xs;\nfoo [] = 0;\n> foo (1..10);\nwarning: rule never reduced: foo (x:xs) = x+foo xs;\n0\n```\n\nNote that the equation foo (x:xs) = x*foo xs was inserted before the previous rule foo (x:xs) = x+foo xs, which is at level #1. (The latter equation is now “shadowed” by the rule we just entered, hence the compiler warns us that this rule can’t be reduced any more.)\n\nEven in override mode, new definitions will be added after other definitions at the current level. This allows us to just continue adding more high-priority definitions overriding lower-priority ones:\n\n```> foo [] = 1;\n> show\nfoo (x:xs) = x*foo xs;\nfoo [] = 1;\nfoo (x:xs) = x+foo xs;\nfoo [] = 0;\n> foo (1..10);\nwarning: rule never reduced: foo (x:xs) = x+foo xs;\nwarning: rule never reduced: foo [] = 0;\n3628800\n```\n\nAgain, the new equation was inserted above the existing lower-priority rules, but below our previous equation foo (x:xs) = x*foo xs entered at the same level. As you can see, we have now effectively replaced our original definition of foo with a version that calculates list products instead of sums, but of course we can easily go back one level to restore the previous definition:\n\n```> clear\nThis will clear all temporary definitions at level #2.\nContinue (y/n)? y\nclear: now at temporary definitions level #1\nclear: override mode is on\n> show\nfoo (x:xs) = x+foo xs;\nfoo [] = 0;\n> foo (1..10);\n55\n```\n\nNote that clear reminded us that override mode is still enabled (save will do the same if override mode is on while pushing a new definitions level). To turn it off again, use the underride command. This will revert to the normal behaviour of adding new equations below existing ones:\n\n```> underride\n```\n\nIt’s also possible to use clear to back out multiple levels at once, if you specify the target level to be cleared with the -t option. For instance:\n\n```> save\nsave: now at temporary definitions level #2\n> let bar = 99;\n> show\nlet bar = 99;\nfoo (x:xs) = x+foo xs;\nfoo [] = 0;\n> // this scraps all our scribblings!\n> clear -t1\nThis will clear all temporary definitions at level #1 and above.\nContinue (y/n)? y\nclear: now at temporary definitions level #1\n> show\n>\n```\n\nThe facilities described above are also available to Pure programs, as the save and clear commands can also be executed under program control using the evalcmd primitive. Conversely, the library provides its own functions for inspecting and manipulating the source program, which may also be useful in custom command definitions; see the Pure Library Manual for details.\n\n### Debugging¶\n\nThe interpreter provides a simple but reasonably convenient symbolic debugging facility when running interactively. To make this work, you have to specify the -g option when invoking the interpreter (pure -g). If you’re already at the interpreter’s command line, you can also use the run -g command to enable the debugger. The -g option disables tail call optimization (see Stack Size and Tail Recursion) to make it easier to debug programs. It also causes special debugging code to be generated which will make your program run much slower. Therefore the -g option should only be used if you actually need the debugger.\n\nOne common use of the debugger is “post mortem” debugging after an evaluation ended with an unhandled exception. In such a case, the bt command of the interpreter prints a backtrace of the call sequence which caused the exception. Note that this only works if debugging mode was enabled. For instance:\n\n```> [1,2]!3;\n<stdin>, line 2: unhandled exception 'out_of_bounds' while evaluating '[1,2]!3'\n> bt\n (!): (x:xs)!n::int = xs!(n-1) if n>0;\nn = 3; x = 1; xs = \n (!): (x:xs)!n::int = xs!(n-1) if n>0;\nn = 2; x = 2; xs = []\n (!): []!n::int = throw out_of_bounds;\nn = 1\n>> throw: extern void pure_throw(expr*) = throw;\nx1 = out_of_bounds\n```\n\nThe last call, which is also marked with the >> symbol, is the call that raised the exception. The format is similar to the p command of the debugger, see below, but bt always prints a full backtrace. (As with the show command of the interpreter, you can set the PURE_MORE environment variable to pipe the output through the corresponding command, or use evalcmd to capture the output of bt in a string.)\n\nThe debugger can also be used interactively. To these ends, you can set breakpoints on functions with the break command. The debugger then gets invoked as soon as a rule for one of the given functions is executed. Example:\n\n```> fact n::int = if n>0 then n*fact (n-1) else 1;\n> break fact\n> fact 1;\n** fact: fact n::int = if n>0 then n*fact (n-1) else 1;\nn = 1\n(Type 'h' for help.)\n:\n** fact: fact n::int = if n>0 then n*fact (n-1) else 1;\nn = 0\n:\n++ fact: fact n::int = if n>0 then n*fact (n-1) else 1;\nn = 0\n--> 1\n** (*): x::int*y::int = x*y;\nx = 1; y = 1\n:\n++ (*): x::int*y::int = x*y;\nx = 1; y = 1\n--> 1\n++ fact: fact n::int = if n>0 then n*fact (n-1) else 1;\nn = 1\n--> 1\n1\n```\n\nLines beginning with ** indicate that the evaluation was interrupted to show the rule (or external) which is currently being considered, along with the current depth of the call stack, the invoked function and the values of parameters and other local variables in the current lexical environment. In contrast, the prefix ++ denotes reductions which were actually performed during the evaluation and the results that were returned by the function call (printed as --> return value).\n\nSometimes you might also see funny symbols like #<closure>, #<case> or #<when> instead of the function name. These indicate lambdas and the special variable-binding environments, which are all implemented as anonymous closures in Pure. Also note that the debugger doesn’t know about the argument names of external functions (which are optional in Pure and not recorded anywhere), so it will display the generic names x1, x2 etc. instead.\n\nAt the debugger prompt ‘:‘ you can enter various special debugger commands, or just keep on hitting the carriage return key to walk through an evaluation step by step, as we did in the example above. (Command line editing works as usual at the debugger prompt, if it is enabled.) The usual commands are provided to walk through an evaluation, print and navigate the call stack, step over the current call, or continue the evaluation unattended until you hit another breakpoint. If you know other source level debuggers like gdb then you should feel right at home. You can type h at the debugger prompt to print the following list:\n\n```: h\nDebugger commands:\na auto: step through the entire program, run unattended\nc [f] continue until next breakpoint, or given function f\nh help: print this list\nn next step: step over reduction\np [n] print rule stack (n = number of frames)\nr run: finish evaluation without debugger\ns single step: step into reduction\nt, b move to the top or bottom of the rule stack\nu, d move up or down one level in the rule stack\nx exit the interpreter (after confirmation)\n. reprint current rule\n! cmd execute interpreter command\n? expr evaluate expression\n<cr> single step (same as 's')\n<eof> step through program, run unattended (same as 'a')\n```\n\nNote\n\nIf you specified an --escape prefix other than ‘!‘ (cf. Command Syntax), that prefix will be used to execute interpreter commands instead, see below. The help message will tell you which command prefix is in effect.\n\nThe command syntax is very simple. Besides the commands listed above you can also enter comment lines (// comment text) which will just be ignored. Extra arguments on commands which don’t expect any will generally be ignored as well. The single letter commands all have to be separated from any additional parameters with whitespace, whereas the ‘!‘, ‘?‘ and ‘.‘ commands count as word delimiters and can thus be followed immediately by an argument. For convenience, the ‘?‘ command can also be omitted if the expression to be evaluated doesn’t start with a single letter or one of the special punctuation commands.\n\nThe debugger can be exited or suspended in the following ways:\n\n• You can type c to continue the evaluation until the next breakpoint, or c foo in order to proceed until the debugger hits an invocation of the function foo.\n• You can type r to run the rest of the evaluation without the debugger.\n• The a (“auto”) command single-steps through the rest of the evaluation, running unattended. This command can also be entered by just hitting the end-of-file key (<" ]
[ null, "https://puredocs.bitbucket.io/_images/math/62d0effd6477f4244d585fc25f46a645378a4ceb.png", null ]
{"ft_lang_label":"__label__en","ft_lang_prob":0.846383,"math_prob":0.9303738,"size":400918,"snap":"2021-04-2021-17","text_gpt3_token_len":98685,"char_repetition_ratio":0.17885132,"word_repetition_ratio":0.054334015,"special_character_ratio":0.2512883,"punctuation_ratio":0.14413106,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96230054,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-25T14:50:06Z\",\"WARC-Record-ID\":\"<urn:uuid:705989b3-e6e4-424f-a4d3-38e9b2f5b2f3>\",\"Content-Length\":\"1050228\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0b8cf7ab-b3ce-4755-9351-3c4ab83c5ef6>\",\"WARC-Concurrent-To\":\"<urn:uuid:b56cde6d-4ab7-4389-a027-35630db124f7>\",\"WARC-IP-Address\":\"18.205.93.11\",\"WARC-Target-URI\":\"https://puredocs.bitbucket.io/pure.html\",\"WARC-Payload-Digest\":\"sha1:6F6KJ375PUQLLU7OOTDWDC4ZDVHMD33V\",\"WARC-Block-Digest\":\"sha1:T2LOGMDXU5U4VVYMBY5WLBYEAVWWS5LW\",\"WARC-Truncated\":\"length\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703581888.64_warc_CC-MAIN-20210125123120-20210125153120-00506.warc.gz\"}"}