Datasets:

Modalities:
Tabular
Text
Formats:
parquet
DOI:
Libraries:
Datasets
Dask
License:
url
stringlengths
5
5.75k
fetch_time
int64
1,368,854,400B
1,726,893,797B
content_mime_type
stringclasses
3 values
warc_filename
stringlengths
108
138
warc_record_offset
int32
873
1.79B
warc_record_length
int32
587
790k
text
stringlengths
30
1.05M
token_count
int32
16
919k
char_count
int32
30
1.05M
metadata
stringlengths
439
444
score
float64
2.52
5.13
int_score
int64
3
5
crawl
stringclasses
93 values
snapshot_type
stringclasses
2 values
language
stringclasses
1 value
language_score
float64
0.05
1
https://questions.examside.com/past-years/jee/question/plet-f--r-to-r-be-a-continuous-function-such-that--jee-main-mathematics-trigonometric-functions-and-equations-nhnohuulhdvxhpzb
1,716,252,734,000,000,000
text/html
crawl-data/CC-MAIN-2024-22/segments/1715971058342.37/warc/CC-MAIN-20240520234822-20240521024822-00331.warc.gz
434,727,721
48,880
1 JEE Main 2022 (Online) 26th July Morning Shift +4 -1 Let f : R $$\to$$ R be a continuous function such that $$f(3x) - f(x) = x$$. If $$f(8) = 7$$, then $$f(14)$$ is equal to : A 4 B 10 C 11 D 16 2 JEE Main 2022 (Online) 26th July Morning Shift +4 -1 If the function $$f(x) = \left\{ {\matrix{ {{{{{\log }_e}(1 - x + {x^2}) + {{\log }_e}(1 + x + {x^2})} \over {\sec x - \cos x}}} & , & {x \in \left( {{{ - \pi } \over 2},{\pi \over 2}} \right) - \{ 0\} } \cr k & , & {x = 0} \cr } } \right.$$ is continuous at x = 0, then k is equal to: A 1 B $$-$$1 C e D 0 3 JEE Main 2022 (Online) 26th July Morning Shift +4 -1 If $$f(x) = \left\{ {\matrix{ {x + a} & , & {x \le 0} \cr {|x - 4|} & , & {x > 0} \cr } } \right.$$ and $$g(x) = \left\{ {\matrix{ {x + 1} & , & {x < 0} \cr {{{(x - 4)}^2} + b} & , & {x \ge 0} \cr } } \right.$$ are continuous on R, then $$(gof)(2) + (fog)( - 2)$$ is equal to : A $$-$$10 B 10 C 8 D $$-$$8 4 JEE Main 2022 (Online) 26th July Morning Shift +4 -1 Let $$f(x) = \left\{ {\matrix{ {{x^3} - {x^2} + 10x - 7,} & {x \le 1} \cr { - 2x + {{\log }_2}({b^2} - 4),} & {x > 1} \cr } } \right.$$. Then the set of all values of b, for which f(x) has maximum value at x = 1, is : A ($$-$$6, $$-$$2) B (2, 6) C $$[ - 6, - 2) \cup (2,6]$$ D $$\left[ {-\sqrt 6 , - 2} \right) \cup \left( {2,\sqrt 6 } \right]$$ EXAM MAP Medical NEET
668
1,351
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.15625
3
CC-MAIN-2024-22
latest
en
0.626459
https://chalmers.instructure.com/courses/12368/assignments/syllabus
1,713,370,895,000,000,000
text/html
crawl-data/CC-MAIN-2024-18/segments/1712296817158.8/warc/CC-MAIN-20240417142102-20240417172102-00815.warc.gz
147,565,129
20,939
## Course syllabus MVE155 / MSG200 Statistical inference (7.5 hp) 2021 Course is offered by the department of Mathematical Sciences Serik Sagitov ### Course purpose "Statistical Inference" is a second course in mathematical statistics suitable for students with different backgrounds. A main prerequisite is an introductory course in probability and statistics. The course gives a deeper understanding of some traditional topics in mathematical statistics such as methods based on likelihood, aspects of experimental design, non-parametric testing, analysis of variance, introduction to Bayesian inference, chi-squared tests, multiple regression. Install Rstudio Step 1: install R from http://ftp.acc.umu.se/mirror/CRAN/ No previous knowledge of programming is required. ### Schedule We meet online via Zoom Link Passcode 899022 Recorded Zoom sessions can be found under the option "Modules". Date, usual time 13.15-15.00 Description of sessions Chapters in Compendium Mon 18/01 Lecture 1: Random sampling  Slides1.pdf Chapters 1-3 Tue 19/01 Exercise 1: 3.6.1, 3.6.2, R session QQplot.R Wed 20/01 Lecture 2: Stratified samples Slides2.pdf. Parametric models  Slides3.pdf Chapters 3-4 Mon 25/01 Exercise 2: 3.6.6, 3.6.7, 3.6.8, 4.7.1, R solution of 3.6.7 Tue 26/01 Lecture 3: Maximum likelihood  Slides4.pdf. R session Multinomial and Chi2 .R Chapter 4 Wed 27/01 Exercise 3:  4.7.3, 4.7.5, 4.7.6, 4.7.7 Fri 29/01 Lecture 4: Hypothesis testing Slides5.pdf, Slides6.pdf Chapter 5 Mon 01/02 Exercise 4: 5.8.1, 5.8.4, 5.8.6, 5.8.7, 5.8.10 Tue 02/02 Lecture 5: Bayesian inference Slides7.pdf. R session Bayes.R Chapter 6 Wed 03/02 Exercise 5: 5.8.2, 5.8.9, 5.8.12, 6.5.4 Fri 05/02 Lecture 6: Bayesian inference  Slides8.pdf Chapter 6 Mon 08/02 Exercise 6: 6.5.1, 6.5.2, 6.5.3, 6.5.5, 6.5.6 Tue 09/02 Lecture 7: Empirical distribution Slides9.pdf. R session Summarising Data.R Chapter 7 Wed 10/02 Exercise 7: 7.7.1, 7.7.2, 7.7.3, 7.7.4, 7.7.5, 7.7.6. R session ExercisesCh7.R Fri 12/02 Lecture 8: Comparing two populations Slides10.pdf, Slides11.pdf Chapter 8 Mon 15/02 Exercise 8: 8.6.2, 8.6.5, 8.6.9, 8.6.11 Tue 16/02 Lecture 9: ANOVA1  Slides11.pdf, Slides12.pdf Chapter 8-9 Wed 17/02 Exercise 9: R session t-test and ANOVA.R Fri 19/02 Lecture 10: ANOVA2 Slides13.pdf Chapter 9 Mon 22/02 Exercise 10: 9.8.1, 9.8.2, 9.8.3, 9.8.4, 9.8.7 Tue 23/02 Lecture 11: Nonparametric tests Slides14.pdf. R session Nonparametric tests.R Chapter 9-10 Wed 24/02 Exercise 11: 8.6.3, 8.6.4, 8.6.7, 8.6.8, 9.8.5, 9.8.6, Mon 01/03 Lecture 12: Categorical data Slides15.pdf. R session Chi-square test.R Chapter 10 Tue 02/03 Exercise 12: 10.5.3, 10.5.6, 10.5.7, 10.5.9. An example of a final exam Wed 03/03 Lecture 13: Simple linear regression Slides16.pdf Chapter 11 Fri 05/03 Exercise 13: 11.6.5, 11.6.6. R session Regression.R Mon 08/03 Lecture 14: Multiple regression Slides17.pdf Chapter 11 Tue 09/03 Exercise 14: 11.6.3, 11.6.4, 11.6.7, 14.1.1, 14.1.14, 14.1.21, 14.1.9 Chapter 14 Tue 16/03, 14.00-18.00 Exam 1 (register before 28.02.2021) Wed 09/06, 8.30-12.30 Exam 2 (register before ) Tue 17/08, 14.00-18.00 Exam 3 (register before ) ### Course literature The course is build around the Compendium - click and download. The compendium may undergo minor updates - on the first page you will see when it was last updated. Recommended additional textbook: Mathematical statistics and data analysis, 3rd edition (2nd edition is also OK), by John Rice (Cremona). ### Learning objectives and syllabus Learning objectives: - summarize multiple sample data in a meaningful and informative way, - recognize several basic types of statistical problems corresponding to various sampling designs, - estimate relevant parameters and perform appropriate statistical tests for multiple sample data sets. Link to the syllabus on Studieportalen: Study plan ### Examination form The grading of the course is based on a written examination. Preparing for the final exam, check Section 12.1 of the Compendium to see the list of the topics that may be addressed by the final exam questions. Several old exams with solutions are given in the module "Old exams". Maximal number of points for the final exam is 30. Passing limits • CTH students: 12 points for '3', 18 points for '4', 24 points for '5' • GU students: 12 points for 'G', 20 points for 'VG' Date Details Due
1,452
4,358
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.6875
3
CC-MAIN-2024-18
latest
en
0.700115
http://slideplayer.com/slide/763764/
1,534,695,087,000,000,000
text/html
crawl-data/CC-MAIN-2018-34/segments/1534221215222.74/warc/CC-MAIN-20180819145405-20180819165405-00645.warc.gz
384,268,089
24,508
# Activity 79 Analysis Questions ## Presentation on theme: "Activity 79 Analysis Questions"— Presentation transcript: Activity 79 Analysis Questions Describe the changes in direction and speed of the marble when they’re inside the circular track? The marbles’ direction changed constantly inside the circular track because of the force the wall exerted on the marble. Similarly, the surface of the circular track rubbed on the marble and slowed in down slightly. outside of the circular track? The direction once outside the circular track was in a straight line, moving across the table as shown on Transparency 79.1, “Inertia Diagrams”. The speed slowed slightly because of the table surface rubbing on the marble. Describe any changes in the path of the marble that occurred when you changed the opening position of the circular track. The marble left the opening in a different direction for each opening position. Once it left the circular track, however, it continued in a straight line. mass of the marble. When comparing the glass (lighter) marble to the heavier (metal) one, no changes occurred to the direction that the marble traveled. Imagine that a car is approaching a curve in the road when it suddenly loses its steering and brakes. The area is flat and there is no guardrail on the road. Copy the diagram below in your science notebook. Then draw a line showing the car’s path when it loses its steering and brakes. Explain why the car will take that path. Because of inertia, which in the absence of other forces keeps moving objects moving in a straight line. How would your answer change if the car had more mass? Explain. More mass will not change the direction the car travels. It would, however, affect the force needed to stop the car. Activity 79 Major Concepts An object that is not being subject to a force will continue to move at a constant speed in a straight line. On your next blank page, take notes Force Notes Net Force In many situations, including driving, more than one force is acting on an object. The combination of all forces acting on an object is the net force. Net force determines whether, and by how much, an object’s motion is changed. Total Force Force Diagrams Objects are shown as a rectangle or square. Force Diagrams A push or pull (force) is shown with an arrow Force Diagrams The arrow always points AWAY from the object. Force Diagrams The bigger the force, the bigger the arrow Force Diagrams Label the arrows with the magnitude (amount) of the force (in N) 3 N 10 N Force Diagrams Net Force is the sum of all of the forces 3 N 10 N 7 N Practice: Draw an object with two forces acting in opposite directions with one force equal to 2 N and one force equal to 8 N. Force Diagrams 2 N 8 N Net Force Draw the net force acting on this object. 2 N 8 N Force Diagrams Net Force 6 N Balanced vs. Unbalanced Forces If there is a situation of unbalanced forces, there is a net force. Balanced forces mean there is a net force of zero on the object. Describe the motion of the blocks below. 2 N 10 N A. 8 N 8 N B.
680
3,078
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
4.3125
4
CC-MAIN-2018-34
longest
en
0.925009
https://devsenv.com/example/codeforcess-solution-b.-shooting-solution-in-c,-c++,-java,-python
1,726,040,920,000,000,000
text/html
crawl-data/CC-MAIN-2024-38/segments/1725700651344.44/warc/CC-MAIN-20240911052223-20240911082223-00191.warc.gz
183,967,129
45,827
Algorithm B. Shooting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed n cans in a row on a table. Cans are numbered from left to right from 11 to n. Vasya has to knock down each can exactly once to finish the exercise. He is allowed to choose the order in which he will knock the cans down. Vasya knows that the durability of the i-th can is ai��. It means that if Vasya has already knocked x cans down and is now about to start shooting the i-th one, he will need (aix+1)(��⋅�+1) shots to knock it down. You can assume that if Vasya starts shooting the i-th can, he will be shooting it until he knocks it down. Your task is to choose such an order of shooting so that the number of shots required to knock each of the n given cans down exactly once is minimum possible. Input The first line of the input contains one integer n (2n1000)(2≤�≤1000) — the number of cans. The second line of the input contains the sequence a1,a2,,an�1,�2,…,�� (1ai1000)(1≤��≤1000), where ai�� is the durability of the i-th can. Output In the first line print the minimum number of shots required to knock each of the n given cans down exactly once. In the second line print the sequence consisting of n distinct integers from 11 to n — the order of indices of cans that minimizes the number of shots required. If there are several answers, you can print any of them. Examples input Copy 3 20 10 20 output Copy 43 1 3 2 input Copy 4 10 10 10 10 output Copy 64 2 1 4 3 input Copy 6 5 4 5 4 4 5 output Copy 69 6 1 3 5 2 4 input Copy 2 1 4 output Copy 3 2 1 Note In the first example Vasya can start shooting from the first can. He knocks it down with the first shot because he haven't knocked any other cans down before. After that he has to shoot the third can. To knock it down he shoots 201+1=2120⋅1+1=21 times. After that only second can remains. To knock it down Vasya shoots 102+1=2110⋅2+1=21 times. So the total number of shots is 1+21+21=431+21+21=43. In the second example the order of shooting does not matter because all cans have the same durability. Code Examples #1 Code Example with C++ Programming Code - C++ Programming #include <bits/stdc++.h> using namespace std; int const N = 1e3 + 10; int n; pair<int, int> a[N]; int main() { #ifndef ONLINE_JUDGE freopen("in", "r", stdin); #endif scanf("%d", &n); for(int i = 0, tmp; i < n; ++i) { scanf("%d", &tmp); a[i].first = tmp; a[i].second = i; } sort(a, a + n); reverse(a, a + n); int res = 0; for(int i = 0; i < n; ++i) res += (a[i].first * i + 1); printf("%d\n", res); for(int i = 0; i < n; ++i) { if(i != 0) printf(" "); printf("%d", a[i].second + 1); } puts(""); return 0; } Copy The Code & Input cmd 3 20 10 20 Output cmd 43 1 3 2
910
2,889
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.984375
3
CC-MAIN-2024-38
latest
en
0.842635
https://forum.nutsvolts.com/viewtopic.php?f=45&t=627&view=print
1,603,511,147,000,000,000
text/html
crawl-data/CC-MAIN-2020-45/segments/1603107881640.29/warc/CC-MAIN-20201024022853-20201024052853-00255.warc.gz
328,661,497
3,882
Page 1 of 2 Automotive dual battery question Posted: Tue Feb 24, 2004 8:30 am I have a diesel pick-up with dual 750 CCA batteries wired in parallel. The passenger side battery has a 2/0 cable running directly to the starter. The drivers side battery is connected to the pass. battery thru a 5 foot length of 4 gauge wire. According to the shop manual, starting current can be as high as 700 amps. My question is, does the pass. side battery take more of a load than the drivers side battery because of the realitive small 4 gauge connection? How is the current draw split between the 2 batteries or is it equal? Thanks in advance for any thoughts. Re: Automotive dual battery question Posted: Tue Feb 24, 2004 9:06 am The battery with the thickest cables takes the greatest load during start-up. The thinner cables resist the current flow from the passenger battery while cranking the starter. Re: Automotive dual battery question Posted: Tue Feb 24, 2004 9:57 am The further the distance, the bigger the cable needed. The two most likely draw apx the same current, based upon size AND distance. Re: Automotive dual battery question Posted: Tue Feb 24, 2004 11:11 am This will screw up the estimates (And probably show how little I know) According to my estimate, with a copper resistivity of 1.6 microhms per cubic centimetre the resistance of a 4 ft long piece of 4 gauge wire is the order of one thousandth of an ohm hence, a 10 volt drop across it would represent a current of 100 amps. There Re: Automotive dual battery question Posted: Tue Feb 24, 2004 11:11 am This will screw up the estimates (And probably show how little I know) According to my estimate, with a copper resistivity of 1.6 microhms per cubic centimetre the resistance of a 4 ft long piece of 4 gauge wire is the order of one thousandth of an ohm hence, a 10 volt drop across it would represent a current of 100 amps. There Re: Automotive dual battery question Posted: Tue Feb 24, 2004 11:16 am This is going to screw up the estimates (Or show how little I know) - according to me, with a copper resistivity of 1.6 microhms per cubic centimetre the resistance of a 4 ft long length of 4 gauge wire woulf be the order of 1000th part of an ohm. Hence, a 100 amp current through it would produce a volts drop of 10 volts. There is no way the differnce between two, fairly well charged 12 volt batteries, with one on load, is going to exceed 10 volts so the likely, bettery healthy, starting current in the lead will be the order of 40 - 60 amps Re: Automotive dual battery question Posted: Tue Feb 24, 2004 11:58 am WOW… <p>[ February 24, 2004: Message edited by: Edd Whatley ]</p> Re: Automotive dual battery question Posted: Tue Feb 24, 2004 1:55 pm Chris Smith,<p> Not sure I follow you. The 2/0 cable to the starter is approx. 4' long. Are you saying that the wire size between the 2 batteries makse no difference and they will always share "equal current",ie, 350 amps? Re: Automotive dual battery question Posted: Tue Feb 24, 2004 3:25 pm Where's that guy with the strap-on ammeter? The large, close cable (passenger side) will carry most of the current. Re: Automotive dual battery question Posted: Tue Feb 24, 2004 4:26 pm You have to include the internal resistance of the battery to make a valid calculation. Since internal resistance will be higher than cable resistance the two batteries will be sharing a nearly equal load. Re: Automotive dual battery question Posted: Tue Feb 24, 2004 5:34 pm The batteries are connected in parallel. The drivers side 4 ga. wire carries only the current from that battery. It connects to the passenger side battery. The 2/0 carries the current from both batteries. If both batteries are healthy, the current will be pretty close to the same from each battery. Re: Automotive dual battery question Posted: Tue Feb 24, 2004 5:34 pm the smaller cable only has have the current flow in it thus smaller cable to the other battery the larger wire carries all the current for the starter 700 amps joe Re: Automotive dual battery question Posted: Tue Feb 24, 2004 8:12 pm If driver's side battery is connected to passenger's side battery, the cable from passenger's side battery to starter carries current from both batteries.<p>Passenger side battery does supply more starter current than driver side, but its not too lop-sided. And, if engine doesn't start, driver side battery will partially recharge passenger side battery between tries.<p>700 amps is only when you first turn the key. As starter motor speeds up, the current decreases. At full cranking speed probably well under 100 amps. Then driver side batt is still providing less current, but is more of an equal share. Re: Automotive dual battery question Posted: Wed Feb 25, 2004 3:56 am My, my! Let's expand on the proportions. Say the passenger side battery is 2 feet away from the starter with 2/0 cable. The drivers side battery is connected by 4 ga, in say, the next county. Same current from each battery? I don't think so. Most of the current from the drivers side is lost as IR drop in the longer, smaller cable. Put another way- disconnect the parallel connection between the batteries. Connect just passengers side battery to starter and measure the cranking current. Then, connect only the drivers side with the smaller wire from the battery in the next county. It won't even crank! Re: Automotive dual battery question Posted: Wed Feb 25, 2004 6:11 am What threw me off is that in almost all cars, the stock (OEM) battery is on the driver's side. I did not catch that the vehicle was a diesel. So, If I were to add an extra battery, I would tend to leave that one alone and connect the extra one to it. I did not catch that both batteries were stock.<p>If I were you, I would connect the batteries together with 0000 gauge wires.<p>[ February 25, 2004: Message edited by: Joseph ]</p>
1,463
5,898
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.859375
3
CC-MAIN-2020-45
latest
en
0.919264
https://coinlogin.org/the-world-communicates-physics/
1,576,200,213,000,000,000
text/html
crawl-data/CC-MAIN-2019-51/segments/1575540547536.49/warc/CC-MAIN-20191212232450-20191213020450-00109.warc.gz
321,524,449
9,819
# The World Communicates-Physics The wave model can be used to explain how current technologies transfer information. Describe the energy transformations required in one of the following: * Mobile Telephone Mobile telephones have built in microphones that changes sound waves ib Describe waves as a transfer of energy disturbance that may occur in one, two or three dimensions, depending on the nature of the wave and the medium Identify that mechanical waves require a medium for propagation while electromagnetic waves do not Mechanical: Requires a medium for propagation (ie. Travel through) Eg. Sound Waves, Water Waves, Waves in a string .. Electromagnetic: Do not require a medium for propagation (ie. EM Waves can pass through a vacuum) Eg. Light, Infrared, UV, X rays, Gamma Rays, Radio waves, Microwaves .. Define and apply the following terms of the wave model: Medium, displacement, amplitude, period, compression, rarefaction, crest, trough, transverse waves, longitudinal waves, frequency, wavelength & velocity. Describe the relationship between particle motion and the direction of energy propagation in transverse and longitudinal waves Quantify the relationship between velocity, frequency and wavelength v=f? We Will Write a Custom Essay Specifically For You For Only \$13.90/page! order now Where v = velocity, f = frequency & ? = wavelength (lambda) Features of a wave model can be used to account for the properties of sound. Identify that sound waves are vibrations or oscillations of particles in a medium Relate compressions and rarefactions of sound waves to the crests and troughs of transverse waves used to represent them Explain qualitatively that pitch is related to frequency and volume to amplitude of sound waves Explain an echo as a reflection of a sound wave Describe the principle of superposition and compare the resulting waves to the original waves in sound
371
1,901
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3
3
CC-MAIN-2019-51
latest
en
0.842486
https://www.experts-exchange.com/questions/26647925/Get-value-from-associative-array-without-key.html
1,488,005,733,000,000,000
text/html
crawl-data/CC-MAIN-2017-09/segments/1487501171670.52/warc/CC-MAIN-20170219104611-00343-ip-10-171-10-108.ec2.internal.warc.gz
816,057,912
27,396
Solved # Get value from associative array without key... Posted on 2010-11-30 485 Views Given an array like this, where I don't know the key name, how can I extract the value of both elements (AL, Alabama)? Array ( [abbreviation] => AL [full_name] => Alabama ) 0 Question by:interclubs • 2 • 2 LVL 11 Expert Comment ID: 34241258 you cannot unless you know the array variable's name in which case you would extract the values like \$name['abbreviation']['full_name']; 0 LVL 14 Expert Comment ID: 34241613 If you mean that you don't know the key names (abbreviation, full_name) you can do something like this: foreach (\$array_name as \$value){ \$x[] = \$value; } That would give you an array of two elements in your example where \$x[0] = 'AL' and \$x[1] = 'Alabama'. If you don't know the name of the actual array (\$array_name) in my example, I have no idea how you would find the values. 0 LVL 1 Accepted Solution jebpotly earned 500 total points ID: 34241967 array_keys will give you a list of the keys in an array. If you have: ``````\$my_array = array('abbreviation' => 'AL', 'full_name' => 'Alabama'); `````` then you could use array_keys: ``````\$my_keys = array_keys(\$my_array); `````` which would give you an array of Array ( [0] => abbreviation [1] => full_name ). You could then do ``````\$first_value = \$my_array[\$my_keys[0]]; \$second_value = \$my_array[\$my_keys[0]]; `````` Or you could convert the array to use numeric indexes instead of string indexes. One way to do this is use the sort() method. So if you have the \$my_array as defined above then you could do: ``````sort(\$my_array); `````` Now \$my_array is Array ( [0] => Alabama [1] => AL) and you can use [0] and [1] to get the values. ``````\$first_value = \$my_array[0]; \$second_value = \$my_array[1]; `````` 0 LVL 11 Expert Comment ID: 34243985 @jebpotly: Sweet, did not know about "array_keys(\$my_array);" Thanks 0 LVL 1 Expert Comment ID: 34244028 ;) 0 ## Featured Post Question has a verified solution. If you are experiencing a similar issue, please ask a related question
604
2,090
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.59375
3
CC-MAIN-2017-09
longest
en
0.801118
https://www.gamedev.net/forums/topic/569246-matrix-operator/
1,529,950,291,000,000,000
text/html
crawl-data/CC-MAIN-2018-26/segments/1529267868237.89/warc/CC-MAIN-20180625170045-20180625190045-00151.warc.gz
801,193,089
27,191
# Matrix operator... This topic is 2983 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic. ## Recommended Posts Hi I seemed to have an error in and old code i digged up. The error was related to the matrix class operator* and some confusion in which order the operators argument comes into the function. Soo please validate what is the correct order of arguments to a operator when doing matrix multiplication. for example consider a*b; Is "this" the left-side (a), and m the right-side (b) according to the function? In my previous code I had to reverse the order in MatrixMultiply, that is exchange arguments this.ref() and m.ref(). So either I didn't understand which arguments was left-/right-side in the operator or the multiply function was wrong. If this function below is correct, then the multiply was originally wrong. Matrix Matrix::operator*(Matrix &m) { Matrix tmp; MatrixMultiply(tmp.ref(), this->ref(), m.ref()); return tmp; } ##### Share on other sites Row-major matrices used by DirectX produces results equal to the left operand followed by the right operand. Column-major matrices used by OpenGL produce results equal to the right operand followed by the left operand. There is no right or wrong answer. You have mixed up the major-ness of your matrices. Pick one and stick with it. L. Spiro ##### Share on other sites The result of a matrix multiplication A * B is mathematically defined in explicit terms. You should ever implement the operator w.r.t. that definition, or else confusion will emerge! You should further implement it as non-member function. Because matrix multiplication isn't commutative, you'll probably come to cases where you don't want to distinct "on the left" or "on the right" (what would simply be possible with operator*) but "on the local side" or "on the global side". Now, here comes the problem of column vs. row vectors into play EDIT, as already mentioned by YogurtEmperor/EDIT. To avoid any confusion, it would IMHO be best to implement 2 non-member functions that explicitely express their behaviour in their names, e.g. inline Matrix mulWithLocal( Matrix const& matrix, Matrix const& local ); inline Matrix mulWithGlobal( Matrix const& matrix, Matrix const& global ); (Made them inlined to avoid performance penalties.) Then implement the both helper routines w.r.t. the vector convention of your choice utilizing the operator*. The only issue with the solution above is IMHO that it needs more typing than a simple *. Just my 2 €-Cent. [Edited by - haegarr on April 24, 2010 10:43:24 AM] ##### Share on other sites Quote: Original post by haegarrNow, here comes the problem of column vs. row vectors into play, as already mentioned by YogurtEmperor. YogurtEmperor was actually referring to matrix majorness (a different issue). Quote: Original post by YogurtEmperorRow-major matrices used by DirectX produces results equal to the left operand followed by the right operand.Column-major matrices used by OpenGL produce results equal to the right operand followed by the left operand. It sounds like you might be confusing matrix 'majorness' with vector notation convention. When you say (e.g.) 'equal to the left operand followed by the right operand', I assume you mean that the resulting transform is equal to the transform represented by the matrix on the left, followed by the transform represented by the matrix on the right (as would be the case in DirectX). However, this doesn't have anything to do with matrix majorness; rather, it has to do with whether row vectors or column vectors are being used. In any case, this shouldn't have any impact on how the '*' operator is implemented for matrices; matrix multiplication is defined the same way (and should be implemented the same way) regardless of what vector notation convention is being used. ##### Share on other sites Quote: Original post by jyk Quote: Original post by haegarrNow, here comes the problem of column vs. row vectors into play, as already mentioned by YogurtEmperor. YogurtEmperor was actually referring to matrix majorness (a different issue). Uhh, I've read it in a hurry. You're right, of course. However, Quote: Original post by jykIn any case, this shouldn't have any impact on how the '*' operator is implemented for matrices; matrix multiplication is defined the same way (and should be implemented the same way) regardless of what vector notation convention is being used. is nevertheless exactly what I meant :) ##### Share on other sites A good way to keep track of this is to wrap your multiplication routine in another named member function, such as Concatenate. Let this function take care of the funny business of matrix multiplication order. This way client code need only worry about which transform should be concatenated, and not the (somewhat arbitrary) way in which this is accomplished. ##### Share on other sites Quote: for example consider a*b;Is "this" the left-side (a), and m the right-side (b)according to the function? Yes for all operators. a * b is the equivalent of a.operator*(b), so "this" is the left hand side, and the parameter is the right hand side. ##### Share on other sites Quote: Original post by taz0010 Quote: for example consider a*b;Is "this" the left-side (a), and m the right-side (b)according to the function? Yes for all operators. a * b is the equivalent of a.operator*(b), so "this" is the left hand side, and the parameter is the right hand side. As I suspected, I just forgot the logic around the operators and became unsure whatever was right soo thank you all! It's been 10 years since I worked with software development before I completely quit coding soo these little things are easy to forget. My old library routine for matrix multiplication was indeed in the incorrect order, it calculated B*A when it should have calculated A*B (I never tested them when I wrote them a long time ago since I used a sdk at the time). Once again, thank you all for your help! 1. 1 2. 2 Rutin 19 3. 3 4. 4 5. 5 • 15 • 13 • 9 • 12 • 10 • ### Forum Statistics • Total Topics 631442 • Total Posts 3000087 ×
1,383
6,161
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.640625
3
CC-MAIN-2018-26
latest
en
0.916107
https://casioeducation.com.au/teacher-resources/category/how-to-classpad-cas/
1,627,702,371,000,000,000
text/html
crawl-data/CC-MAIN-2021-31/segments/1627046154042.23/warc/CC-MAIN-20210731011529-20210731041529-00630.warc.gz
174,079,505
27,204
• Clear Filters CP240 Restrict Range Of Solutions With Trig Equations Two methods to restrict the range of solutions returned when solving trig equations in Main. Year Level: State: , , CP250 Solve System Of Equations With 3 Unknowns Use one of the 2D templates to solve systems of equations with 2 or more variables. Year Level: State: , , CP350 Using Sliders To Explore Functions How to use sliders in graph and table to explore function transformations. Year Level: State: , , CP172 Inverse Of A Function Find the inverse of a function algebraically using invert and also view the inverse graphically. Year Level: State: , , CP205 Solving Simultaneous Linear Equations 1 Solve simultaneously the equations 2x – 3y = -1 and x + y = 7 using a traditional step by step elimination method in Main. Year Level: State: , , How to update the operating system of your hand-held ClassPad using a Windows PC. CP011 Simplifying and Expanding Collect like terms and expand and simplify expressions such as 3(4-2x)^2. CP012 Factorising Factorisation of numbers and expressions (eg quadratics) CP041 Sequence: What Is My Rule? Use the sequence function in Main to find the defining rule for various sequences
280
1,219
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.03125
3
CC-MAIN-2021-31
longest
en
0.825737
https://books.google.gr/books?id=sX8AAAAAMAAJ&hl=el&lr=
1,590,935,622,000,000,000
text/html
crawl-data/CC-MAIN-2020-24/segments/1590347413406.70/warc/CC-MAIN-20200531120339-20200531150339-00416.warc.gz
279,106,345
12,197
# New School Algebra Ginn & Company, 1898 - 407 σελίδες ### Τι λένε οι χρήστες -Σύνταξη κριτικής Δεν εντοπίσαμε κριτικές στις συνήθεις τοποθεσίες. ### Περιεχόμενα Fractions 123 Fractional Equations 148 Simultaneous Simple Equations 174 Problems with Two or More Unknown Numbers 190 Simple Indeterminate Equations 205 XrV Inequalities 208 Variables and Limits 338 XXrV Properties of Series 345 Binomial Theorem 352 Logarithms 372 Graphs 409 Πνευματικά δικαιώματα ### Δημοφιλή αποσπάσματα Σελίδα 276 - There are four numbers in geometrical progression, the second of which is less than the fourth by 24 ; and the sum of the extremes is to the sum of the means, as 7 to 3. What are the numbers ? Ans. Σελίδα 252 - If the product of two quantities is equal to the product of two others, either two may be made the extremes of a proportion and the other two the means. For, if ad = be, then, divide by bd. Σελίδα 316 - If the number is less than 1, make the characteristic of the logarithm negative, and one unit more than the number of zeros between the decimal point and the first significant figure of the given number. Σελίδα 244 - If twelve times the units' digit is subtracted from the number, the order of the digits will be reversed. Find the number. Σελίδα 25 - Two men start from the same place and travel in the same direction, one 30 miles a day, and the other 20 miles a day. Σελίδα 118 - To reduce a fraction to its lowest terms. A fraction is in its lowest terms, when the numerator and denominator are prime to each other. Σελίδα 56 - To Multiply a Polynomial by a Monomial, Multiply each term of the polynomial by the monomial, and connect the partial products with their proper signs. Σελίδα 263 - The distance a body falls from rest varies as the square of the time it is falling. Σελίδα 254 - In a Series of Equal Ratios, the sum of the antecedents is to the sum of the consequents as any antecedent is to its consequent. Σελίδα 276 - Of three numbers in geometrical progression, the sum of the first and second exceeds the third by 3, and the sum of the first and third exceeds the second by 21.
556
2,120
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.78125
4
CC-MAIN-2020-24
latest
en
0.727829
https://www.hackmath.net/en/math-problem/2609
1,624,306,607,000,000,000
text/html
crawl-data/CC-MAIN-2021-25/segments/1623488289268.76/warc/CC-MAIN-20210621181810-20210621211810-00108.warc.gz
724,587,808
11,644
# Bricks II 3/4 bricks weighs 6 kg and 2/3 bricks. How weighs one whole brick? x =  72 kg ### Step-by-step explanation: 3/4x = 6+ 2/3 x 3/4•x = 6+ 2/3•x x = 72 Our simple equation calculator calculates it. Did you find an error or inaccuracy? Feel free to write us. Thank you! Tips to related online calculators Do you have a linear equation or system of equations and looking for its solution? Or do you have a quadratic equation? ## Related math problems and questions: • Brick weight The brick weighs 2 kg and a half bricks. How much does one brick weigh? • Two bricks One brick weighs 1kg and half a brick, how many weigh two bricks? • Bricks Openings in perforated bricks occupy 10% and brick has dimensions 30 cm, 15 cm and 7.5 cm. Calculate a) the weight of a perforated bricks, if you know that the density of the full brick material is p = 1800 kg/m3 (1.8 kg/dm3) b) the number of perforated • Brick Brick weight before drying is 5.3 kg. After drying, the bricks is 1 kg lighter and after firing is 0.7 kg lighter than after drying. What is the weight of the brick after drying and firing? • Bag Nelly found interesting point. An empty bag weighs 4 kg less than full. And empty bag is 5 times easier than full. How many kg weigh things in this bag? • Bob and Bobek Bobek has 2 cabbages and 5 carrots, Bob has 2 cabbages and 9 carrots. When Bobek stepped on the scale weight 5800 g and when Bob weight 8960 g. Actual Bob weight is 8 kg and Bobek 5 kg. How much weighs one carrot? • Can Watering can full of water weighs 10 kg. Half-full can weighs 5.5 kg. How much weigh can? • Brick Isosceles scale has on one side all brick and second weight 1 kg and 1/4 of brick. The balance is in equilibrium. What is the weight of a brick? • Cooks Four cooks cleaned 5 kg of potatoes for 10 minutes. How many cook would have to work clean 9 kg of potatoes for 12 minutes? • Children Margaret and Zdena weigh the same and Petra 3 kg more. Together weigh 156 kg. How much do they weigh? • Apples 5 In six crates are 45 kg of apples. In five crates were the same amount and in one crate was 3 kg of apples more. How many kg of apples were in each crate? • Apples Mr. Vesely give to the market his own 48 kg of apples, 40 kg from Mr. Kovar and 72 kg of Mr. Novak. Grossed a total of 1,920 CZK. How must divide income money for apples? • Milk2cheese From 40 liters of milk is produced 8 kg of cheese how many liters of milk are needed to produce 2 kg of cheese? • DIY press Under socialism regime was in some socialist countries to own a typewriter requires special permission. That has hindered the spread of DIY literature (manually transcribed through carbon copy paper for typewriters). Calculate how many typewriters today c • Watering can A watering can full of water weighs 11 kg, the weight of water is 10 kg greater than the weight of an empty watering can, how much is the weight of the watering can? • Water container Container with water weighs 1.48 kg. When we cast 75% of water container of water weight 0.73 kg. How heavy is an empty container? • Warehouses To four warehouses is going cement in 25 kg bags. To first one third, to second quarter of the total. The third store got two thirds of the rest, and the last 310 tons came to fourth. How many cement is in all warehouses and how much got every one?
896
3,324
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.90625
4
CC-MAIN-2021-25
longest
en
0.929229
https://redkiwiapp.com/en/english-guide/words/elementary
1,709,556,985,000,000,000
text/html
crawl-data/CC-MAIN-2024-10/segments/1707947476442.30/warc/CC-MAIN-20240304101406-20240304131406-00884.warc.gz
461,568,333
19,900
# elementary [ˌelɪˈmɛntəri] ## elementary Definition • 1relating to the first stages of something; basic and fundamental • 2relating to or denoting the basic, essential, or fundamental part of something ## Using elementary: Examples Take a moment to familiarize yourself with how "elementary" can be used in various situations through the following examples! • Example The book provides an elementary introduction to quantum mechanics. • Example The teacher gave us an elementary explanation of the concept. • Example The course covers elementary algebra and geometry. • Example The experiment involves elementary particles. ## Phrases with elementary • ### elementaryschool a school for young children, typically those aged between five and eleven Example I went to an elementary school in my hometown. • ### elementaryparticle a subatomic particle that cannot be broken down into smaller particles Example The Higgs boson is an elementary particle. • ### elementaryalgebra the branch of mathematics that deals with equations and algebraic structures in which both operands are numbers Example The course covers elementary algebra and geometry. ## Origins of elementary from Latin 'elementarius', from 'elementum' meaning 'principle' 📌 ## Summary: elementary in Brief The term 'elementary' [ˌelɪˈmɛntəri] refers to the first stages of something, or the basic and fundamental part of something. It can describe a simple or rudimentary explanation or introduction, as in 'The teacher gave us an elementary explanation of the concept.' It also extends to fields like mathematics, where 'elementary algebra' is a basic branch of study. How do native speakers use this expression? Oncheon-ro 45, Yuseong Prugio City unit. 208. Yuseong-gu, Daejeon
391
1,775
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.71875
3
CC-MAIN-2024-10
latest
en
0.873584
https://exercism.io/tracks/objective-c/exercises/sum-of-multiples/solutions/01ad754a46b04e2d96c59754af2a141e
1,627,680,162,000,000,000
text/html
crawl-data/CC-MAIN-2021-31/segments/1627046153980.55/warc/CC-MAIN-20210730185206-20210730215206-00494.warc.gz
253,910,139
6,548
# lockheedbird's solution ## to Sum Of Multiples in the Objective-C Track Published at Jan 13 2019 · 0 comments Instructions Test suite Solution Given a number, find the sum of all the unique multiples of particular numbers up to but not including that number. If we list all the natural numbers below 20 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12, 15, and 18. The sum of these multiples is 78. ## Setup There are two different methods of getting set up to run the tests with Objective-C: • Create an Xcode project with a test target which will run the tests. • Use the ruby gem `objc` as a test runner utility. Both are described in more detail here: http://exercism.io/languages/objective-c ### Submitting Exercises When submitting an exercise, make sure your solution file is in the same directory as the test code. The submit command will look something like: ``````exercism submit <path-to-exercism-workspace>/objective-c/sum-of-multiples/SumOfMultiples.m `````` You can find the Exercism workspace by running `exercism debug` and looking for the line beginning with Workspace. ## Source A variation on Problem 1 at Project Euler http://projecteuler.net/problem=1 ## Submitting Incomplete Solutions It's possible to submit an incomplete solution so you can see how others have completed the exercise. ### SumOfMultiplesTest.m ``````#import <XCTest/XCTest.h> #if __has_include("SumOfMultiplesExample.h") # import "SumOfMultiplesExample.h" # else # import "SumOfMultiples.h" #endif @interface SumOfMultiplesTest : XCTestCase @end @implementation SumOfMultiplesTest - (void)testSumTo1 { NSNumber *sum = [SumOfMultiples toLimit:@1 inMultiples:@[@3, @5]]; XCTAssertEqualObjects(@0, sum); } - (void)testSumTo3 { NSNumber *sum = [SumOfMultiples toLimit:@4 inMultiples:@[@3, @5]]; XCTAssertEqualObjects(@3, sum); } - (void)testSumTo10 { NSNumber *sum = [SumOfMultiples toLimit:@10 inMultiples:@[@3, @5]]; XCTAssertEqualObjects(@23, sum); } - (void)testSumTo100 { NSNumber *sum = [SumOfMultiples toLimit:@100 inMultiples:@[@3, @5]]; XCTAssertEqualObjects(@2318, sum); } - (void)testSumTo1000 { NSNumber *sum = [SumOfMultiples toLimit:@1000 inMultiples:@[@3, @5]]; XCTAssertEqualObjects(@233168, sum); } - (void)testConfigurable_7_13_17_to_20 { NSNumber *sum = [SumOfMultiples toLimit:@20 inMultiples:@[@7, @13, @17]]; XCTAssertEqualObjects(@51, sum); } - (void)testConfigurable_4_6_to_15 { NSNumber *sum = [SumOfMultiples toLimit:@15 inMultiples:@[@4, @6]]; XCTAssertEqualObjects(@30, sum); } - (void)testConfigurable_5_6_8_to_150 { NSNumber *sum = [SumOfMultiples toLimit:@150 inMultiples:@[@5, @6, @8]]; XCTAssertEqualObjects(@4419, sum); } - (void)testConfigurable_43_47_to_10000 { NSNumber *sum = [SumOfMultiples toLimit:@10000 inMultiples:@[@43, @47]]; XCTAssertEqualObjects(@2203160, sum); } - (void)testConfigurable_0_to_10 { NSNumber *sum = [SumOfMultiples toLimit:@10 inMultiples:@[@0]]; XCTAssertEqualObjects(@0, sum); } - (void)testConfigurable_0_1_to_10 { NSNumber *sum = [SumOfMultiples toLimit:@10 inMultiples:@[@0, @1]]; XCTAssertEqualObjects(@45, sum); } @end`````` ``````#import "SumOfMultiples.h" @implementation SumOfMultiples + (NSNumber *)toLimit:(NSNumber*)limit inMultiples:(NSArray *)multiples { NSNumber *sum = @0; NSMutableSet *setOfNumbers = [NSMutableSet setWithObject:@0]; for (int i = 0; i < limit.intValue; i++) { for (NSNumber *n in multiples) { if (n.integerValue > 0 && i % n.integerValue == 0) { } } } for (NSNumber *n in setOfNumbers) { sum = @(sum.integerValue + n.integerValue); } return sum; } @end``````
1,059
3,593
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.34375
3
CC-MAIN-2021-31
latest
en
0.732571
https://forum.awesystems.info/t/wacky-wave-kite-power-idea/2643
1,708,968,530,000,000,000
text/html
crawl-data/CC-MAIN-2024-10/segments/1707947474661.10/warc/CC-MAIN-20240226162136-20240226192136-00659.warc.gz
275,088,116
7,601
# Wacky Wave Kite Power Idea I was thinking about wave power and AWE today. How to extract the energy of a wave using a kite. I based the idea on a bounding one kite one tether base. Then look at the flow in a wave. https://www.acs.psu.edu/drussell/demos/waves/wavemotion.html Now look the current at the crest of the wave is heading with the wave, the bough towards offshore. The kite should fly (under water) along the crest of the wave pulling towards shore then turn 180 degrees and follow the trough back towards the origin, pulling towards offshore. The sketch shows the basics. We have two winches [purple], one for crest production and one for trough production. Crest production path is colored green, trough red, and the yellow part is a return phase to account for net movement «downwind» during the production cycle. The kite is the black one, tethered to both winches at the same time I think its a neat idea [I say, patting my own sholder]. Problems is one that the kite must fit in the wave so the wing area is naturally limited. So the concept would require many smaller units coupled together to get big net power output. I would naturally see many kites stacked on a single tether. But if we do that, its hard to align them all with the crest. I am also like for most wave power just not dealing with such a nimble machinery running underwater for an extended duration. Also, the kite must be placed carefully just beneath the surface of the sea. The kite must be placed carefully at the crest and trough, and the system must be able to find these and place the kite there in time. And account for a waves irregular shape (at least here in norway). Except for those solvable details, this should power thousands of homes. 1 Like Could this be some kind of tethered underwater variation of dynamic soaring flight mode? If we look closely at the moving diagram, we see that the kite would always be close to the surface, and would follow the movement of the wave. This is why a partially submerged float filled with water would seem simpler and more appropriate to me, not subject to such dimensional limitations and being able to form a single power unit. I think not being a float would be the primary improvement in the design, as the float will perish in the first storm Floating buoys (like the one below) follow the motion of the waves, and are very robust even during storms and big waves. And I don’t see the usefulness of kites which must only follow the flow and not “fly” in relation to said flow. Double anchoring with the respective winches would be possible with a model like this: The idea I suggested had the kites flying? Yes, as mentioned in the description (see the quote below). And generally kites fly, in the air or underwater, in static or crosswind mode. I don’t see the usefulness of kites for this configuration. Floating buoys are suitable, if of course this scheme is other than “wacky”. The problem is that at sea even more than in air [well maybe] condition in fair and bad weather vary a lot. In particular, if the waves grow big enough to break, you dont want a floating structure in there. Being close to the surface could be achieved through sensors and active control. An additional problem with a floating kite at the surface is the drag it may cause, in particular by waves created on water, and due to disturbances on the water surface and wind. I think though my initial sketch was misleading, so let me try to improve on it A farm could look like this I think about it sometimes, but never going further into design considerations. Do you know the wave glider ? The Wave Glider | How It Works 1 Like I guess this idea is not too far from home for you at Syroco. Especially if the winches were placed above sea level which could be a good idea if tether drag was an issue. I think we discussed this earlier, that subsea tethers are much more succeptible to tether drag issues, as you have more force for the same wing area, but you cant increase the strength of the tether without increasing the diameter.
902
4,103
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.71875
3
CC-MAIN-2024-10
latest
en
0.947913
https://www.johnlearn.com/p/brahmagupta-was-astronomer-and-an-indian-mathematician-the-son-of-jishnugupta
1,553,097,546,000,000,000
text/html
crawl-data/CC-MAIN-2019-13/segments/1552912202433.77/warc/CC-MAIN-20190320150106-20190320172106-00434.warc.gz
797,082,505
12,039
Indian mathematician Mathematics Astronomy Scholars Topics Astronomer Multiplication # Brahmagupta was astronomer and an Indian mathematician, the son of Jishnugupta Brahmagupta describes the multiplication found the result gives, natural numbers does not explicitly state that these quadrilaterals, uses. Brahmagupta is encoded mostly in concrete-number notation, enumerates six first sine-values made in astronomy by Brahmagupta, discusses the illumination of the moon by the sun, believed in a static Earth. Bhillamala called pi-lo-mo-lo by Xuanzang, was for astronomy and mathematics. Critiques of rival theories appear throughout the eleventh chapter and the ten first astronomical chapters. The court of Caliph Al-Mansur received an embassy from Sindh. An immediate outcome was the spread of the decimal number system. The mathematician Al-Khwarizmi wrote a text, al-Jam wal-tafriq bi hisal-al-Hind. Indian astronomic material circulated widely for centuries. The the middle square-root of the rupas multiplied by the square by four times. Addition was indicated by subtraction by juxtaposition. Multiplication were represented by abbreviations of appropriate terms. The four fundamental operations were known before Brahmagupta to many cultures. This current system is based on Arabic number system on the Hindu. Brahmasphutasiddhanta was named Gomutrika contains twenty-five chapters. The procedures are followed for five types of combinations by rules. A positive number and Zero is negative number and the positive number divided by zero. One theorem gives the lengths of the two segments, a triangle's base. The Thus lengths of the two segments gives further a theorem on rational triangles. The square of the diagonal is diminished by the square. The geometry of plane figures discusses the computation of volumes. The next formula gives an estimate for the value of a function. Progenitors represents the 14 Progenitors in Indian cosmology. The same way seen in sunlight by the sun of a pot standing. The brightness is increased in the direction of the sun. The key have only 150 staff, 're dedicated to reader privacy, accept never ads. Undergraduate students studying the history of mathematics for secondary education and engineering for science. George Gheverghese Joseph takes on a breathtaking multicultural tour of the roots, shows the deep influence that Babylonians and the Egyptians. The third edition emphasizes the dialogue between civilizations, includes new chapters. The book's scope is now even wider recent findings, an also indispensable guide for mathematics teachers. The authors have written also substantial section introductions. The mathematics literature is an essential resource with at an least undergraduate degree for anyone. Imhausen mentioned algorithmic aspects of certain calculations. The AWT set of theoretical facts was mentioned not in &39; s book in Katz. One side of the hekat unity division method was proven by a Charles U. by Hana Vymazalova. A new interdisciplinary standard is rescuing the Egyptian hieratic texts. A debt subtracted from zero, multiplied by fortune and a debt. Majumdar gives the original Sanskrit verses from Brahmagupta's Brahmasphuta siddhanta. The Khandakhadyaka is in eight chapters, contains an appendix. Previous article Next article
676
3,321
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.734375
3
CC-MAIN-2019-13
latest
en
0.936093
http://auto.howstuffworks.com/auto-parts/towing/towing-capacity/information/truck-tow-ten-thousand-pounds.htm
1,503,522,915,000,000,000
text/html
crawl-data/CC-MAIN-2017-34/segments/1502886124563.93/warc/CC-MAIN-20170823210143-20170823230143-00241.warc.gz
35,995,724
17,548
# How can a 5,000-pound truck tow 10,000 pounds? Wait, doesn't that defy physics? Nope. Tim McCaig/iStockPhoto Have you ever watched in amazement as a pickup truck tows a huge load of bricks? If you thought, "Wow, that defies the laws of physics!" you would be wrong. Believe it or not, the laws of physics (or more specifically, the laws of motion) actually allow a 5,000-pound (2,268 kilogram) truck to tow a 10,000-pound (4,536 kg) load. It's part of the interplay between the energy exerted by the truck's engine and the forces of gravity. This is no small feat, however; if you remember Newton's Third Law of Motion, you know that from the moment your truck begins to move, there are forces that oppose it every step of the way. If you understand the physics of driving, you understand the physics of towing. There's actually a fairly simple way to look at the process. There are three states that your truck can enter when it comes to driving and towing: rest, acceleration and constant velocity. When your truck's transmission is in park and your truck is motionless, it's considered at rest. The gravitational push downward toward the center of the earth and the upward push from the earth (called normal force) oppose one another to keep your truck at rest. Your truck will stay put -- after all, an object at rest tends to stay at rest. But you don't want to rest, you want to tow. This means you have to overcome this tendency to rest through applied force. Fortunately for you, your truck has an engine that can produce energy, which serves as the applied force required to get you moving. While the opposing normal and gravitational forces still remain, to accelerate you're going to have to deal with the forces of friction. Rather than up and down, these forces exist parallel to the ground, and push in the opposite direction of the way you want to move. You can't catch a break physics-wise, can you? With us so far? Good. Keep reading to learn more about the physics of towing.
453
2,002
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.515625
4
CC-MAIN-2017-34
latest
en
0.974163
https://www.nitrc.org/forum/message.php?msg_id=32513
1,632,253,974,000,000,000
text/html
crawl-data/CC-MAIN-2021-39/segments/1631780057227.73/warc/CC-MAIN-20210921191451-20210921221451-00070.warc.gz
936,068,877
10,594
open-discussion > The second temporal derivative of HRF in estimating the "amplitude of effects" Apr 28, 2021  04:04 AM | Gao F - central south university The second temporal derivative of HRF in estimating the "amplitude of effects" In the paper 'BASCO: a toolbox for task-related functional connectivity', estimation of the "amplitude of effects" is proposed as: β = sign(β1) * sqrt(β1^2 + β2^2 + β3^2), where, the first beta-value relates to the canonical HRF, the second and third beta-values relate to the first and second temporal derivative, respectively. I was wondering how to set or create the [color=#ff0000]β3. Then I check the BASCO.m, where in the 1270 to 1272[/color] lines  of the script, it is commented: % Estimating the "amplitude" of the effects at each voxel = sign(V1).*sqrt(V1.^2+V2.^2) % where V1 is the canonical effect contrast volume, and V2 is the temporal derivative % effect contrast volume. [Calhoun (2004)] [color=#ff0000]β3 seems not included in the [/color]formula in the comment, and in the following line 1282 of the script: datmat = sign(datmatA).*sqrt(datmatA.^2+datmatB.^2+datmatC.^2) [color=#ff0000] [/color] The 'datmatC' seems corresponding to 'β3', but it more likely a disperion derivatives while not the second temporal derivative. My question is, in which way the BASCO estimating the "amplitude of effects", and by which way the second temporal derivative of HRF could be used, or if I have just misunderstood the script? [color=#ff0000] [/color]
412
1,496
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.671875
3
CC-MAIN-2021-39
latest
en
0.823398
https://www.vedantu.com/question-answer/6-balls-are-marked-with-numbers-1-to-6-if-two-class-11-maths-cbse-60a63c56d13f1000c94a4718
1,721,735,107,000,000,000
text/html
crawl-data/CC-MAIN-2024-30/segments/1720763518029.87/warc/CC-MAIN-20240723102757-20240723132757-00554.warc.gz
865,491,012
28,185
Courses Courses for Kids Free study material Offline Centres More Store # 6 balls are marked with numbers $1$ to $6$. If two balls are picked out of these $6$ balls, what is the probability that the sum of the numbers on the balls is $8$?A. 1/15B. 2/15C. 1/5D. 4/15E. 1/3 Last updated date: 23rd Jul 2024 Total views: 349.2k Views today: 4.49k Verified 349.2k+ views Hint: To find the required probability, we need to find the total number of outcomes and favorable number of outcomes first. Then, we will use the formula of probability that is $\text{Probability}=\dfrac{\text{Number of favorable outcomes}}{\text{Total number of outcomes}}$ and substitute the obtained value of favorable number of outcomes and total number of outcomes. After simplifying it, we will get the probability that the sum of the numbers on the ball is $8$ when two balls are picked. Complete step-by-step solution: Since, the order is not important for selection of balls. So we will use the formula of combination to get the total number of outcomes as: $\Rightarrow {}^{n}{{C}_{r}}=\dfrac{n!}{r!\centerdot \left( n-r \right)!}$ Where, $n$ is the total number of objects and $r$ is the number of objects chosen. Now, we will substitute $6$ for $n$ and $2$ for $r$in the above formula. $\Rightarrow {}^{6}{{C}_{2}}=\dfrac{6!}{2!\centerdot \left( 6-2 \right)!}$ Solve the terms within the bracket. $\Rightarrow {}^{6}{{C}_{2}}=\dfrac{6!}{2!\centerdot \left( 4 \right)!}$ We can write $15!$ as: $\Rightarrow {}^{6}{{C}_{2}}=\dfrac{6\centerdot 5\centerdot 4!}{2!\centerdot \left( 4 \right)!}$ Here, we will cancel out the equal like terms and will expand the factorial terms as: $\Rightarrow {}^{6}{{C}_{2}}=\dfrac{6\centerdot 5}{1\centerdot 2}$ Now, we will complete the multiplication in numerator and denominator as: $\Rightarrow {}^{6}{{C}_{2}}=\dfrac{30}{2}$ After simplifying the above step, we will have: $\Rightarrow {}^{6}{{C}_{2}}=15$ Since, there are only two combinations that sum is $8$(2,6),(3,5). So, the number of favorable outcomes is $2$. Now, we will use the formula of probability to get the required probability as: $\text{Probability}=\dfrac{\text{Number of favorable outcomes}}{\text{Total number of outcomes}}$ Here, we will substitute the respective values as: $\text{Probability}=\dfrac{\text{2}}{\text{15}}$ Hence, $\dfrac{\text{2}}{\text{15}}$ is the required probability that the sum of the numbers on the balls is$8$. Note: Here a term is given as picking up the balls that means we have to select the balls and we use the combination for selection of objects. Combination is the possible number of outcomes of selecting objects where order doesn’t matter. The formula used for calculation of number of combination is: $\Rightarrow {}^{n}{{C}_{r}}=\dfrac{n!}{r!\centerdot \left( n-r \right)!}$ Where, $n\ge r$ and $n$ is the total number of objects and $r$ is the number of objects chosen.
839
2,900
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 2, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
4.96875
5
CC-MAIN-2024-30
latest
en
0.790416
https://physicshelpforum.com/threads/converting-density-to-molecular-weight.15421/
1,580,122,855,000,000,000
text/html
crawl-data/CC-MAIN-2020-05/segments/1579251696046.73/warc/CC-MAIN-20200127081933-20200127111933-00369.warc.gz
595,539,415
18,761
Converting Density to Molecular Weight Dragonrider99 Greetings all. I am currently in the midst of a Final Acceptance Testing for one of our customers that is purchasing some Density Meters. Physics is not my strong point as I am a Test Engineer and I desperately need some help. Our product is spec'd out such that it reports Density, Pressure, Current, and several other measurements but it does not report Molecular Weight. This customer is insisting on my telling him how to convert the Density Measurement to Molecular Weight and I am not sure. Basically the product is pressurized with Lab Grade Nitrogen and it detects Density via a change in frequency due to compression of a spool. Anyway, I found this formula for converting Molecular Weight to Density: p=PM/RT where p=Density P=Pressure in Pascals M=Molecular Weight R=Universal Gas Constant T=Temp in Kelvin Re-arranging the formula I get: M=pRT/P My Values are: p=8.65Kg.m3 P=786000 pascals R=8.134j/mol*K T=305.15 Kelvin After doing the math I get 0.027Kg/mol Is this correct or am I totally wrong? Thanks benit13 Caveat... I will accept no blame if something goes wrong! Now that that's out of the way... The only mistake seems to be your choice of value for the real gas constant; it's 8.314 J/(mol.kg) Assuming an ideal gas: $$\displaystyle PV = nRT$$ Since: $$\displaystyle \rho = \frac{M}{V}$$ Substituting for V: $$\displaystyle P\frac{M}{\rho} = nRT$$ $$\displaystyle \frac{M}{n} = \mu = \frac{\rho}{P}RT$$ $$\displaystyle \mu = \frac{8.65 * 8.314 * 305.15}{786000} = 0.02792$$ kg/mol = 27.92 g/mol Carbon monoxide perhaps? 1. Make sure your real gas constant is correct (R = 8.314 J/(mol.K), not 8.134) 2. Make your customer aware that your measurement is a derived parameter using an equation that assumes an ideal gas. Last edited: 1 person Woody I am not sure what your customer is actually after. The molecular weight is a constant which depends only on the material. It is the weight (or more correctly Mass) of 1 Mole of the molecules of the material (1 mole is a big number = about 6x10^23) It allows one to estimate the number of molecules in a sample from its weight (mass) rather than by physically counting molecules (which is time consuming). The standard atomic mass for Nitrogen is 0.014kg/mol however you have Nitrogen gas, thus N2 giving molecular mass of 0.028kg/mol I think that is fairly close to what you have calculated... Last edited: Woody What the customer wants. Thinking about it, knowing the molecular mass of the gas being processed can tell you a fair amount about it. For example your pure dry nitrogen gave a very close result to the book value. However if it was contaminated (damp for example) the molecular mass would have been off. Water with a molecular mass of 18grams/mole would raise the overall molecular mass of the mix. Perhaps your customer wants to monitor a process to ensure that the (combined) molecular weights of the products remains within tolerable boundaries. Benit's point about an ideal gas is pertinent. Complex mixes, and complex molecules are less likely to match the theoretical "ideal" gas. Have a look at the Wikipedia article linked here: <Ideal Gas> If your customer wants to monitor a process (ensuring it does not change), then relative accuracy might be more important than absolute accuracy. Last edited: 1 person Dragonrider99 You guys are great! Thanks so much. Your comment about if there is another gas or substance in the mix hits home because otherwise I can't figure out for the life of me why they want that. Based on the data I have taken at various pressures and densities, the Molecular Weight always comes out to the "Book Value." If there IS another substance such as Water contaminating the gas, is there any way to determine the concentrations of each based on the calculated Molecular Weight based on the other measured parameters? Not sure if I phrased that correctly but I hope you get the gist of what I mean. Otherwise thanks to all of you that have responded. I truly appreciate your help and inputs. Woody Contaminants If you have a clear idea of what the molecular mass of the "clean" gas is and a clear idea of what the contaminant might be, and what it's molecular mass is, then you can start to get quantitative estimates of the level of contamination. However if you just have an unknown contaminant, all you can get is a qualitative estimate of the level of contamination (i.e. you don't know how much contaminant is there, but you do know if it gets better or worse). donglebox Referring to common practices, If he needs a careful but easy-to-use quick-check manual, or reads out the transformation software tools according to the conditions, You can sell this as an additional item. After all, this has expanded the use of the device. It belongs to advanced tools.
1,162
4,881
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.703125
4
CC-MAIN-2020-05
latest
en
0.893476
https://rosettagit.org/drafts/sort-an-integer-array/
1,716,176,322,000,000,000
text/html
crawl-data/CC-MAIN-2024-22/segments/1715971058147.77/warc/CC-MAIN-20240520015105-20240520045105-00138.warc.gz
458,589,357
28,108
⚠️ Warning: This is a draft ⚠️ This means it might contain formatting issues, incorrect code, conceptual problems, or other severe issues. If you want to help to improve and eventually enable this page, please fork RosettaGit's repository and open a merge request on GitHub. {{task|Sorting}} Sort an array (or list) of integers in ascending numerical order. ;Task: Use a sorting facility provided by the language/library if possible. ## 4D ### English ```ARRAY INTEGER(\$nums;0) APPEND TO ARRAY(\$nums;2) APPEND TO ARRAY(\$nums;4) APPEND TO ARRAY(\$nums;3) APPEND TO ARRAY(\$nums;1) APPEND TO ARRAY(\$nums;2) SORT ARRAY(\$nums) ` sort in ascending order SORT ARRAY(\$nums;<) ` sort in descending order ``` ===Français=== ```TABLEAU ENTIER(\$nombres;0) AJOUTER A TABLEAU(\$nombres;2) AJOUTER A TABLEAU(\$nombres;4) AJOUTER A TABLEAU(\$nombres;3) AJOUTER A TABLEAU(\$nombres;1) AJOUTER A TABLEAU(\$nombres;2) TRIER TABLEAU(\$nombres) ` pour effectuer un tri par ordre croissant TRIER TABLEAU(\$nombres;<) ` pour effectuer un tri par ordre décroissant ``` ## 8th ``` [ 10,2,100 ] ' n:cmp a:sort . cr ``` Output is: [2,10,100] ## ActionScript ```//Comparison function must returns Numbers even though it deals with integers. function compare(x:int, y:int):Number { return Number(x-y); } var nums:Vector.<int> = Vector.<int>([5,12,3,612,31,523,1,234,2]); nums.sort(compare); ``` {{works with|GNAT|GPL 2006}} ```with Gnat.Heap_Sort_G; procedure Integer_Sort is -- Heap sort package requires data to be in index values starting at -- 1 while index value 0 is used as temporary storage type Int_Array is array(Natural range <>) of Integer; Values : Int_Array := (0,1,8,2,7,3,6,4,5); -- define move and less than subprograms for use by the heap sort package procedure Move_Int(From : Natural; To : Natural) is begin Values(To) := Values(From); end Move_Int; function Lt_Int(Left, Right : Natural) return Boolean is begin return Values(Left) < Values (Right); end Lt_Int; -- Instantiate the generic heap sort package package Heap_Sort is new Gnat.Heap_Sort_G(Move_Int, Lt_Int); begin Heap_Sort.Sort(8); end Integer_Sort; requires an Ada05 compiler, e.g GNAT GPL 2007 procedure Integer_Sort is -- type Int_Array is array(Natural range <>) of Integer; Values : Int_Array := (0,1,8,2,7,3,6,4,5); -- Instantiate the generic sort package from the standard Ada library (Index_Type => Natural, Element_Type => Integer, Array_Type => Int_Array); begin Sort(Values); end Integer_Sort; ``` ## ALGOL 68 {{trans|python}} {{works with|ALGOL 68|Standard - no extensions to language used}} {{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} {{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}} ```CO PR READ "shell_sort.a68" PR CO MODE TYPE = INT; PROC in place shell sort = (REF[]TYPE seq)REF[]TYPE:( INT inc := ( UPB seq + LWB seq + 1 ) OVER 2; WHILE inc NE 0 DO FOR index FROM LWB seq TO UPB seq DO INT i := index; TYPE el = seq[i]; WHILE ( i - LWB seq >= inc | seq[i - inc] > el | FALSE ) DO seq[i] := seq[i - inc]; i -:= inc OD; seq[i] := el OD; inc := IF inc = 2 THEN 1 ELSE ENTIER(inc * 5 / 11) FI OD; seq ); PROC shell sort = ([]TYPE seq)[]TYPE: in place shell sort(LOC[LWB seq: UPB seq]TYPE:=seq); print((shell sort((2, 4, 3, 1, 2)), new line)) ``` Output: ``` +1 +2 +2 +3 +4 ``` ## ALGOL W Algol W doesn't have standard sorting facilities. This uses the Algol W quicksort sample in the Sorting Algorithms Quicksort task. ```begin % use the quicksort procedure from the Sorting_Algorithms/Quicksort task % % Quicksorts in-place the array of integers v, from lb to ub - external % procedure quicksort ( integer array v( * ) ; integer value lb, ub ) ; algol "sortingAlgorithms_Quicksort" ; % sort an integer array with the quicksort routine % begin integer array t ( 1 :: 5 ); integer p; p := 1; for v := 2, 3, 1, 9, -2 do begin t( p ) := v; p := p + 1; end; quicksort( t, 1, 5 ); for i := 1 until 5 do writeon( i_w := 1, s_w := 1, t( i ) ) end end. ``` {{out}} ``` -2 1 2 3 9 ``` ## APL {{works with|APL2}} ``` X←63 92 51 92 39 15 43 89 36 69 X[⍋X] 15 36 39 43 51 63 69 89 92 92 ``` ## AppleScript AppleScript has no native sort function. Later versions of AppleScript (OS X 10.10 onwards) do allow access to the ObjC NSArray library, but while this approach can yield reasonably fast sorts, it is slow in terms of scripter time, requiring digestion of the ObjC library documentation, and leading to code like the '''sort''' function below, which is possibly more messy than it is worth for the purposes of casual end-user scripting, for which AppleScript was presumably designed. ```use framework "Foundation" -- sort :: [a] -> [a] on sort(lst) ((current application's NSArray's arrayWithArray:lst)'s ¬ sortedArrayUsingSelector:"compare:") as list end sort -- TEST ----------------------------------------------------------------------- on run map(sort, [[9, 1, 8, 2, 8, 3, 7, 0, 4, 6, 5], ¬ ["alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", ¬ "theta", "iota", "kappa", "lambda", "mu"]]) end run -- GENERIC FUNCTIONS --------------------------------------------------------- -- map :: (a -> b) -> [a] -> [b] on map(f, xs) tell mReturn(f) set lng to length of xs set lst to {} repeat with i from 1 to lng set end of lst to |λ|(item i of xs, i, xs) end repeat return lst end tell end map -- Lift 2nd class handler function into 1st class script wrapper -- mReturn :: Handler -> Script on mReturn(f) if class of f is script then f else script property |λ| : f end script end if end mReturn ``` {{Out}} ```{{0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9}, {"alpha", "beta", "delta", "epsilon", "eta", "gamma", "iota", "kappa", "lambda", "mu", "theta", "zeta"}} ``` ## AutoHotkey ```numbers = 5 4 1 2 3 sort, numbers, N D%A_Space% Msgbox % numbers ``` ## AWK ``` # syntax: GAWK -f SORT_AN_INTEGER_ARRAY.AWK BEGIN { split("9,10,3,1234,99,1,200,2,0,-2",arr,",") show("@unsorted","unsorted") show("@val_num_asc","sorted ascending") show("@val_num_desc","sorted descending") exit(0) } function show(sequence,description, i) { PROCINFO["sorted_in"] = sequence for (i in arr) { printf("%s ",arr[i]) } printf("\t%s\n",description) } ``` output: ``` 9 10 3 1234 99 1 200 2 0 -2 unsorted -2 0 1 2 3 9 10 99 200 1234 sorted ascending 1234 200 99 10 9 3 2 1 0 -2 sorted descending ``` ## Axe There is no ascending sort function in Axe, but there is a descending sort function. One can either implement a custom ascending sorting function or simply reverse the output from SortD. ```2→{L₁} 4→{L₁+1} 3→{L₁+2} 1→{L₁+3} 2→{L₁+4} SortD(L₁,5) ``` ## Babel Use the sortval operator to sort an array of integers (val-array in Babel terminology). The following code creates a list of random values, converts it to a val-array, sorts that val-array, then converts it back to a list for display using the lsnum utility. ``` nil { zap {1 randlf 100 rem} 20 times collect ! } nest dup lsnum ! --> Create a list of random numbers ( 20 47 69 71 18 10 92 9 56 68 71 92 45 92 12 7 59 55 54 24 ) babel> ls2lf --> Convert list to array for sorting babel> dup {fnord} merge_sort --> The internal sort operator babel> ar2ls lsnum ! --> Display the results ( 7 9 10 12 18 20 24 45 47 54 55 56 59 68 69 71 71 92 92 92 ) ``` In Babel, lists and arrays are distinct. If you want to sort a list, use the lssort utility: ``` ( 68 73 63 83 54 67 46 53 88 86 49 75 89 83 28 9 34 21 20 90 ) babel> {lt?} lssort ! lsnum ! ( 9 20 21 28 34 46 49 53 54 63 67 68 73 75 83 83 86 88 89 90 ) ``` To reverse the sort-order, use the 'gt?' predicate instead of the 'lt?' predicate: ``` ( 68 73 63 83 54 67 46 53 88 86 49 75 89 83 28 9 34 21 20 90 ) {gt?} lssort ! lsnum ! ( 90 89 88 86 83 83 75 73 68 67 63 54 53 49 46 34 28 21 20 9 ) ``` ## BaCon ```' Sort an integer array DECLARE values[5] TYPE NUMBER values[0] = 23 values[1] = 32 values[2] = 12 values[3] = 21 values[4] = 01 SORT values FOR i = 0 TO 3 PRINT values[i], ", "; NEXT PRINT values[4] ``` {{out}} ```prompt\$ ./sort-integer 1, 12, 21, 23, 32 ``` Use SORT array DOWN for descending sort order. ## BBC BASIC {{works with|BBC BASIC for Windows}} Uses the supplied SORTLIB library. ``` INSTALL @lib\$+"SORTLIB" sort% = FN_sortinit(0,0) DIM array(8) array() = 8, 2, 5, 9, 1, 3, 6, 7, 4 C% = DIM(array(),1) + 1 CALL sort%, array(0) FOR i% = 0 TO DIM(array(),1) - 1 PRINT ; array(i%) ", "; NEXT PRINT ; array(i%) ``` Output: ``` 1, 2, 3, 4, 5, 6, 7, 8, 9 ``` ## Befunge {{works with|befungee}} Elements of the array are read from standard input, preceded by their quantity. The algorithm uses counting sort and allows numbers between 1 and 60, inclusive. ```v > 543** > :#v_ \$&> :#v_ 1 > :0g > :#v_ \$ 1+: 543** `! #v_ 25*,@ ^-1p0\0:< ^-1 p0\+1 g0:&< ^-1\.:\< ^ < ``` ## Bracmat As a Computer Algebra system, Bracmat transforms expressions to a canonical form. Terms in a sum are sorted and, where possible, added together. So the task is partially solved by expressing the list as a sum of terms. Evaluating the list sorts the list, but also adds like terms. To illustrate, this is what happens when entering our list at the prompt: ```{?} (9.)+(-2.)+(1.)+(2.)+(8.)+(0.)+(1.)+(2.) {!} (-2.)+(0.)+2*(1.)+2*(2.)+(8.)+(9.) ``` The use of a computationally inert operator like the dot `.` is essential: ```{?} (9)+(-2)+(1)+(2)+(8)+(0)+(1)+(2) {!} 21 ``` To complete the task need to unfold the terms with a numerical factor >1: ```{sort takes a list of space-separated integers} (sort= sum elem sorted n . 0:?sum & whl ' (!arg:%?elem ?arg&(!elem.)+!sum:?sum) & :?sorted & whl ' ( !sum:?n*(?elem.)+?sum & whl ' ( !n+-1:~<0:?n & !sorted !elem:?sorted ) ) & !sorted); out\$sort\$(9 -2 1 2 8 0 1 2); ``` Output: ```-2 0 1 1 2 2 8 9 ``` This solution becomes very ineffective for long lists. To add a single term to an already sorted sum of N terms requires on average N/2 steps. It is much more efficient to merge two already sorted sums of about equal length. Also, adding elements to the end of the list 'sorted' is costly. Better is to prepend elements to a list, which will have inverted sorting order, and to invert this list in an extra loop. ## Burlesque ```{1 3 2 5 4}>< ``` ## C ```#include <iostream> /* qsort() */ #include <stdio.h> /* printf() */ int intcmp(const void *aa, const void *bb) { const int *a = aa, *b = bb; return (*a < *b) ? -1 : (*a > *b); } int main() { int nums[5] = {2,4,3,1,2}; qsort(nums, 5, sizeof(int), intcmp); printf("result: %d %d %d %d %d\n", nums[0], nums[1], nums[2], nums[3], nums[4]); return 0; } ``` ''Caution:'' An older version of intcmp() did return *a - *b. This is only correct when the subtraction does not overflow. Suppose that *a = 2000000000 and *b = -2000000000 on a machine with 32-bit int. The subtraction *a - *b would overflow to -294967296, and intcmp() would believe *a < *b, but the correct answer is *a > *b. ## C++ {{works with|g++|4.0.1}} ### Simple Array ```#include <algorithm> int main() { int nums[] = {2,4,3,1,2}; std::sort(nums, nums+sizeof(nums)/sizeof(int)); return 0; } ``` ### std::vector ```#include <algorithm> #include <vector> int main() { std::vector<int> nums; nums.push_back(2); nums.push_back(4); nums.push_back(3); nums.push_back(1); nums.push_back(2); std::sort(nums.begin(), nums.end()); return 0; } ``` ### std::list ```#include <list> int main() { std::list<int> nums; nums.push_back(2); nums.push_back(4); nums.push_back(3); nums.push_back(1); nums.push_back(2); nums.sort(); return 0; } ``` ## C# ```using System; using System.Collections.Generic; public class Program { static void Main() { int[] unsorted = { 6, 2, 7, 8, 3, 1, 10, 5, 4, 9 }; Array.Sort(unsorted); } } ``` ## Clean We use list and array comprehensions to convert an array to and from a list in order to use the built-in sort on lists. ```import StdEnv sortArray :: (a e) -> a e | Array a e & Ord e sortArray array = {y \\ y <- sort [x \\ x <-: array]} Start :: {#Int} Start = sortArray {2, 4, 3, 1, 2} ``` ## Clojure ```(sort [5 4 3 2 1]) ; sort can also take a comparator function (1 2 3 4 5) ``` ## COBOL {{works with|Visual COBOL}} ``` PROGRAM-ID. sort-ints. DATA DIVISION. WORKING-STORAGE SECTION. 01 array-area VALUE "54321". 03 array PIC 9 OCCURS 5 TIMES. 01 i PIC 9. PROCEDURE DIVISION. main-line. PERFORM display-array SORT array ASCENDING array PERFORM display-array GOBACK . display-array. PERFORM VARYING i FROM 1 BY 1 UNTIL 5 < i DISPLAY array (i) " " NO ADVANCING END-PERFORM DISPLAY SPACE . ``` ## Common Lisp In Common Lisp, the ''sort'' function takes a predicate that is used as the comparator. This parameter can be any two-argument function. To sort a sequence (list or array) of integers, call ''sort'' with the < operator as the predicate: ```CL-USER> (sort #(9 -2 1 2 8 0 1 2) #'<) #(-2 0 1 1 2 2 8 9) ``` ## Crystal Example demonstrating the support for copy sort and in-place sort (like Ruby) ``` a = [5, 4, 3, 2, 1] puts a.sort # => [1, 2, 3, 4, 5] puts a # => [5, 4, 3, 2, 1] a.sort! puts a # => [1, 2, 3, 4, 5] ``` ## D ```import std.stdio, std.algorithm; void main() { auto data = [2, 4, 3, 1, 2]; data.sort(); // in-place assert(data == [1, 2, 2, 3, 4]); } ``` ## Delphi ```uses Types, Generics.Collections; var a: TIntegerDynArray; begin a := TIntegerDynArray.Create(5, 4, 3, 2, 1); TArray.Sort<Integer>(a); end; ``` ```!. sort [ 5 4 3 2 1 ] ``` {{out}} ```[ 1 2 3 4 5 ] ``` ## DWScript ```var a : array of Integer := [5, 4, 3, 2, 1]; a.Sort; // ascending natural sort PrintLn(a.Map(IntToStr).Join(',')); // 1,2,3,4,5 ``` ## E ```[2,4,3,1,2].sort() ``` ## Elena ELENA 4.1 : ```import system'routines; import extensions; public program() { var unsorted := new int[]::(6, 2, 7, 8, 3, 1, 10, 5, 4, 9); console.printLine(unsorted.clone().sort(ifOrdered).asEnumerable()) } ``` ## Elixir ```list = [2, 4, 3, 1, 2] IO.inspect Enum.sort(list) IO.inspect Enum.sort(list, &(&1>&2)) ``` {{out}} ``` [1, 2, 2, 3, 4] [4, 3, 2, 2, 1] ``` ## Erlang ```List = [2, 4, 3, 1, 2]. SortedList = lists:sort(List). ``` ## Euphoria ```include sort.e print(1,sort({20, 7, 65, 10, 3, 0, 8, -60})) ``` ## EGL {{works with|EDT}} The following works in EDT with Rich UI and stand-alone programs. ```program SortExample function main() test1 int[] = [1,-1,8,-8,2,-2,7,-7,3,-3,6,-6,9,-9,4,-4,5,-5,0]; test1.sort(sortFunction); for(i int from 1 to test1.getSize()) SysLib.writeStdout(test1[i]); end end function sortFunction(a any in, b any in) returns (int) return (a as int) - (b as int); end end ``` {{works with|RBD}} The following works in RBD but only with Rich UI programs. ```test1 int[] = [1,-1,8,-8,2,-2,7,-7,3,-3,6,-6,9,-9,4,-4,5,-5,0]; RUILib.sort(test1, sortFunction); function sortFunction(a any in, b any in) returns (int) return ((a as int) - (b as int)); end ``` ## Factor ```{ 1 4 9 2 3 0 5 } natural-sort . ``` ## Fantom The List collection contains a sort method which uses the usual comparison method for the data in the list; the sort is done 'in place'. ``` fansh> a := [5, 1, 4, 2, 3] [5, 1, 4, 2, 3] fansh> a.sort [1, 2, 3, 4, 5] fansh> a [1, 2, 3, 4, 5] ``` ## Forth {{works with|Win32Forth|4.2}} ### Win32Forth ```create test-data 2 , 4 , 3 , 1 , 2 , test-data 5 cell-sort ``` ### ANS/ISO Forth {{works with|GForth}} Uses quicksort http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Forth Standard Forth does not have a library sort ```100000 CONSTANT SIZE CREATE MYARRAY SIZE CELLS ALLOT : FILLIT ( -- ) ( reversed order) SIZE 0 DO SIZE I - I MYARRAY [] ! LOOP ; : SEEIT ( -- ) SIZE 0 DO I MYARRAY [] ? LOOP ; \ define non-standard words used by Quicksort author 1 CELLS CONSTANT CELL CELL NEGATE CONSTANT -CELL : CELL- CELL - ; : MID ( l r -- mid ) OVER - 2/ -CELL AND + ; OVER @ OVER @ ( read values) SWAP ROT ! SWAP ! ; ( exchange values) : PARTITION ( l r -- l r r2 l2 ) 2DUP MID @ >R ( r: pivot ) 2DUP BEGIN SWAP BEGIN DUP @ R@ < WHILE CELL+ REPEAT SWAP BEGIN R@ OVER @ < WHILE CELL- REPEAT 2DUP <= IF 2DUP EXCH >R CELL+ R> CELL- THEN 2DUP > UNTIL R> DROP ; : QSORT ( l r -- ) PARTITION SWAP ROT 2DUP < IF RECURSE ELSE 2DROP THEN 2DUP < IF RECURSE ELSE 2DROP THEN ; : QUICKSORT ( array len -- ) DUP 2 < IF 2DROP EXIT THEN 1- CELLS OVER + QSORT ;</LANG> Test at the console ```forth FILLIT ok MYARRAY SIZE QUICKSORT ok ``` ## Fortran {{works with|Silverfrost FTN95}} ```CALL ISORT@(b, a, n) ! n = number of elements ! a = array to be sorted ! b = array of indices of a. b(1) 'points' to the minimum value etc. ``` ## FreeBASIC Qsort is not buildin, but include in the compiler package. ```' version 11-03-2016 ' compile with: fbc -s console #Include Once "crt/stdlib.bi" ' needed for qsort subroutine ' Declare Sub qsort (ByVal As Any Ptr, <== point to start of array ' ByVal As size_t, <== size of array ' ByVal As size_t, <== size of array element ' ByVal As Function(ByVal As Any Ptr, ByVal As Any Ptr) As Long) <== callback function ' declare callback function with Cdecl to ensures that the parameters are passed in the correct order ' ' size of long: 4 bytes on 32bit OS, 8 bytes on 64bit OS ' ascending Function callback Cdecl (ByVal element1 As Any Ptr, ByVal element2 As Any Ptr) As Long Function = *Cast(Long Ptr, element1) - *Cast(Long Ptr, element2) End Function ' Function callback Cdecl (ByVal element1 As Any Ptr, ByVal element2 As Any Ptr) As Long ' Dim As Long e1 = *Cast(Long Ptr, element1) ' Dim As Long e2 = *Cast(Long Ptr, element2) ' Dim As Long result = Sgn(e1 - e2) ' If Sgn(e1) = -1 And Sgn(e2) = -1 Then result = -result ' Function = result ' End Function ' ------=< MAIN >=------ Dim As Long i, array(20) Dim As Long lb = LBound(array) Dim As Long ub = UBound(array) For i = lb To ub ' fill array array(i) = 10 - i Next Print Print "unsorted array" For i = lb To ub ' display array Print Using "###";array(i); Next Print : Print ' sort array qsort(@array(lb), ub - lb +1, SizeOf(array), @callback) Print "sorted array" For i = lb To ub ' show sorted array Print Using "###";array(i); Next Print ' empty keyboard buffer While Inkey <> "" : Wend Print : Print "hit any key to end program" Sleep End ``` {{out}} ```unsorted array 10 9 8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9-10 sorted array -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 ``` ## Frink The following sorts an array in-place. ```a = [5, 2, 4, 1, 6, 7, 9, 3, 8, 0] sort[a] ``` ```// sorting an array in place let nums = [| 2; 4; 3; 1; 2 |] Array.sortInPlace nums // create a sorted copy of a list let nums2 = [2; 4; 3; 1; 2] let sorted = List.sort nums2 ``` ## FunL ```nums = [5, 2, 78, 2, 578, -42] println( sort(nums) ) // sort in ascending order println( nums.sortWith((>)) ) // sort in descending order ``` {{out}} ``` [-42, 2, 2, 5, 78, 578] [578, 78, 5, 2, 2, -42] ``` ## GAP ```a := [ 8, 2, 5, 9, 1, 3, 6, 7, 4 ]; # Make a copy (with "b := a;", b and a would point to the same list) b := ShallowCopy(a); # Sort in place Sort(a); a; # [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] # Sort without changing the argument SortedList(b); # [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] b; # [ 8, 2, 5, 9, 1, 3, 6, 7, 4 ] ``` ## Gambas '''[https://gambas-playground.proko.eu/?gist=1f1d244aa95c329eb87cb538f0d5fc4a Click this link to run this code]''' ```Public Sub Main() Dim iArray As Integer[] = [8, 2, 5, 9, 1, 3, 6, 7, 4] Dim iTemp As Integer Dim sOutput As String For Each iTemp In iArray.Sort() sOutput &= iTemp & ", " Next Print Left(sOutput, -2) End ``` Output: ``` 1, 2, 3, 4, 5, 6, 7, 8, 9 ``` ## Go ```package main import "fmt" import "sort" func main() { nums := []int {2, 4, 3, 1, 2} sort.Ints(nums) fmt.Println(nums) } ``` ## Golfscript ```[2 4 3 1 2]\$ ``` ## Groovy ```println ([2,4,0,3,1,2,-12].sort()) ``` Output: ```[-12, 0, 1, 2, 2, 3, 4] ``` {{works with|GHC|GHCi|6.6}} ```nums = [2,4,3,1,2] :: [Int] sorted = List.sort nums ``` ## HicEst ```DIMENSION array(100) array = INT( RAN(100) ) SORT(Vector=array, Sorted=array) ``` ## Huginn ```main() { nums = [2, 4, 3, 1, 2]; nums.sort(); } ``` ## IDL ```result = array[sort(array)] ``` =={{header|Icon}} and {{header|Unicon}}== Icon and Unicon lists allow mixed type and the built-in function 'sort' will deal with mixed type arrays by sorting by type first then value. Integers sort before, reals, strings, lists, tables, etc. As a result a list of mixed numeric valuess (i.e. integers and reals) will not sort by numeric value, rather the reals will appear after the integers. Sort returns a sorted copy of it's argument. It will also perform some type conversion, such converting an unordered set into an ordered list. In the example below, L will remain an unsorted list and S will be sorted. ```S := sort(L:= [63, 92, 51, 92, 39, 15, 43, 89, 36, 69]) # will sort a list ``` ## Inform 7 ```let L be {5, 4, 7, 1, 18}; sort L; ``` ## Io ```mums := list(2,4,3,1,2) sorted := nums sort # returns a new sorted array. 'nums' is unchanged nums sortInPlace # sort 'nums' "in-place" ``` ## J ```/:~ ``` The verb /:~ sorts anything that J can represent. For example: ``` ] a=: 10 ?@\$ 100 NB. random vector 63 92 51 92 39 15 43 89 36 69 /:~ a 15 36 39 43 51 63 69 89 92 92 ``` Arrays of any rank are treated as lists of component arrays. Thus /:~ sorts not only atoms within a list, but whole lists within a table, tables within a three-axis array, and so on. The level of structure at which sorting occurs may also be specified, so that /:~"1 sorts the atoms within the finest-grained list within the array, regardless of the overall rank of the array. See the [https://code.jsoftware.com/wiki/Essays/The_TAO_of_J Total Array Ordering essay] on the JWiki for more details. This code also applies to any data type. ## Java ### Array ```import java.util.Arrays; public class Example { public static void main(String[] args) { int[] nums = {2,4,3,1,2}; Arrays.sort(nums); } } ``` ### List {{works with|Java|1.5+}} ```import java.util.Arrays; import java.util.Collections; import java.util.List; public class Example { public static void main(String[] args) { List<Integer> nums = Arrays.asList(2,4,3,1,2); Collections.sort(nums); } } ``` ## JavaScript {{works with|Firefox|2.0}} JavaScript sorts lexically by default, so "10000" comes before "2". To sort numerically, a custom comparator is used. ```function int_arr(a, b) { return a - b; } var numbers = [20, 7, 65, 10, 3, 0, 8, -60]; numbers.sort(int_arr); document.write(numbers); ``` ## Kotlin ```// version 1.0.6 fun main(args: Array<String>) { val ints = intArrayOf(6, 2, 7, 8, 3, 1, 10, 5, 4, 9) ints.sort() println(ints.joinToString(prefix = "[", postfix = "]")) } ``` {{out}} ``` [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ``` ## Lasso ```local(array) = array(5,20,3,2,6,1,4) #array->sort #array // 1, 2, 3, 4, 5, 6, 20 // Reverse the sort order #array->sort(false) #array // 20, 6, 5, 4, 3, 2, 1 ``` ## jq jq's builtin `sort` filter sorts the elements of an array in ascending order: ```[2,1,3] | sort # => [1,2,3] ``` ## Julia Julia has both out-of-place (`sort`) and in-place (`sort!`) sorting functions in its standard-library: ``` a = [4,2,3,1] 4-element Int32 Array: 4 2 3 1 julia> sort(a) #out-of-place/non-mutating sort 4-element Int32 Array: 1 2 3 4 julia> a 4-element Int32 Array: 4 2 3 1 julia> sort!(a) # in-place/mutating sort 4-element Int32 Array: 1 2 3 4 julia> a 4-element Int32 Array: 1 2 3 4 ``` ## K ``` num: -10?10 / Integers from 0 to 9 in random order 5 9 4 2 0 3 6 1 8 7 srt: {x@<x} / Generalized sort ascending srt num 0 1 2 3 4 5 6 7 8 9 ``` ## Liberty BASIC LB has an array-sort command. Parameters are arrayname, start term, finish term. ```N =20 dim IntArray( N) print "Original order" for i =1 to N t =int( 1000 *rnd( 1)) IntArray( i) =t print t next i sort IntArray(), 1, N print "Sorted oprder" for i =1 to N print IntArray( i) next i ``` ## Lingo ```l = [7, 4, 23] l.sort() put l -- [4, 7, 23] ``` ## LiveCode LiveCode can sort lines or items natively. The delimiter for items can be set to any single character, but defaults to comma. ```put "3,2,5,4,1" into X sort items of X numeric put X -- outputs "1,2,3,4,5" ``` ## Lua ```t = {4, 5, 2} table.sort(t) print(unpack(t)) ``` ## Maple ```sort([5,7,8,3,6,1]); sort(Array([5,7,8,3,6,1])) ``` ## Mathematica ```numbers = Sort[{2,4,3,1,2}] ``` ## MATLAB ```a = [4,3,7,-2,9,1]; b = sort(a) % b contains elements of a in ascending order [b,idx] = sort(a) % b contains a(idx) ``` ## Maxima ```sort([9, 4, 3, 7, 6, 1, 10, 2, 8, 5]); ``` ## MAXScript ```arr = #(5, 4, 3, 2, 1) arr = sort arr ``` ## Mercury :- module sort_int_list. :- interface. :- import_module io. :- pred main(io::di, uo::uo) is det. :- implementation. :- import_module list. main(!IO) :- Nums = [2, 4, 0, 3, 1, 2], list.sort(Nums, Sorted), io.write(Sorted, !IO), io.nl(!IO). ``` ## min {{works with|min|0.19.3}} ```min (5 2 1 3 4) '> sort print ``` {{out}} ``` (1 2 3 4 5) ``` =={{header|Modula-3}}== Modula-3 provides a generic ArraySort module, as well as an instance of that module for integers called IntArraySort. ```MODULE ArraySort EXPORTS Main; IMPORT IntArraySort; VAR arr := ARRAY [1..10] OF INTEGER{3, 6, 1, 2, 10, 7, 9, 4, 8, 5}; BEGIN IntArraySort.Sort(arr); END ArraySort. ``` ## MUMPS ```SORTARRAY(X,SEP) ;X is the list of items to sort ;X1 is the temporary array ;SEP is the separator string between items in the list X ;Y is the returned list ;This routine uses the inherent sorting of the arrays NEW I,X1,Y SET Y="" FOR I=1:1:\$LENGTH(X,SEP) SET X1(\$PIECE(X,SEP,I))="" SET I="" FOR SET I=\$O(X1(I)) Q:I="" SET Y=\$SELECT(\$L(Y)=0:I,1:Y_SEP_I) KILL I,X1 QUIT Y ``` Output: ```USER>W \$\$SORTARRAY^ROSETTA("3,5,1,99,27,16,0,-1",",") -1,0,1,3,5,16,27,99 ``` ## Neko ```/** <doc><h2>Sort integer array, in Neko</h2> <p>Array sort function modified from Haxe codegen with -D neko-source</p> <p>The Neko target emits support code for Haxe basics, sort is included</p> <p>Tectonics:<br />prompt\$ nekoc sort.neko<br />prompt\$ neko sort</p> </doc> **/ var sort = function(a) { var i = 0; var len = \$asize(a); while ( i < len ) { var swap = false; var j = 0; var max = (len - i) - 1; while ( j < max ) { if ( (a[j] - a[j + 1]) > 0 ) { var tmp = a[j + 1]; a[j + 1] = a[j]; a[j] = tmp; swap = true; } j += 1; } if ( \$not(swap) ) break;; i += 1; } return a; } var arr = \$array(5,3,2,1,4) \$print(arr, "\n") /* Sorts in place */ sort(arr) \$print(arr, "\n") /* Also returns the sorted array for chaining */ \$print(sort(\$array(3,1,4,1,5,9,2,6,5,3,5,8)), "\n") ``` {{out}} ```prompt\$ nekoc sort.neko prompt\$ neko sort.n [5,3,2,1,4] [1,2,3,4,5] [1,1,2,3,3,4,5,5,5,6,8,9] ``` ## Nemerle ```using System.Console; module IntSort { Main() : void { def nums = [1, 5, 3, 7, 2, 8, 3, 9]; def sorted = nums.Sort((x, y) => x.CompareTo(y)); WriteLine(nums); WriteLine(sorted); } } ``` Output: ```[1, 5, 3, 7, 2, 8, 3, 9] [1, 2, 3, 3, 5, 7, 8, 9] ``` ## NetRexx ```/* NetRexx */ options replace format comments java crossref savelog symbols binary ia = int[] ia = [ 2, 4, 3, 1, 2, -1, 0, -2 ] display(ia) Arrays.sort(ia) display(ia) -- Display results method display(in = int[]) public static sorted = Rexx('') loop ix = 0 for in.length sorted = sorted || Rexx(in[ix]).right(4) end ix say sorted.strip('t') return ``` '''Output''' ``` 2 4 3 1 2 -1 0 -2 -2 -1 0 1 2 2 3 4 ``` NetRexx reimplementations of the [[#REXX|Rexx]] samples from below: ```NetRexx /* NetRexx */ options replace format comments java crossref savelog symbols /*REXX program to sort an integer array.*/ numeric digits 20 /*handle larger numbers.*/ a = '' a[ 1]= 1 a[ 2]= 0 a[ 3]= -1 a[ 4]= 0 a[ 5]= 5 a[ 6]= 0 a[ 7]= -61 a[ 8]= 0 a[ 9]= 1385 a[10]= 0 a[11]= -50521 a[12]= 0 a[13]= 2702765 a[14]= 0 a[15]= -199360981 a[16]= 0 a[17]= 19391512145 a[18]= 0 a[19]= -2404879675441 a[20]= 0 a[21]= 370371188237525 size = 21 /*we have a list of 21 Euler numbers.*/ tell('un-sorted', a, size) a[0] = size esort(a, 1) tell(' sorted', a, size) return /*----------------------------------ESORT subroutine--------------------*/ method esort(a, size) public static --esort: procedure expose a.; h = a[0] loop while h > 1 h = h % 2 loop i = 1 for a[0] - h j = i k = h + i loop while a[k] < a[j] t = a[j] a[j] = a[k] a[k] = t if h >= j then leave j = j - h k = k - h end end i end return /*----------------------------------TELL subroutine---------------------*/ method tell(arg, a, size) public static --tell: say arg.center(40, '-') loop j = 1 for size say arg 'array element' j.right(size.length)'='a[j].right(25) end j say return ``` '''Output''' ---------------un-sorted---------------- un-sorted array element 1= 1 un-sorted array element 2= 0 un-sorted array element 3= -1 un-sorted array element 4= 0 un-sorted array element 5= 5 un-sorted array element 6= 0 un-sorted array element 7= -61 un-sorted array element 8= 0 un-sorted array element 9= 1385 un-sorted array element 10= 0 un-sorted array element 11= -50521 un-sorted array element 12= 0 un-sorted array element 13= 2702765 un-sorted array element 14= 0 un-sorted array element 15= -199360981 un-sorted array element 16= 0 un-sorted array element 17= 19391512145 un-sorted array element 18= 0 un-sorted array element 19= -2404879675441 un-sorted array element 20= 0 un-sorted array element 21= 370371188237525 --------------- sorted---------------- sorted array element 1= -2404879675441 sorted array element 2= -199360981 sorted array element 3= -50521 sorted array element 4= -61 sorted array element 5= -1 sorted array element 6= 0 sorted array element 7= 0 sorted array element 8= 0 sorted array element 9= 0 sorted array element 10= 0 sorted array element 11= 0 sorted array element 12= 0 sorted array element 13= 0 sorted array element 14= 0 sorted array element 15= 0 sorted array element 16= 1 sorted array element 17= 5 sorted array element 18= 1385 sorted array element 19= 2702765 sorted array element 20= 19391512145 sorted array element 21= 370371188237525 ``` ```NetRexx /* NetRexx */ options replace format comments java crossref savelog symbols /*REXX program to sort an interesting integer list.*/ bell = '1 1 2 5 15 52 203 877 4140 21147 115975' /*some Bell numbers.*/ bern = '1 -1 1 0 -1 0 1 0 -1 0 5 0 -691 0 7 0 -3617' /*some Bernoulli num*/ perrin = '3 0 2 3 2 5 5 7 10 12 17 22 29 39 51 68 90' /*some Perrin nums. */ list = bell bern perrin /*combine the three.*/ size = list.words a = 0 loop j = 1 for size a[j] = list.word(j) end j say ' as is='list a[0] = size esort(a, size) bList = '' loop j = 1 for size bList = bList a[j] end j blist = bList.strip say ' sorted='bList return /*----------------------------------ESORT subroutine--------------------*/ method esort(a, size) public static --esort: procedure expose a.; h = a[0] loop while h > 1 h = h % 2 loop i = 1 for a[0] - h j = i k = h + i loop while a[k] < a[j] t = a[j] a[j] = a[k] a[k] = t if h >= j then leave j = j - h k = k - h end end i end return ``` '''Output''' as is=1 1 2 5 15 52 203 877 4140 21147 115975 1 -1 1 0 -1 0 1 0 -1 0 5 0 -691 0 7 0 -3617 3 0 2 3 2 5 5 7 10 12 17 22 29 39 51 68 90 sorted=-3617 -691 -1 -1 -1 0 0 0 0 0 0 0 0 1 1 1 1 1 2 2 2 3 3 5 5 5 5 7 7 10 12 15 17 22 29 39 51 52 68 90 203 877 4140 21147 115975 ``` ## Nial ```nial>sort = 9 6 8 7 1 10 = 10 9 8 7 6 1 ``` ## Nim ```nim import algorithm var a: array[0..8,int] = [2,3,5,8,4,1,6,9,7] a.sort(system.cmp[int], Ascending) for x in a: echo(x) ``` {{out}} ```txt 1 2 3 4 5 6 7 8 9 ``` ## Niue '''Library''' ```Niue 2 6 1 0 3 8 sort .s 0 1 2 3 6 8 ``` ```objc NSArray *nums = @[@2, @4, @3, @1, @2]; NSArray *sorted = [nums sortedArrayUsingSelector:@selector(compare:)]; ``` ## Objeck ```objeck bundle Default { class Sort { function : Main(args : System.String[]) ~ Nil { nums := Structure.IntVector->New([2,4,3,1,2]); nums->Sort(); } } } ``` ## OCaml ### Array ```ocaml let nums = [|2; 4; 3; 1; 2|] Array.sort compare nums ``` ### List ```ocaml let nums = [2; 4; 3; 1; 2] let sorted = List.sort compare nums ``` ## Octave The variable v can be a vector or a matrix (columns will be sorted). ```octave sortedv = sort(v); ``` ## Oforth ```Oforth [ 8, 2, 5, 9, 1, 3, 6, 7, 4 ] sort ``` ## ooRexx ```rexx a = .array~of(4, 1, 6, -2, 99, -12) say "The sorted numbers are" say a~sortWith(.numericComparator~new)~makeString ``` Output: ```txt The sorted numbers are -12 -2 1 4 6 99 ``` ## Order Passing the less-than operator to the built-in sequence (i.e. list) sort function: ```c #include ORDER_PP( 8seq_sort(8less, 8seq(2, 4, 3, 1, 2)) ) ``` ## Oz ```oz declare Nums = [2 4 3 1 2] Sorted = {List.sort Nums Value.'<'} in {Show Sorted} ``` ## PARI/GP ```parigp vecsort(v) ``` ## Peloton Sorting a list of numbers as strings and as numbers (from the manual.) ```sgml Construct a list of numbers <@ LETCNSLSTLIT>L|65^84^1^25^77^4^47^2^42^44^41^25^69^3^51^45^4^39^ Numbers sort as strings <@ ACTSRTENTLST>L <@ SAYDMPLST>L <@ ACTSRTENTLSTLIT>L|__StringDescending <@ SAYDMPLST>L Construct another list of numbers <@ LETCNSLSTLIT>list|65^84^1^25^77^4^47^2^42^44^41^25^69^3^51^45^4^39^ Numbers sorted as numbers <@ ACTSRTENTLSTLIT>list|__Numeric <@ SAYDMPLST>list <@ ACTSRTENTLSTLIT>list|__NumericDescending <@ SAYDMPLST>list ``` Output ```html Construct a list of numbers Numbers sort as strings 1^2^25^25^3^39^4^4^41^42^44^45^47^51^65^69^77^84^ 84^77^69^65^51^47^45^44^42^41^4^4^39^3^25^25^2^1^ Construct another list of numbers Numbers sorted as numbers 1^2^3^4^4^25^25^39^41^42^44^45^47^51^65^69^77^84^ 84^77^69^65^51^47^45^44^42^41^39^25^25^4^4^3^2^1^ ``` ## Perl {{works with|Perl|5.8.6}} ```perl @nums = (2,4,3,1,2); @sorted = sort {\$a <=> \$b} @nums; ``` ## Perl 6 If `@a` contains only numbers: ```perl6>my @sorted = sort @a;@a .= sort; ``` ## PicoLisp The [http://software-lab.de/doc/refS.html#sort sort] function in PicoLisp returns already by default an ascending list (of any type, not only integers): ```PicoLisp (sort (2 4 3 1 2)) -> (1 2 2 3 4) ``` ## PL/I {{works with|IBM PL/I|7.5}} ```pli DCL (T(10)) FIXED BIN(31); /* scratch space of length N/2 */ MERGE: PROCEDURE (A,LA,B,LB,C); DECLARE (A(*),B(*),C(*)) FIXED BIN(31); DECLARE (LA,LB) FIXED BIN(31) NONASGN; DECLARE (I,J,K) FIXED BIN(31); I=1; J=1; K=1; DO WHILE ((I <= LA) & (J <= LB)); IF(A(I) <= B(J)) THEN DO; C(K)=A(I); K=K+1; I=I+1; END; ELSE DO; C(K)=B(J); K=K+1; J=J+1; END; END; DO WHILE (I <= LA); C(K)=A(I); I=I+1; K=K+1; END; RETURN; END MERGE; MERGESORT: PROCEDURE (A,N) RECURSIVE ; DECLARE (A(*)) FIXED BINARY(31); DECLARE N FIXED BINARY(31) NONASGN; DECLARE Temp FIXED BINARY; DECLARE (M,I) FIXED BINARY; DECLARE AMP1(N) FIXED BINARY(31) BASED(P); DECLARE P POINTER; IF (N=1) THEN RETURN; M = trunc((N+1)/2); IF (M>1) THEN CALL MERGESORT(A,M); IF (N-M > 1) THEN CALL MERGESORT(AMP1,N-M); IF A(M) <= AMP1(1) THEN RETURN; DO I=1 to M; T(I)=A(I); END; CALL MERGE(T,M,AMP1,N-M,A); RETURN; END MERGESORT; ``` ## Pop11 Pop11 library function sorts lists. So we first convert array to list, then sort and finally convert back: ```pop11 lvars ar = {2 4 3 1 2}; ;;; Convert array to list. ;;; destvector leaves its results and on the pop11 stack + an integer saying how many there were destvector(ar); ;;; conslist uses the items left on the stack plus the integer, to make a list of those items. lvars ls = conslist(); ;;; Sort it sort(ls) -> ls; ;;; Convert list to array destlist(ls); consvector() -> ar; ``` The above can be abbreviated to more economical, but possibly more opaque, syntax, using pop11 as a functional language: ```pop11 lvars ar = {2 4 3 1 2}; consvector(destlist(sort(conslist(destvector(ar))))) -> ar; ;;; print the sorted vector: ar => ** {1 2 2 3 4} ``` (The list created by conslist will be garbage-collected.) Alternatively, using the datalist function, even more economically: ```pop11 lvars ar = {2 4 3 1 2}; consvector(destlist(sort(datalist(ar)))) -> ar; ``` or in Forth-like pop11 postfix syntax: ```pop11 lvars ar = {2 4 3 1 2}; ar.datalist.sort.destlist.consvector -> ar; ``` ## Potion ```potion (7, 5, 1, 2, 3, 8, 9) sort join(", ") print ``` ## PowerBASIC PowerBASIC has several options available for sorting. At its simplest, an array (of any type) is sorted using `ARRAY SORT`: ```powerbasic ARRAY SORT x() ``` Options are available to limit sorting to only part of the array, collate string arrays, sort multiple arrays together, etc. (Details [http://www.powerbasic.com/support/help/pbwin/html/ARRAY_SORT_statement.htm here].) ## PowerShell ```powershell 34,12,23,56,1,129,4,2,73 | Sort-Object ``` ## Prolog ```txt ?- msort([10,5,13,3, 85,3,1], L). L = [1,3,3,5,10,13,85]. ``` Note that [http://www.swi-prolog.org/pldoc/man?predicate=sort/2 sort/2] removes duplicates. ## PureBasic ```PureBasic Dim numbers(20) For i = 0 To 20 numbers(i) = Random(1000) Next SortArray(numbers(), #PB_Sort_Ascending) ``` ## Python {{works with|Python|2.3}} ```python nums = [2,4,3,1,2] nums.sort() ``` '''Note:''' The array nums is sorted in place. '''Interpreter:''' [[Python]] 2.4 (and above) You could also use the built-in sorted() function ```python nums = sorted([2,4,3,1,2]) ``` ## R ```r nums <- c(2,4,3,1,2) sorted <- sort(nums) ``` ## Racket ```Racket -> (sort '(1 9 2 8 3 7 4 6 5) <) '(1 2 3 4 5 6 7 8 9) ``` ## Rascal Rascal has a built-in sort function that sort the elements of a list. Additionally, one can give a LessThenOrEqual function to compare the elements (See [http://tutor.rascal-mpl.org/Courses/Rascal/Rascal.html#/Courses/Rascal/Libraries/Prelude/List/sort/sort.html documentation]). ```rascal>rascal import List; ok rascal>a = [1, 4, 2, 3, 5]; list[int]: [1,4,2,3,5] rascal>sort(a) list[int]: [1,2,3,4,5] rascal>sort(a, bool(int a, int b){return a >= b;}) list[int]: [5,4,3,2,1] ``` ## Raven Sort list in place: ```raven [ 2 4 3 1 2 ] sort ``` ## REBOL ```rebol sort [2 4 3 1 2] ``` ## Red ```Red>> nums: [3 2 6 4 1 9 0 5 7] == [3 2 6 4 1 9 0 5 7] >> sort nums == [0 1 2 3 4 5 6 7 9] ``` ## REXX ### sort an array This REXX version creates an array with over a score of Euler numbers (integers), then sorts it. ```rexx /*REXX program sorts an array (using E─sort), in this case, the array contains integers.*/ numeric digits 30 /*enables handling larger Euler numbers*/ @. = 0; @.1 = 1 @.3 = -1; @.5 = 5 @.7 = -61; @.9 = 1385 @.11= -50521; @.13= 2702765 @.15= -199360981; @.17= 19391512145 @.19= -2404879675441; @.21= 370371188237525 #= 21 /*indicate there're 21 Euler numbers.*/ call tell 'unsorted' /*display the array before the eSort. */ call eSort # /*sort the array of some Euler numbers.*/ call tell ' sorted' /*display the array after the eSort. */ exit /*stick a fork in it, we're all done. */ /*──────────────────────────────────────────────────────────────────────────────────────*/ eSort: procedure expose @.; parse arg N; h=N /*an eXchange sort.*/ do while h>1; h= h%2 /*define a segment.*/ do i=1 for N-h; j=i; k= h+i /*sort top segment.*/ do while @.k<@.j /*see if need swap.*/ parse value @.j @.k with @.k @.j /*swap two elements*/ if h>=j then leave; j= j-h; k= k-h /*this part sorted?*/ end /*while @.k<@.j*/ end /*i*/ end /*while h>1*/ return /*──────────────────────────────────────────────────────────────────────────────────────*/ tell: say copies('─', 65); _= left('',9); w= length(#) do j=1 for #; say _ arg(1) 'array element' right(j, w)"="right(@.j, 20) end /*j*/ return ``` {{out|output|text= when using the default internal input:}} ```txt ───────────────────────────────────────────────────────────────── unsorted array element 1= 1 unsorted array element 2= 0 unsorted array element 3= -1 unsorted array element 4= 0 unsorted array element 5= 5 unsorted array element 6= 0 unsorted array element 7= -61 unsorted array element 8= 0 unsorted array element 9= 1385 unsorted array element 10= 0 unsorted array element 11= -50521 unsorted array element 12= 0 unsorted array element 13= 2702765 unsorted array element 14= 0 unsorted array element 15= -199360981 unsorted array element 16= 0 unsorted array element 17= 19391512145 unsorted array element 18= 0 unsorted array element 19= -2404879675441 unsorted array element 20= 0 unsorted array element 21= 370371188237525 ───────────────────────────────────────────────────────────────── sorted array element 1= -2404879675441 sorted array element 2= -199360981 sorted array element 3= -50521 sorted array element 4= -61 sorted array element 5= -1 sorted array element 6= 0 sorted array element 7= 0 sorted array element 8= 0 sorted array element 9= 0 sorted array element 10= 0 sorted array element 11= 0 sorted array element 12= 0 sorted array element 13= 0 sorted array element 14= 0 sorted array element 15= 0 sorted array element 16= 1 sorted array element 17= 5 sorted array element 18= 1385 sorted array element 19= 2702765 sorted array element 20= 19391512145 sorted array element 21= 370371188237525 ``` ### sort a list This REXX version creates a list with a bunch of interesting integers, then sorts it. Because it so much more efficient to sort an array, an array is built from the list, it is then sorted, and then the list is re-constituted. ```rexx /*REXX program sorts (using E─sort) and displays a list of some interesting integers. */ Bell= 1 1 2 5 15 52 203 877 4140 21147 115975 /*a few Bell " */ Bern= '1 -1 1 0 -1 0 1 0 -1 0 5 0 -691 0 7 0 -3617' /*" " Bernoulli " */ Perrin= 3 0 2 3 2 5 5 7 10 12 17 22 29 39 51 68 90 /*" " Perrin " */ list=Bell Bern Perrin /*throw them all ───► a pot. */ say 'unsorted =' list /*display what's being shown.*/ size=words(list) /*nice to have # of elements.*/ do j=1 for size /*build an array, a single */ @.j=word(list,j) /* ··· element at a time.*/ end /*j*/ call eSort size /*sort the collection of #s. */ \$= /*list: define as null so far*/ do k=1 for size /*build a list from the array*/ \$=\$ @.k /*append a number to the list*/ end /*k*/ say ' sorted =' space(\$) /*display the sorted list. */ exit /*stick a fork in it, we're all done.*/ /*──────────────────────────────────────────────────────────────────────────────────────*/ eSort: procedure expose @.; parse arg N; h=N /*an eXchange sort.*/ do while h>1; h= h%2 /*define a segment.*/ do i=1 for N-h; j=i; k= h+i /*sort top segment.*/ do while @.k<@.j /*see if need swap.*/ parse value @.j @.k with @.k @.j /*swap two elements*/ if h>=j then leave; j= j-h; k= k-h /*this part sorted?*/ end /*while @.k<@.j*/ end /*i*/ end /*while h>1*/ return ``` {{out|output|text= when using the default internal inputs:}} ```txt unsorted = 1 1 2 5 15 52 203 877 4140 21147 115975 1 -1 1 0 -1 0 1 0 -1 0 5 0 -691 0 7 0 -3617 3 0 2 3 2 5 5 7 10 12 17 22 29 39 51 68 90 sorted = -3617 -691 -1 -1 -1 0 0 0 0 0 0 0 0 1 1 1 1 1 2 2 2 3 3 5 5 5 5 7 7 10 12 15 17 22 29 39 51 52 68 90 203 877 4140 21147 115975 ``` ## Ring ```ring aArray = [2,4,3,1,2] see sort(aArray) ``` ## Ruby ```ruby nums = [2,4,3,1,2] sorted = nums.sort # returns a new sorted array. 'nums' is unchanged p sorted #=> [1, 2, 2, 3, 4] p nums #=> [2, 4, 3, 1, 2] nums.sort! # sort 'nums' "in-place" p nums #=> [1, 2, 2, 3, 4] ``` ## Rust Uses merge sort in place (undocumented), allocating ~2*n memory where n is a length of an array. ```rust fn main() { let mut a = vec!(9, 8, 7, 6, 5, 4, 3, 2, 1, 0); a.sort(); println!("{:?}", a); } ``` ## Scala ### Array Scala's "default" Array is a ''mutable'' data structure, very close to Java's Array. Generally speaking, that means an "array" is not very Scala-lesque, even as mutable data structures go. It can serves a purpose, though. If array is the right data type for your need, then that is how you sort it. ```Scala import scala.compat.Platform object Sort_an_integer_array extends App { val array = Array((for (i <- 0 to 10) yield scala.util.Random.nextInt()): _* /*Sequence is passed as multiple parameters to Array(xs : T*)*/) /** Function test the array if it is in order */ def isSorted[T](arr: Array[T]) = array.sliding(2).forall(pair => pair(0) <= pair(1)) assert(!isSorted(array), "Not random") scala.util.Sorting.quickSort(array) assert(isSorted(array), "Not sorted") println(s"Array in sorted order.\nSuccessfully completed without errors. [total \${Platform.currentTime - executionStart} ms]") } ``` ### List ```Scala println(List(5,2,78,2,578,-42).sorted) //--> List(-42, 2, 2, 5, 78, 578) ``` ## Scheme {{works with|Guile}} Same as [[Common Lisp]] ```scheme (sort #(9 -2 1 2 8 0 1 2) #'<) ``` Sorting is also available through SRFIs. SRFI 132 provides separate list-sort and vector-sort routines: ```scheme > (import (srfi 132)) > (list-sort < '(9 -2 1 2 8 0 1 2)) (-2 0 1 1 2 2 8 9) > (vector-sort < #(9 -2 1 2 8 0 1 2)) #(-2 0 1 1 2 2 8 9) ``` SRFI 132 replaced the older SRFI 95, which is still found in many implementations. SRFI 95 provides a generic sort function (but note the order of the sequence and comparator!): ```scheme > (import (srfi 95)) > (sort '(9 -2 1 2 8 0 1 2) <) (-2 0 1 1 2 2 8 9) > (sort #(9 -2 1 2 8 0 1 2) <) #(-2 0 1 1 2 2 8 9) ``` ## Seed7 ```seed7 var array integer: nums is [] (2, 4, 3, 1, 2); nums := sort(nums); ``` ## Sidef ```ruby var nums = [2,4,3,1,2]; var sorted = nums.sort; # returns a new sorted array. nums.sort!; # sort 'nums' "in-place" ``` ## Slate ```slate #(7 5 2 9 0 -1) sort ``` ## Smalltalk ```smalltalk #(7 5 2 9 0 -1) asSortedCollection ``` or destructive: ```smalltalk #(7 5 2 9 0 -1) sort ``` ## Sparkling ```sparkling var arr = { 2, 8, 1, 4, 6, 5, 3, 7, 0, 9 }; sort(arr); ``` ## Standard ML The Standard ML Basis library does not have any sorting facilities. But each implementation of Standard ML has its own. ### Array {{works with|SML/NJ}} ```sml - val nums = Array.fromList [2, 4, 3, 1, 2]; val nums = [|2,4,3,1,2|] : int array - ArrayQSort.sort Int.compare nums; val it = () : unit - nums; val it = [|1,2,2,3,4|] : int array ``` {{works with|Moscow ML}} ```sml > val it = () : unit > val it = () : unit - val nums = Array.fromList [2, 4, 3, 1, 2]; > val nums = : int array - Arraysort.sort Int.compare nums; > val it = () : unit - Array.foldr op:: [] nums; > val it = [1, 2, 2, 3, 4] : int list ``` ### List {{works with|SML/NJ}} ```sml - val nums = [2, 4, 3, 1, 2]; val nums = [2,4,3,1,2] : int list - val sorted = ListMergeSort.sort op> nums; val sorted = [1,2,2,3,4] : int list ``` {{works with|Moscow ML}} ```sml > val it = () : unit > val it = () : unit - val nums = [2, 4, 3, 1, 2]; > val nums = [2, 4, 3, 1, 2] : int list - val sorted = Listsort.sort Int.compare nums; > val sorted = [1, 2, 2, 3, 4] : int list ``` ## Stata ### Sort a Stata dataset See '''[https://www.stata.com/help.cgi?sort sort]''' in Stata help. ```stata . clear . matrix a=(2,9,4,7,5,3,6,1,8)' . qui svmat a . sort a . list +----+ | a1 | |----| 1. | 1 | 2. | 2 | 3. | 3 | 4. | 4 | 5. | 5 | |----| 6. | 6 | 7. | 7 | 8. | 8 | 9. | 9 | +----+ ``` ### Sort a macro list See '''[https://www.stata.com/help.cgi?macrolists macrolists]''' in Stata help for other functions on lists stored in macros. ```stata . local a 2 9 4 7 5 3 6 1 8 . di "`: list sort a'" 1 2 3 4 5 6 7 8 9 ``` ### Mata See Mata's '''[http://www.stata.com/help.cgi?mf_sort sort]''' function. ```stata mata : a=2\9\4\7\5\3\6\1\8 : sort(a,1) 1 +-----+ 1 | 1 | 2 | 2 | 3 | 3 | 4 | 4 | 5 | 5 | 6 | 6 | 7 | 7 | 8 | 8 | 9 | 9 | +-----+ end ``` ## Swift ### Sort in place {{works with|Swift|2.x+}} ```swift var nums = [2, 4, 3, 1, 2] nums.sortInPlace() print(nums) ``` or ```swift var nums = [2, 4, 3, 1, 2] nums.sortInPlace(<) print(nums) ``` {{works with|Swift|1.x}} ```swift var nums = [2, 4, 3, 1, 2] nums.sort(<) println(nums) ``` or ```swift var nums = [2, 4, 3, 1, 2] sort(&nums) println(nums) ``` or ```swift var nums = [2, 4, 3, 1, 2] sort(&nums, <) println(nums) ``` ### Return new array You could also create a new sorted array without affecting the original one: {{works with|Swift|2.x+}} ```swift let nums = [2,4,3,1,2].sort() print(nums) ``` or ```swift let nums = [2,4,3,1,2].sort(<) print(nums) ``` {{works with|Swift|1.x}} ```swift let nums = sorted([2,4,3,1,2]) println(nums) ``` or ```swift let nums = [2,4,3,1,2].sorted(<) println(nums) ``` ## Tcl ```tcl set result [lsort -integer \$unsorted_list] ``` Store input into L1, run prgmSORTBTIN, and L2 will be L1, only sorted. :L1→L2 :SortA(L2) SortA is found via: [LIST] → ENTER. SortD is also available for a descending sort. ## Toka This can be done by using the bubble sort library: ```toka needs bsort arrayname number_elements bsort ``` See the Toka entry on [[Bubble Sort]] for a full example. ## UNIX Shell Each shell parameter separates the integers using the default IFS whitespace (space, tab, newline). ```bash nums="2 4 3 1 5" sorted=`printf "%s\n" \$nums | sort -n` echo \$sorted # prints 1 2 3 4 5 ``` Alternate solution: sorted=`for i in \$nums; do echo \$i; done | sort -n` ---- Some shells have real arrays. You still need IFS to split the string from sort -n to an array. {{works with|pdksh|5.2.14}} ```bash set -A nums 2 4 3 1 5 set -A sorted \$(printf "%s\n" \${nums[*]} | sort -n) echo \${sorted[*]} # prints 1 2 3 4 5 ``` Users of [[bash]], [[ksh93]] and [[mksh]] can probably use the nums=(2 4 3 1 2) syntax. ## Ursa ```ursa>decl int< nums append 2 4 3 1 2 nums sort nums ``` ## Ursala using the built in sort operator, -<, with the nleq library function for comparing natural numbers ```Ursala #import nat #cast %nL example = nleq-< <39,47,40,53,14,23,88,52,78,62,41,92,88,66,5,40> ``` output: ```txt <5,14,23,39,40,40,41,47,52,53,62,66,78,88,88,92> ``` ## WDTE ```WDTE>let a = import 'arrays'; a.sort [39; 47; 40; 53; 14; 23; 88; 52; 78; 62; 41; 92; 88; 66; 5; 40] < -- io.writeln io.stdout; ``` ## Wortel ```wortel @sort [39 47 40 53 14 23 88 52 78 62 41 92 88 66 5 40] ``` ## XPL0 ```XPL0 include c:\cxpl\codes; \intrinsic 'code' declarations proc SSort(A, N); \Shell sort array in ascending order int N; \number of elements in array (size) int I, J, Gap, JG, T; [Gap:= N>>1; while Gap > 0 do [for I:= Gap to N-1 do [J:= I - Gap; loop [JG:= J + Gap; if A(J) <= A(JG) then quit; T:= A(J); A(J):= A(JG); A(JG):= T; \swap elements J:= J - Gap; if J < 0 then quit; ]; ]; Gap:= Gap>>1; ]; ]; \SSort int A, I; [A:= [3, 1, 4, 1, 5, 9, 2, 6, 5, 4]; SSort(A, 10); for I:= 0 to 10-1 do [IntOut(0, A(I)); ChOut(0, ^ )]; CrLf(0); ] ``` Output: ```txt 1 1 2 3 4 4 5 5 6 9 ``` ## Yabasic ```Yabasic export sub shell_sort(x()) // Shell sort based on insertion sort local gap, i, j, first, last, tempi, tempj last = arraysize(x(),1) gap = int(last / 10) + 1 while(TRUE) first = gap + 1 for i = first to last tempi = x(i) j = i - gap while(TRUE) tempj = x(j) if tempi >= tempj then j = j + gap break end if x(j+gap) = tempj if j <= gap then break end if j = j - gap wend x(j) = tempi next i if gap = 1 then return else gap = int(gap / 3.5) + 1 end if wend end sub if peek\$("library") = "main" then clear screen ITEMS = 100 dim numeros(ITEMS) for n = 1 to ITEMS numeros(n) = ran(ITEMS + 1) next n print time\$ shell_sort(numeros()) print time\$ print "Press a key to see ordered numbers." inkey\$ for n = 1 to ITEMS print numeros(n),", "; next n end if ``` ## Yorick In Yorick, ''sort'' returns an index list into the array that will put it in sorted order. ```yorick nums = [2,4,3,1,2]; nums = nums(sort(nums)); ``` ## zkl ```zkl a:=L(4,5,2,6); a.sort(); a.println() //--> L(2,4,5,6) ```
19,467
55,351
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.78125
3
CC-MAIN-2024-22
latest
en
0.425093
https://www.coursehero.com/file/1675678/Ch07/
1,518,933,750,000,000,000
text/html
crawl-data/CC-MAIN-2018-09/segments/1518891811655.65/warc/CC-MAIN-20180218042652-20180218062652-00565.warc.gz
818,162,769
28,559
{[ promptMessage ]} Bookmark it {[ promptMessage ]} Ch07 - Chapter 7 Utility and Demand I The Households Budget... This preview shows pages 1–2. Sign up to view the full content. C h a p t e r 7 : U t i l i t y a n d D e m a n d I. The Household’s Budget A. Consumption Possibilities 1. A household’s consumption choices are constrained by its income and the prices of the goods and services it buys. 2. A household’s budget line describes the limits to its consumption choices. 3. Figure 7.1 shows a budget line, which separates those combinations of goods that the household can afford (points below and on the budget line) from those combinations that it cannot afford (points above the budget line). B. Relative Price 1. A relative price is the price of one good divided by the price of another good. a) The magnitude of the slope of the budget line is the relative price of the good measured on the x -axis. b) A change in the relative price changes the slope of the budget line. c) Figure 7.2 (a) shows how changes in the relative price of a movie rotates the budget line. C. Real Income 1. A household’s real income is the household’s income expressed as the quantity of goods that the household can buy. a) A change in real income shifts the budget line but does not change its slope. b) Figure 7.2 (b) shows how changes in real income shift the budget line. II. Preferences and Utility A. A household’s preferences determine the benefits or satisfaction a person receives consuming a good or service. 1. The benefit or satisfaction from the consumption a good or service is called utility . B. Total Utility 1. Total utility is the total benefit a person gets from the consumption of goods. Generally, more consumption gives more utility. 2. This preview has intentionally blurred sections. Sign up to view the full version. View Full Document This is the end of the preview. Sign up to access the rest of the document. {[ snackBarMessage ]} Page1 / 3 Ch07 - Chapter 7 Utility and Demand I The Households Budget... This preview shows document pages 1 - 2. Sign up to view the full document. View Full Document Ask a homework question - tutors are online
502
2,174
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.515625
3
CC-MAIN-2018-09
latest
en
0.886615
http://www.enhancestyleteam.com/deflection-of-cantilever-beam-due-to-shear-forces/
1,642,636,260,000,000,000
text/html
crawl-data/CC-MAIN-2022-05/segments/1642320301592.29/warc/CC-MAIN-20220119215632-20220120005632-00654.warc.gz
96,014,959
12,435
# Deflection Of Cantilever Beam Due To Shear Forces Chapter 4 shear forces and bending moments stresses in a tapered beam top dog cantilever beam skyciv ering deflection of a cantilever beam bending moment diagrams sfd bmd Cantilever Beams Moments And Deflections Cantilever Beam Point Load At Any Cantilever Beams Moments And Deflections Beam Stress Deflection Mechanicalc Shear Force And Bending Moment Diagram For Cantilever 000124 Calculation Of Bending Moment Shear Force Amount Deflection Angle Inclination Slope Single Span Beam Cantilever Uniformly Distributed Load Tip Deflections Of The Tapered Cantilever Beam Subjected To M0 P0 And Q Scientific Diagram Cantilever Beam Udl And End Bending Moment Determine The Maximum Deflection Of Cantilevered Beam Is Made A Material Having An E 200 Gpa And I 69 106 Mm 6 Study Shear Force Bending Moment Diagram Of Cantilever Beam Exles Ering Intro Shear Deformation Of Beams Using Virtual Work Method Structville Solved Consider A Cantilever Beam Of Length L Width B And Chegg 4 5 Shear Force And Bending Moment Of Cantilever Beams Strength Materials Schematic Of A Cantilever Beam In Bending Scientific Diagram What Is The Shear Force And Bending Moment Of A Cantilever Beam If Point Load On Middle Its Length Quora 000130 Calculation Of Bending Moment Shear Force Amount Deflection Angle Inclination Slope Single Span Beam Cantilever Partial Lily Distributed Load Increase Beam Deflection Tables Mechanicalc Is A Plot Of The Bending Moment Double And Shear Force In Scientific Diagram Cantilever Beam Point Load And Bending Moment At End Beam stress deflection mechanicalc deflection of a cantilever beam subject to bined end force and scientific diagram chapter 4 shear forces and bending moments 000124 calculation of bending moment shear force amount deflection angle inclination slope single span beam cantilever uniformly distributed load get for the cantilever beam and loading shown determine a slope transtutors
457
1,991
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.515625
3
CC-MAIN-2022-05
latest
en
0.542656
https://www.bestcollege.info/math-4th-grade-kahoot/
1,656,265,822,000,000,000
text/html
crawl-data/CC-MAIN-2022-27/segments/1656103271763.15/warc/CC-MAIN-20220626161834-20220626191834-00140.warc.gz
721,553,934
14,132
If you’re looking for Math 4th Grade Kahoot, you’ve come to the right place. Use the relevant links provided below to gain direct access. 4th Grade FSA Math Review – Kahoot We would like to show you a description here but the site won’t allow us. 4th Grade Math Kahoot Game! | Small Online Class for Ages … In this one time class, we will practice various 4th grade math concepts in an exciting, fun, challenging game of Kahoot! Compete against other learners as you practice addition, subtraction, multiplication, division, fractions, decimals, place value, word problems, and more! Kahoot! – Miss Ayers4th Grade Math – Weebly 4th Grade Math. Home Strategy Examples Homework Table of Contents Websites Used Engage NY Resources Kahoot! Perseverance Problems Kahoot! Multiplication! Multiples and Factors. Division. Triangles. Geometry. Powered by Create your own unique website with customizable templates. Get Started. Home Strategy Examples … 4th Grade Math Kahoot Review 1 – Instructure https://indianriver.instructure.com/courses/60649/modules/items/382788 4th Grade Math Kahoot Review 1. 4th Grade Math Kahoot Review 1 Grades 4-7 Archives | Kahoot! Barron’s – Learn. Grow. Succeed. Ranger Rick and Ranger Rick Jr. are award-winning magazines published by the National Wildlife Federation. We have inspired children and families to care about… Check out this #Kahoot called ‘Multiplication 4th Grade … https://www.pinterest.com/pin/88875792627211139/ Nov 21, 2016 – Check out this #Kahoot called ‘Multiplication 4th Grade’ on @GetKahoot. Play it now! Kahoot! | Play this quiz now! | Kahoot, 4th grade math … https://www.pinterest.com/pin/31032684907015049/ About this resource : Math stations work so well in middle school! This bundle includes all 17 sets of math stations in my store that align to 8th grade curriculums. This bundle will grow as I create more 8th stations!Each set of stations includes question sheets, student answer pages …
481
1,964
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.765625
3
CC-MAIN-2022-27
latest
en
0.8871
https://www.weegy.com/?ConversationId=69Y1IISP
1,606,891,769,000,000,000
text/html
crawl-data/CC-MAIN-2020-50/segments/1606141692985.63/warc/CC-MAIN-20201202052413-20201202082413-00034.warc.gz
900,339,261
11,228
Give the values of a, b, and c needed to write the equation's general form. 1/4x^2+5=0 A = 1/4; B = 5; C = 0 A = 1; B = 0; C = 20 A = 1; B = 0; C = -5 Question Updated 4/29/2015 11:36:33 PM Flagged by janezeshun [4/29/2015 11:21:42 PM], Edited by jeifunk [4/29/2015 11:36:33 PM] g Original conversation User: Give the values of a, b, and c needed to write the equation's general form. 1/4x^2+5=0 A = 1/4; B = 5; C = 0 A = 1; B = 0; C = 20 A = 1; B = 0; C = -5 Question Updated 4/29/2015 11:36:33 PM Flagged by janezeshun [4/29/2015 11:21:42 PM], Edited by jeifunk [4/29/2015 11:36:33 PM] Rating 8 Give the values of a, b, and c needed to write the equation's general form. 1/4x^2+5=0 is the gerneral form and a = 1.4 , b = 0 , c = 5 . Confirmed by jeifunk [4/29/2015 11:36:34 PM] Questions asked by the same visitor The force between two poles is proportional to: the inverse of the pole strengths the distance between the poles the inverse of the distance between the poles Weegy: The force between two poles is proportional to: the inverse of the distance between the poles. (More) Question Updated 4/27/2015 12:20:48 PM 32,772,300 Popular Conversations Correct the sentence by selecting the proper pronoun usage. None of ... Weegy: The coach chose us girls and him to attend the track meet. The sentence is correct as is. User: Correct the ... In the time of butterflies which character can be described as ... Weegy: The elements of health, physical, mental/emotional/spiritual, and social are interconnected and should be kept ... A galaxy that has a shape similar to a football is a(n) ____ galaxy. ... Weegy: A galaxy that has a shape similar to a football is an irregular galaxy. In Asia, the Cold war led to Potential source of radioactive material can be located where? Weegy: Potential sources of radioactive material can be located in Hospitals, Cancer treatment facilities, University ... * Get answers from Weegy and a team of really smart live experts. S L P 1 L Points 137 [Total 6770] Ratings 0 Comments 137 Invitations 0 Offline S L 1 Points 111 [Total 1225] Ratings 0 Comments 111 Invitations 0 Online S L P R Points 74 [Total 2410] Ratings 0 Comments 74 Invitations 0 Offline S L L 1 P 1 L P Points 47 [Total 10367] Ratings 0 Comments 47 Invitations 0 Offline S Points 12 [Total 13] Ratings 0 Comments 12 Invitations 0 Online S L Points 10 [Total 483] Ratings 0 Comments 10 Invitations 0 Offline S L 1 1 1 1 1 1 1 1 1 1 1 Points 10 [Total 2340] Ratings 1 Comments 0 Invitations 0 Online S L Points 10 [Total 133] Ratings 1 Comments 0 Invitations 0 Offline S L R P Points 9 [Total 2174] Ratings 0 Comments 9 Invitations 0 Offline S L Points 8 [Total 499] Ratings 0 Comments 8 Invitations 0 Offline * Excludes moderators and previous winners (Include) Home | Contact | Blog | About | Terms | Privacy | © Purple Inc.
942
2,835
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.59375
3
CC-MAIN-2020-50
longest
en
0.931113
http://www.rhlschool.com/math4n2.htm
1,708,735,338,000,000,000
text/html
crawl-data/CC-MAIN-2024-10/segments/1707947474470.37/warc/CC-MAIN-20240223221041-20240224011041-00217.warc.gz
63,259,779
2,487
Name_______________________________________________Date_________________________ Mathematics Problem Solving Volume 4, Number 2, September 14, 1998 www.rhlschool.com Using a Calendar September 1998 Sunday Monday Tuesday Wednesday Thursday Friday Saturday (-:] (-:] 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 1. What is the date of the first Monday of the month? 2. What day of the week is it on September 20, 1998? 3. What date is exactly one week after the 7th of September? 4. There are always the same number of days in September. How many days are in September? 5. There are always 31 days in August, the month that comes right before September. What day of the week was August 30? 6. Sam was jumping around and singing because his birthday was coming in exactly 2 weeks. His birthday is September 17. On what date was Sam jumping around and singing? 7. Cheryl is having a big sale to get rid of all her junk. It will start on Friday, September 25. The last day of the sale will be Sunday, September 27. How many days long is the sale? (You probably know that figuring 27-25=2 will not give you the correct answer.) 8. The Hemlock Mills Country Fair runs from September 16 through September 23. The fair is ________ days long. Tweet G Delicious E-mail Math Problem Solving Home RHL School Home
362
1,356
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.0625
3
CC-MAIN-2024-10
latest
en
0.939631
https://www.scribd.com/document/236140431/ps1
1,566,550,250,000,000,000
text/html
crawl-data/CC-MAIN-2019-35/segments/1566027318243.40/warc/CC-MAIN-20190823083811-20190823105811-00193.warc.gz
958,567,099
56,017
You are on page 1of 4 # Exercises: ## Exercise 2.3-6 (page 37) from CLRS. Exercise 3.1-3 (page 50) from CLRS. Exercise 3.1-4 (page 50) from CLRS. 1. (11 points) Asymptotic Growth Rank the following functions by increasing order of growth; that is, nd an arrangement g 1 , g 2 , . . . , g 11 of the functions satisfying g 1 = O(g 2 ), g 2 = O(g 3 ), . . . , g 10 = O(g 11 ). Partition your list into equivalence classes such that f(n) and g(n) are in the same class if and only if f(n) = (g(n)). All the logs are in base 2. n 100 , 3 n , n 100 , 1/n, 2 2n , 10 100 n, 3 n , 1/5, 4 n , nlog n, log(n!). 2. (19 points) Suppose you are given an array A[1..n] A[1..n] of sorted integers that has been circularly shifted k positions to the right. For example, [35, 42, 5, 15, 27, 29] is a sorted array that has been circularly shifted k = 2 positions, while [27, 29, 35, 42, 5, 15] has been shifted k = 4 positions. We can obviously nd the largest element in A in O(n) time. Describe an O(log n) algorithm based on the divide-and-conquer strategy to nd the largest element in A. (You need to show that your algorithms time complexity is O(log n)) Let n = len(alist). (a) (6 points) What is the runtime of the iterative version in terms of n, and why? Be sure to state a recurrence relation and solve it. (b) (8 points) What is the runtime of the recursive version in terms of n, and why? Be sure to state a recurrence relation and solve it. (c) (5 points) Explain how you might x the recursive version so that it has the same asymptotic running time as the iterative version (but is still recursive). 1 3. (30 points) Set Intersection Python has a built in set data structure. A set is a collection of elements without repetition. In an interactive Python session, type the following to create an empty set: s = set() To nd out what operations are available on sets, type: dir(s) Some fundamental operations include add, remove, and contains and len . Note that contains and len are more commonly called with the syntax element in set and len(set). All four of these operations run in constant time i.e. O(1) time. For this problem, we will be analyzing the runtime of s.intersection(t) that takes two sets, s and t, and returns a new set with all the elements that occur in both s and t. We will then use intersection in a new version of the Document Distance code from the rst two lectures. (a) (5 points) Using notation, make a conjecture for the asymptotic running time of s.intersection(t) in terms of the sizes of the sets: |s| and |t|. Justify your conjecture. HINT: Think about the fundamental operations above. (b) (10 points) Determine experimentally the running time of s.intersection(t), by running it with dierent sized sets. Fill in the following chart. Include in your PDF submission a snippet of code that determines one of the entries in the chart. Note: there are a number of ways to time code. You can use the timeit mod- ule (see http://www.diveintopython.org/performance tuning/timeit.html for a good description of how to use it). Alternatively, if you have ipython in- stalled (see http://ipython.scipy.org), you can use their builtin timeit com- mand which is more user friendly. time in s |s| = 10 3 |s| = 10 4 |s| = 10 5 |s| = 10 6 |t| = 10 3 |t| = 10 4 |t| = 10 5 |t| = 10 6 (c) (5 points) Give an approximate formula for asymptotic running time of s.intersection(t) based on your experiments. How does this compare with your conjecture in part (a)? If the results dier from your conjecture, make a new (d) (10 points) In the Document Distance problem from the rst two lectures, we compared two documents by counting the words in each, treating theses counts 2 as vectors, and computing the angle between these two vectors. For this problem, we will change the Document Distance code to use a new metric. Now, we will only care about words that show up in both documents, and we will ignore the contributions of words that only show up in one document. docdist7.py is mostly the same as docdist6.py seen in class, however it does not implement vector angle or inner product; instead, it imports those functions from ps1.py. Currently, ps1.py contains code copied straight from docdist6.py, but you will need to modify this code to implement the new metric. Modify inner product to take a third argument, domain, which will be a set containing the words in both texts. Modify the code so that it only increases sum if the word is in domain. Dont forget to change the documentation string at the top. Modify vector angle so that it creates sets of the words in both L1 and L2, takes their intersection, and uses that intersection when calling inner product. Again, dont forget to change the docstring at the top. Run test-ps1.py to make sure your modied code works. The same test suite will be run when you submit ps1.py to the class website. Does your code take signicantly longer with the new metric? Why or why not? Submit ps1.py on the class website. All code submitted for this class will be checked for accuracy, asymptotic eciency, and clarity. 3 Iterative Version: def binarySearch(alist, item): first = 0 last = len(alist)-1 found = False midpoint = (first + last)/2 if alist[midpoint] == item: found = True else: if item < alist[midpoint]: last = midpoint-1 else: first = midpoint+1 return found Recursive Version: def binarySearch(alist, item): if len(alist) == 0: return False else: midpoint = len(alist)/2 if alist[midpoint]==item: return True else: if item<alist[midpoint]: return binarySearch(alist[:midpoint],item) else: return binarySearch(alist[midpoint+1:],item) 4
1,536
5,608
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.796875
4
CC-MAIN-2019-35
latest
en
0.92116
https://number.academy/4004937
1,718,841,877,000,000,000
text/html
crawl-data/CC-MAIN-2024-26/segments/1718198861853.72/warc/CC-MAIN-20240619220908-20240620010908-00437.warc.gz
382,607,905
11,180
# Number 4004937 facts The odd number 4,004,937 is spelled 🔊, and written in words: four million, four thousand, nine hundred and thirty-seven, approximately 4.0 million. The ordinal number 4004937th is said 🔊 and written as: four million, four thousand, nine hundred and thirty-seventh. The meaning of the number 4004937 in Maths: Is it Prime? Factorization and prime factors tree. The square root and cube root of 4004937. What is 4004937 in computer science, numerology, codes and images, writing and naming in other languages ## What is 4,004,937 in other units The decimal (Arabic) number 4004937 converted to a Roman number is (M)(M)(M)(M)(IV)CMXXXVII. Roman and decimal number conversions. #### Time conversion (hours, minutes, seconds, days, weeks) 4004937 seconds equals to 1 month, 2 weeks, 4 days, 8 hours, 28 minutes, 57 seconds 4004937 minutes equals to 8 years, 3 months, 1 week, 2 days, 4 hours, 57 minutes ### Codes and images of the number 4004937 Number 4004937 morse code: ....- ----- ----- ....- ----. ...-- --... Sign language for number 4004937: Number 4004937 in braille: QR code Bar code, type 39 Images of the number Image (1) of the number Image (2) of the number More images, other sizes, codes and colors ... ## Share in social networks #### Is Prime? The number 4004937 is not a prime number. #### Factorization and factors (dividers) The prime factors of 4004937 are 3 * 3 * 3 * 148331 The factors of 4004937 are 1, 3, 9, 27, 148331, 444993, 1334979, 4004937. Total factors 8. Sum of factors 5933280 (1928343). #### Powers The second power of 40049372 is 16.039.520.373.969. The third power of 40049373 is 64.237.268.607.962.284.032. #### Roots The square root √4004937 is 2001,233869. The cube root of 34004937 is 158,805387. #### Logarithms The natural logarithm of No. ln 4004937 = loge 4004937 = 15,203038. The logarithm to base 10 of No. log10 4004937 = 6,602596. The Napierian logarithm of No. log1/e 4004937 = -15,203038. ### Trigonometric functions The cosine of 4004937 is -0,991859. The sine of 4004937 is -0,127338. The tangent of 4004937 is 0,128383. ## Number 4004937 in Computer Science Code typeCode value 4004937 Number of bytes3.8MB Unix timeUnix time 4004937 is equal to Monday Feb. 16, 1970, 8:28:57 a.m. GMT IPv4, IPv6Number 4004937 internet address in dotted format v4 0.61.28.73, v6 ::3d:1c49 4004937 Decimal = 1111010001110001001001 Binary 4004937 Decimal = 21112110202000 Ternary 4004937 Decimal = 17216111 Octal 4004937 Decimal = 3D1C49 Hexadecimal (0x3d1c49 hex) 4004937 BASE64NDAwNDkzNw== 4004937 SHA1c2c78a5950f2b3462bd048792b4ea1e1bb684c24 4004937 SHA2246e0a7710712a4f04cce9fe753e32bda7521010041a7795bda35ccd87 4004937 SHA256fe75fe785dd3d11aba1d10baefddfbca4cf605d32af2b59a816e9f24f4979961 4004937 SHA38496f11da8299fca8b109a62215b24d478f1017536a63df920112350f4e44d5a8fef7a65ab334711306b6c8dbe629c8a4e More SHA codes related to the number 4004937 ... If you know something interesting about the 4004937 number that you did not find on this page, do not hesitate to write us here. ## Numerology 4004937 ### Character frequency in the number 4004937 Character (importance) frequency for numerology. Character: Frequency: 4 2 0 2 9 1 3 1 7 1 ### Classical numerology According to classical numerology, to know what each number means, you have to reduce it to a single figure, with the number 4004937, the numbers 4+0+0+4+9+3+7 = 2+7 = 9 are added and the meaning of the number 9 is sought. ## № 4,004,937 in other languages How to say or write the number four million, four thousand, nine hundred and thirty-seven in Spanish, German, French and other languages. The character used as the thousands separator. Spanish: 🔊 (número 4.004.937) cuatro millones cuatro mil novecientos treinta y siete German: 🔊 (Nummer 4.004.937) vier Millionen viertausendneunhundertsiebenunddreißig French: 🔊 (nombre 4 004 937) quatre millions quatre mille neuf cent trente-sept Portuguese: 🔊 (número 4 004 937) quatro milhões e quatro mil, novecentos e trinta e sete Hindi: 🔊 (संख्या 4 004 937) चालीस लाख, चार हज़ार, नौ सौ, सैंतीस Chinese: 🔊 (数 4 004 937) 四百万四千九百三十七 Arabian: 🔊 (عدد 4,004,937) أربعة ملايين و أربعة آلاف و تسعمائة و سبعة و ثلاثون Czech: 🔊 (číslo 4 004 937) čtyři miliony čtyři tisíce devětset třicet sedm Korean: 🔊 (번호 4,004,937) 사백만 사천구백삼십칠 Danish: 🔊 (nummer 4 004 937) fire millioner firetusinde og nihundrede og syvogtredive Hebrew: (מספר 4,004,937) ארבעה מיליון וארבעת אלפים תשע מאות שלושים ושבע Dutch: 🔊 (nummer 4 004 937) vier miljoen vierduizendnegenhonderdzevenendertig Japanese: 🔊 (数 4,004,937) 四百万四千九百三十七 Indonesian: 🔊 (jumlah 4.004.937) empat juta empat ribu sembilan ratus tiga puluh tujuh Italian: 🔊 (numero 4 004 937) quattro milioni e quattromilanovecentotrentasette Norwegian: 🔊 (nummer 4 004 937) fire million fire tusen ni hundre og trettisyv Polish: 🔊 (liczba 4 004 937) cztery miliony cztery tysiące dziewięćset trzydzieści siedem Russian: 🔊 (номер 4 004 937) четыре миллиона четыре тысячи девятьсот тридцать семь Turkish: 🔊 (numara 4,004,937) dörtmilyondörtbindokuzyüzotuzyedi Thai: 🔊 (จำนวน 4 004 937) สี่ล้านสี่พันเก้าร้อยสามสิบเจ็ด Ukrainian: 🔊 (номер 4 004 937) чотири мільйони чотири тисячі дев'ятсот тридцять сім Vietnamese: 🔊 (con số 4.004.937) bốn triệu bốn nghìn chín trăm ba mươi bảy Other languages ... ## News to email I have read the privacy policy ## Comment If you know something interesting about the number 4004937 or any other natural number (positive integer), please write to us here or on Facebook. #### Comment (Maximum 2000 characters) * The content of the comments is the opinion of the users and not of number.academy. It is not allowed to pour comments contrary to the laws, insulting, illegal or harmful to third parties. Number.academy reserves the right to remove or not publish any inappropriate comment. It also reserves the right to publish a comment on another topic. Privacy Policy.
2,031
5,928
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
3.21875
3
CC-MAIN-2024-26
latest
en
0.754321
https://prezi.com/s0fix_80z6fc/cs135-exam-review-session/
1,542,537,866,000,000,000
text/html
crawl-data/CC-MAIN-2018-47/segments/1542039744348.50/warc/CC-MAIN-20181118093845-20181118115212-00023.warc.gz
694,446,395
27,239
### Present Remotely Send the link below via email or IM • Invited audience members will follow you as you navigate and present • People invited to a presentation do not need a Prezi account • This link expires 10 minutes after you close the presentation Do you really want to delete this prezi? Neither you, nor the coeditors you shared it with will be able to recover it again. # CS135 Exam Review Session No description by ## Eric Folland on 14 March 2011 Report abuse #### Transcript of CS135 Exam Review Session How to use listof properly Types of recursion and how to determine the type Local Lambda Abstraction and ALFs Trees Last office hours Check your exam seat! CS 135 Exam Review Incorrect: Correct: (list-of-characters) listof Character (listof Characters) (listof lists) (listof Character) (listof (listof Character)) Pure Structural Examples: ;This example follows the list data definition (define (pure-structural1 lst) (cond [(empty? lst) 0] [(cons? lst) (add1 (pure-structural1 (rest lst)))])) ;This example follows from the unary definition of a natural number (define (pure-structural2 n) (cond [(zero? n) empty] [else (cons n (pure-structural2 (sub1 n)))])) Base case Recursive call gets closer to the base case Recursion follows the recursion of the data definition Pure Structural with an Accumulator Accumulators vs. "along for the ride" vs. "counters" Same as Pure Structural, but rather than accumulating on the return result, accumulates on a parameter Examples: ;This example follows the list data definition (define (pure-structural/acc1 lst items-so-far) (cond [(empty? lst) items-so-far] [(cons? lst) (pure-structural1 (rest lst) (add1 items-so-far))])) ;This example follows from the unary definition of a natural number (define (pure-structural/acc2 n list-so-far) (cond [(zero? n) empty] [else (pure-structural2 (sub1 n) (cons n list-so-far))])) Generative Still has a base case Termination argument vs. "one step closer to the base case" Recursive step does not follow from the data definition Examples: ;This has a chance of terminating each call (define (generative1 x) (cond [(zero? x) empty] [else (cons x (generative1 (random-0-to-9 x)))])) ;This will surely terminate, but is not based on the data definition (define (generative2 lst) (cond [(empty? lst) empty] [else (generative2 (filter (lambda (x) (equal? x (first lst))) lst))])) Scope, binding occurrence Stepping When to use it over external helper functions/constants ;Scope example (define x 5) (define (f x) (+ (local [(define x 7)] (+ x 3)) x)) (+ (f 3) (f x)) ;Local stepping example (define (foo a) (local [(define x (+ 1 2)) (define y 3)] (+ x y a))) (foo (+ 1 2)) ;can't call a function until its arguments are simplest form (foo 3) ;replace the function with its body, subbing in arguments (local [(define x (+ 1 2)) (define y 3)] (+ x y 3)) ;local's first step is to take out the defines ;replace all instances of those constants with their new name (define x_0 (+ 1 2)) (define y_0 3) (+ x_0 y_0 3) ;simplify the first thing first ;also, exclude any defines that are in simplest form. they ; are still there, but not shown (define x_0 3) (+ x_0 y_0 3) ;substitute one constant at a time: first x_0 (+ 3 y_0 3) ;now y_0 (+ 3 3 3) ;pre-defined functions happen in one step 9 Local can also be used for readability. If it makes more sense to have a local helper function or local constant, then it should probably be used. Namespace Efficiency Readability When creating a very large program or working in a team, there can be a big list of functions. That's why it's important to "hide" helper functions inside of local. On the other hand, if a helper function is useful for more than one function, it should be outside of local. The same goes for constants. Something like pi might be useful for many functions, but something specific like sum-so-far should be local. As we've seen before, local can also be used to make a program more efficient, by storing the result of a recursive call in a local constant. This only needs to be done if you will then access that constant more than once afterward. Stepping When to use lambda Examples of how to use it ;if we look at a regular function and application (define (foo x y) (+ x y)) (foo 1 2) ;here, the first step is replace the function ;name with its body, subbing in all arguments (+ 1 2) ;and finish 3 ;here is the same starting code, but using lambda. ;there are still 2 parameters, a function body, and 2 ;arguments ((lambda (x y) (+ x y)) 1 2) ;the step is logically similar here: replace the ;lambda with the body of the function, subbing in ;all arguments, which are the 1 and 2 (+ 1 2) ;and finish 3 ;this is a similar example, except now foo is a ;constant that holds a function. this is really the ;same as a function, but here we'll have an extra step (define foo (lambda (x y) (+ x y))) (foo 1 2) ;now foo is a constant, so, like any constant, it takes ;a step to sub in ((lambda (x y) (+ x y)) 1 2) ;now we continue like the last example (+ 1 2) ;and finish 3 Use lambda when the code is trivial. It is typically used in abstract list functions like quicksort, map, filter, foldr, foldl, or ones you make yourself. Although it is possible to use (define foo (lambda (x y) (+ x y))), it is considered more readable to use (define (foo x y) (+ x y)), which is the same. ;when you need a function to produce a function: (define (foo a) (lambda (x) (char=? a x))) ;think about what this would do ;notice that this is different from (define (foo a) (char=? a __)) ;this wouldn't work ;when you use a function that consumes a function, and ;it's too simple to make it a helper function (map (lambda (x) (* x 2)) (list 1 2 3 4)) There will be many more examples coming up. quicksort build-list map filter foldr quicksort requires you to give it a function that consumes two numbers it's trying to compare. Your function should produce true if the first should come before the second. (define numbers (list 5 2 7 4 1 3)) Sort ascending: (quicksort numbers <) --> (list 1 2 3 4 5 7) Sort descending: (quicksort numbers >) --> (list 7 5 4 3 2 1) Put even first: (quicksort numbers (lambda (num1 num2) (even? num1))) --> (list 4 2 5 7 1 3) build-list requires you to give it a function that consumes one number, which will hold the value of each number up to n as it gets called each time. Your function can produce anything, using the number it's given for calculations. Build list always consumes a number and produces a list with that many items. (define numbers (list 5 2 7 4 1 3)) Make 0 to 9: (build-list 10 (lambda (x) x)) OR (build-list 10 identity) --> (list 0 1 2 3 4 5 6 7 8 9) Make 1 to 10: (build-list 10 (lambda (x) (add1 x))) OR (build-list 10 add1) --> (list 1 2 3 4 5 6 7 8 9 10) Make even 2 to 20: (build-list 10 (lambda (x) (add1 (* 2 x)))) --> (list 2 4 6 8 10 12 14 16 18 20) Make 0 to 4 as lists: (build-list 10 (lambda (x) (list x))) OR (build-list 10 list) --> '((0) (1) (2) (3) (4)) map requires you to give it a function that consumes one item, which will be each item in the given list and it should return what you want that item to turn into. Unlike build-list, the item consumed doesn't have to be a number. Map always consumes a list and produces a list with the same number of items, but those items are all transformed into something else using the function you give it. (define numbers (list 5 2 7 4 1 3)) Double each number: (map (lambda (x) (* 2 x)) numbers) --> (list 10 4 14 8 2 6) (map (lambda (x) (add1 x)) numbers) OR (map add1 numbers) --> (list 6 3 8 5 2 4) Change them all into 'a: (map (lambda (x) 'a) numbers) --> (list 'a 'a 'a 'a 'a 'a) filter requires you to give it a function that consumes each item like map, but will produce true or false. True means keep the item and false means don't include it in the new list. filter always consumes a list and produces a list with equal or fewer items. (define numbers (list 5 2 7 4 1 3)) Keep only even numbers: (filter even? numbers) --> (list 2 4) Keep only numbers greater than 4: (filter (lambda (x) (> x 4)) numbers) --> (list 5 7) Keep only symbols: (filter symbol? numbers) --> empty foldr requires you to give it a function that consumes two items: the first of these is each item in the list and the second is the result of calling your function on the rest of the list. Your function should do something to combine the item onto the result of the rest. foldr always consumes a list but can produce anything. It will only produce a list if your function acts like cons. What type it produces depends on the function you give it. (define numbers (list 5 2 7 4 1 3)) Count the number of items: (foldr add1 0 numbers) --> 6 Sum the numbers: (foldr + 0 numbers) --> 22 Make the exact same list: (foldr cons empty numbers) --> (list 5 2 7 4 1 3) Double each number: (foldr (lambda (x y) (cons (* 2 x) y)) empty numbers) --> (list 10 4 14 8 2 6) Recursion for BST Mutual recursion for a General Tree (Demonstrate on the board) Searching Removing a node (Demonstrate on the board) Searching Assignment 7 q3 and q4 Thursday Friday 4-5pm Eric 9-10am Max 10am-12pm Eric 12-1pm Minghao 2pm-3:30 Prof Becker To look up your exam seat: Go to the course web page --> Exams --> a link in the text that says "look up" Monday, December 20, 2010 12:30-3:00 PM in the PAC Relax and do your best! :) ;; zip: (listof Any) (listof Any) -> (listof (list Any Any)) (define (zip lst1 lst2) (cond [(and (empty? lst1) (empty? lst2)) empty] [else (cons (list (first lst1) (first lst2)) (zip (rest lst1) (rest lst2)))])) ;; dot-product: (listof Num) (listof Num) -> Num (define (dot-product lst1 lst2) (cond [(and (empty? lst1) (empty? lst2)) 0] [else (+ (* (first lst1) (first lst2)) (dot-product (rest lst1) (rest lst2)))])) ;; map-combine: Z (W X -> Y) (Y Z -> Z) (listof W) (listof X) -> Z (define (map-combine base func-elem func-lst lst1 lst2) (cond [(and (empty? lst1) (empty? lst2)) base] [else (func-lst (func-elem (first lst1) (first lst2)) (map-combine base func-elem func-lst (rest lst1) (rest lst2)))])) (define (my-zip lst1 lst2) (map-combine empty list cons lst1 lst2)) (define (my-dot-product lst1 lst2) (map-combine 0 * + lst1 lst2)) (check-expect (zip (list 1 2 3 4 5) (list 6 7 8 9 10)) (my-zip (list 1 2 3 4 5) (list 6 7 8 9 10))) (check-expect (dot-product (list 1 3 4) (list 5 7 8)) (my-dot-product (list 1 3 4) (list 5 7 8))) Template: (define-struct node (key val left right)) ;; A binary search tree (Bst) is one of: ;; * empty ;; * (make-node Number String Bst Bst) Template: (define-struct UTnode (val children)) ;; An unbounded tree (Ut) is one of: ;; * empty ;; * (make-UTnode Any UtList) ;; A UtList is one of: ;; * empty ;; * (cons Ut UtList) Full transcript
3,167
10,801
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.65625
3
CC-MAIN-2018-47
latest
en
0.740048
https://www.coderefer.com/category/kotlin/page/2/
1,561,031,446,000,000,000
text/html
crawl-data/CC-MAIN-2019-26/segments/1560627999210.22/warc/CC-MAIN-20190620105329-20190620131329-00080.warc.gz
726,932,736
15,981
## Merge sort Kotlin Implementation – Sorting Algorithms #3 Vamsi Tallapudi 1 Comment Merge Sort is sorting based on Divide and Conquer strategy and is one of the famous algorithms among Sorting. In this article, we will be discussing about Merge Sort Kotlin Implementation. How Merge sort Works? Merge sort algorithm technique basically involves two processes – one process splits the array into two halves and sorts them individually. The other process involves … ## Bubble Sort Kotlin Implementation – Sorting Algorithms #2 Bubble Sort is the simplest Algorithm of all the sorting techniques. It compares two adjacent elements and swaps them if they are in wrong order. In this article we will focus on Bubble Sort Kotlin Implementation How Bubble Sort Works? Bubble sort works by iterating through the array of N elements, from the first element to the last, comparing each …
166
883
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.71875
3
CC-MAIN-2019-26
latest
en
0.858422
http://www.wjhsh.net/Zinn-p-9490395.html
1,653,699,685,000,000,000
text/html
crawl-data/CC-MAIN-2022-21/segments/1652663011588.83/warc/CC-MAIN-20220528000300-20220528030300-00793.warc.gz
119,810,430
5,619
 bzoj 1367 [ Baltic 2004 ] sequence —— 左偏树 ### bzoj 1367 [ Baltic 2004 ] sequence —— 左偏树 ```#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int const maxn=1e6+5; int n,t[maxn],l[maxn],r[maxn],rt[maxn],siz[maxn],num[maxn]; int ls[maxn],rs[maxn],dis[maxn]; ll ans; int abb(int x){return x>0?x:-x;} int merge(int x,int y) { if(!x||!y)return x+y; if(t[x]<t[y])swap(x,y);//维护大根堆 rs[x]=merge(rs[x],y); siz[x]=siz[ls[x]]+siz[rs[x]]+1;//+1 if(dis[ls[x]]<dis[rs[x]])swap(ls[x],rs[x]); if(rs[x])dis[x]=dis[rs[x]]+1; else dis[x]=0; return x; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&t[i]),t[i]-=i; int nw=0; for(int i=1;i<=n;i++) { l[++nw]=r[nw]=i; rt[nw]=i; siz[rt[nw]]=num[nw]=1; while(nw>1&&t[rt[nw-1]]>t[rt[nw]]) { nw--; num[nw]+=num[nw+1]; r[nw]=r[nw+1]; rt[nw]=merge(rt[nw],rt[nw+1]); while(siz[rt[nw]]*2>num[nw]+1)//+1 rt[nw]=merge(ls[rt[nw]],rs[rt[nw]]); } } for(int i=1;i<=nw;i++) for(int j=l[i];j<=r[i];j++)ans+=abb(t[j]-t[rt[i]]); printf("%lld ",ans); return 0; }```
455
1,061
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.640625
3
CC-MAIN-2022-21
latest
en
0.094692
https://testing.general.chemistrysteps.com/category/general-chemistry/chemical-kinetics/
1,721,045,666,000,000,000
text/html
crawl-data/CC-MAIN-2024-30/segments/1720763514696.4/warc/CC-MAIN-20240715102030-20240715132030-00046.warc.gz
515,575,496
23,058
Zero-Order Reactions In a zero-order reaction, the rate of the reaction is independent of the concentration of the reactant. This can be seen in the differential rate law which shows how the rate of a reaction depends on the concentration of the … Read more Second-Order Reactions In a second-order reaction, the rate of the reaction is proportional to the square of the concentration of the reactant. This can be seen in the differential rate law which shows how the rate of a reaction depends on the … Read more First-Order Reactions In first-order reactions, the rate of the reaction is directly/linearly proportional to the concentration of the reactant. This can be seen in the differential rate law which shows how the rate of a reaction depends on the concentration of the … Read more Half Life and Radioactivity Practice Problems In these practice problems, we will work on the kinetics of radioactive reactions. Most often, in chemistry at least, you will be asked to determine the activity, quantity, the decay rate of radioactive isotopes, the time required to drop the … Read more The Arrhenius Equation When discussing the reaction order, we mentioned that the rate of a first- and second-order reaction depends on the concentration of the reactant. For example, the rate for a simple first-order reaction can be shown as:   A → Products … Read more Activation Energy A chemical reaction between two molecules occurs when they collide with proper orientation and sufficient kinetic energy. During the collision, the kinetic energy is used to stretch, bend, and ultimately break bonds, initiating the chemical reaction where new bonds and … Read more The Half-Life of a Reaction The half-life (t1/2) of a reaction is the time required for the concentration of a reactant to drop to one-half of its initial value. The half-life depends on the order of the reaction, and it is obtained from the corresponding … Read more Determining Reaction Order Using Graphs In the previous post, we talked about the integrated rate law and its use for determining the concentration of a reactant at a given time when the reaction order was provided.   Now, there are questions where the reaction order … Read more Units of Rate Constant k Knowing the units of the rate constant is important as it is used often for solving problems related to the rate laws.   k Units of a Zero-Order Reaction Zero-order indicates that the rate does not depend on the concentration, … Read more How Are Integrated Rate Laws Obtained We talked about the integrated rate laws in the previous post. Remember, they show the correlation between the concentration of reactants and time. There is a question that I got asked quite a few times when teaching the contacts and … Read more
564
2,777
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.671875
3
CC-MAIN-2024-30
latest
en
0.901538
http://book.caltech.edu/bookforum/showpost.php?s=54af0fb99e0a3857ec3dc804884757dc&p=11648&postcount=1
1,582,083,309,000,000,000
text/html
crawl-data/CC-MAIN-2020-10/segments/1581875144027.33/warc/CC-MAIN-20200219030731-20200219060731-00473.warc.gz
23,244,317
4,671
View Single Post #1 02-08-2014, 07:19 PM LazyPiggy Junior Member Join Date: Feb 2014 Posts: 8 Some questions about the lecture two Recently, I'm learning the video tutorials of learning from data . Two questions are lingering in my mind about the lecture two, which focused on the feasibility of learning: the first one is that how to define the feasibility of learning? Is the Hoeffding's Inequality the useful tool to gauge feasibility for one hypothesis h? take the hypothesis h1 and h2 for example, if both satisfy the Hoeffding's Inequality, then what we should do next? Another confusion is that in the case of mutiple h's, the simple solution to the modification of Hoeffding's Inequality could be useless as M is close to infinity. In my opinion ,the Hoeffding's Inequality seems to hold in this situation for the following reason: P[ |Ein(g) − Eout(g)| > ǫ ] ≤ P[ |Ein(h1) − Eout(h1)| > ǫ or |Ein(h2) − Eout(h2)| > ǫ· · · is no more than the minimum of them, that makes the Hoeffding's Inequality satisified. Is there a logical or mathematical error ? When it comes to the exception, I think that even the best learning algorithm could meet the special situation that only few of them could be equal to the target function for randomness, or we could consider this standard : for each hypothesis hi, i=1,2,...M, toss the coin N times, then calculate the possibility of the times that coins get all heads is less than one particular value t. such as N/4 or others. Is this standard viable? All responses are appreciated. Thank you.
385
1,542
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}
2.828125
3
CC-MAIN-2020-10
latest
en
0.925577

📐 FineMath

image/png

What is it?

📐 FineMath consists of 34B tokens (FineMath-3+) and 54B tokens (FineMath-3+ with InfiMM-WebMath-3+) of mathematical educational content filtered from CommonCrawl. To curate this dataset, we trained a mathematical content classifier using annotations generated by LLama-3.1-70B-Instruct. We used the classifier to retain only the most educational mathematics content, focusing on clear explanations and step-by-step problem solving rather than advanced academic papers.

The Dataset Curation section details the process for creating the dataset.

What is being released?

The dataset is released in two versions:

  • FineMath-3+: 34B tokens, 21.4M documents containing mathematical reasoning and problem solving, formatted with Markdown and LaTeX.
  • FineMath-4+ (a subset of FineMath-3+): 9.6B tokens, 6.7M documents of higher quality with detailed explanations. Models trained on this dataset perform better on GSM8k and MATH.

We also release a filtered English text-only portion of the InfiMM-WebMath-40B dataset, classified using the same approach as FineMath:

  • InfiMM-WebMath-3+: 20.5B tokens, 13.9M documents.
  • InfiMM-WebMath-4+ (a subset of InfiMM-WebMath-3+): 8.5B tokens, 6.3M documents.

How to load the dataset

Use one of the available configs: finemath-3plus, finemath-4plus, infiwebmath-3plus, or infiwebmath-4plus.

from datasets import load_dataset

# Load the high-quality subset
data = load_dataset("HuggingFaceTB/finemath", "finemath-4plus", split="train", num_proc=8)

# Or load the larger subset
data = load_dataset("HuggingFaceTB/finemath", "finemath-3plus", split="train", num_proc=8)

Dataset curation

Recent language models like DeepSeekMath and MathStral have demonstrated strong mathematical capabilities, trained on specialized datasets that aren't publicly available. We developed a pipeline to identify and extract high-quality mathematical content from CommonCrawl, with several iterations of refinement to improve quality.

Phase 1: Initial content extraction and classification

We began by re-extracting pages from CommonCrawl WARCs using URLs from the FineWeb dataset, collecting both the latest and largest versions of each page to capture the evolution of pages across the years. Unlike FineWeb which uses Trafilatura, we employed Resiliparse for text extraction as it better preserves forum discussions and QA answers that often contain crucial reasoning steps and solutions.

For initial quality assessment, we used Llama-3.1-70B-Instruct to generate annotations on a 3-point scale:

  1. Contains general mathematical content
  2. Shows logical reasoning in mathematical context
  3. Contains clear step-by-step solutions at appropriate level

A multilingual-e5-small-based classifier finetuned on these annotations was used to score the initial corpus. However, this first version performed below the OpenWebMath baseline, leading to several important refinements.

Phase 2: Recalling more candidate pages

Analysis revealed that FineWeb's C4 filter removes pages containing '{' characters, inadvertently filtering out content with LaTeX notation. To address this and expand coverage, we:

  1. Identified promising website domains by selecting those where at least 10% of pages received a classifier score ≥ 2
  2. Added URLs from OpenWebMath and InfiMM-WebMath datasets
  3. Recovered URLs of pages filtered by FineWeb's '{' rule from its rejection logs
  4. Re-extracted all content from scratch using the OpenWebMath pipeline, which properly handles mathematical notation across various HTML markup formats and standardizes them to LaTeX

Phase 3: Refined quality assessment

The expanded corpus underwent a more fine-grained quality evaluation:

Once again, we used LLama-3.1-70B-Instruct to score a sample of newly extracted pages on a 5-point scale (full prompt available in here): We finetuned a new classifier on these annotations and scored the entire corpus. After leaving only pages with a score of 3 or higher, and deduplicating the samples using simple single-band MinHash-LSH, we obtained FineMath-3+ with 34B tokens.

The same classifier was applied to InfiMM-WebMath's text content, focusing more on reasoning rather than advanced mathematics.

Both datasets were additionally filtered using FineWeb's language classification pipeline to remove non-English content.

Decontamination

Following Qwen2.5-Math's approach, we removed samples with 13-gram overlaps against test sets from GSM8k, MATH, MMLU and ARC. Decontamination logs are available at HuggingFaceTB/finemath_contamination_report.

Results and Performance

Our evaluations show several key findings:

  1. FineMath-3+ outperforms the base InfiWebMath on GSM8k and MATH benchmarks
  2. FineMath-4+ demonstrates superior performance compared to both FineMath-3+ and InfiWebMath-4+ on GSM8k and MATH
  3. Combining the datasets (50% FineMath-3+ with 50% InfiWebMath-3+) yields approximately 50B tokens while matching the performance of FineMath-3+
  4. Deduplicating the pages repeated between FineMath and InfiWebMath reduces performance compared to a non-deduplicated combination

Dataset Schema

{
    'url': string,               # Source page URL
    'fetch_time': int64,         # Crawler timestamp
    'content_mime_type': string, # MIME type
    'warc_filename': string,     # Common Crawl WARC source file
    'warc_record_offset': int32, # WARC record offset, in bytes
    'warc_record_length': int32, # WARC record size, in bytes
    'text': string,             # Page content
    'token_count': int32,       # Number of Llama tokens
    'char_count': int32,        # Character count
    'metadata': string,         # Additional OpenWebMath metadata
    'score': float64,           # Raw quality score
    'int_score': int64,         # Integer quality score
    'crawl': string,            # Common Crawl crawl identifier
    'snapshot_type': string,    # Whether the page is the latest or the largest for this URL
    'language': string,         # Document language
    'language_score': float64   # LangID probability
}

Considerations for Using the Data

Social Impact of Dataset

With the release of this dataset, we aim to make high-quality mathematical educational content more accessible to the machine learning community. While multiple language models have demonstrated strong mathematical capabilities, the datasets used to train these capabilities are often not publicly available. By releasing FineMath, we hope to:

  • Make the dataset creation process more transparent
  • Reduce the barrier to entry for training models with strong mathematical capabilities
  • Provide a benchmark for mathematical content quality filtering

Discussion of Biases

The dataset may have certain inherent biases:

  • Focus on English language content
  • Emphasis on popular educational approaches to mathematics
  • Bias towards certain types of mathematical notation and formatting

Other Known Limitations

  • The dataset is limited to English language content
  • The filtering criteria may not capture advanced mathematical content (e.g. advanced research subjects)
  • Some mathematical notation (e.g. image-based) may not be preserved
  • Long-form content may have varying quality even within high-scoring documents

Licensing Information

The dataset is released under the Open Data Commons Attribution License (ODC-By) v1.0 license. The use of this dataset is also subject to CommonCrawl's Terms of Use.

Future work

There are several avenues for future work:

  • Expand language coverage beyond English
  • Improve mathematical notation extraction and preservation
  • Develop more sophisticated quality metrics
  • Create specialized subsets for different educational levels

Citation Information

@misc{lozhkov2024finemath,  
    author       = { Lozhkov, Anton and Ben Allal, Loubna and Bakouch, Elie and von Werra, Leandro and Wolf, Thomas },  
    title        = { FineMath: the Finest Collection of Mathematical Content }, 
    year         = 2024,  
    url          = { https://huggingface.co/datasets/HuggingFaceTB/finemath },  
    doi          = { 10.57967/hf/3847 },
    publisher    = { Hugging Face }
}
Downloads last month
21,350

Models trained or fine-tuned on HuggingFaceTB/finemath

Collection including HuggingFaceTB/finemath