[11] In these consolidated appeals, Appellants West Park Hospital District and Yellowstone Behavioral Health Center challenge the district court's denial of their petition for a writ of mandamus directing the Park County Attorney to commence court proceedings and to appear at initial emergency detention hearings under Wyo. Stat, Ann. § 25-10-1109 (LexisNexis 2018), as well as to appear and prosecute the case in chief at the involuntary hospitalization hearings under Wyo. Stat. Ann. § 25-10-110 (LexisNexis 2018). We agree with Appellants that the statutes in question do require a county attorney's office to participate in civil commitment proceedings as they claim it should. However, we also find that the statutes are ambiguous, and that the district court therefore did not abuse its discretion by refusing to issue a writ of mandamus. Therefore, although we disagree with the district court as to the county attorney's duty in civil commitment cases, we affirm.
ISSUES
[12] Two interrelated issues are raised in this appeal:
1. What are the statutorily required duties of a Wyoming county attorney in civil commitment proceedings under Wyo. Stat. Ann. §§ 25-10-109 and 1107
2. Did the district court abuse its discretion in denying Appellants' petition for writ of mandamus?
FACTS
[13] West Park Hospital District is a hospital district formed under Wyo. Stat. Ann. § 35-2401. It frequently houses patients believed to be mentally ill when they are temporarily detained pending civil commitment hearings, and if they are determined to be a danger to themselves or others, pending transportation to the Wyoming State Hospital.1 Yellowstone Behavioral Health Center (Yellowstone) is a Wyoming non-profit corporation which furnishes mental health services throughout the Big Horn Basin, and particularly in the emergency room of West Park,. Yellowstone provides examiners who evaluate patients to determine whether they must be detained for their own safety or that of the community until an involuntary commitment hearing can be held under Title 25, Chapter 10 of the Wyoming statutes.
[T4] Appellee Bryan A. Skoric is the duly elected Park County and Prosecuting Attorney. The Park County Attorney's office has historically represented the public's interest in emergency detention and involuntary hospitalization hearings under Title 25. The county attorney or his deputies filed applications for involuntary hospitalization and appeared at emergency detention hearings under § 25-10-109 as well as involuntary hospitalization hearings under § 25-10-110. If the assigned attorney from the county at*337torney's office believed detention and/or involuntary hospitalization appropriate, he or she would present the case for hospitalization by making an opening statement and closing argument, conducting direct examinations, cross-examining adverse witnesses, and preparing all necessary paperwork. Once notified that an individual was being detained on an emergency basis under § 109, the office handled all necessary commitment proceedings on behalf of the State, commencing the case in the district court and prosecuting it to completion, whether it involved just an emergency detention hearing or proceeded to an involuntary commitment hearing under § 110(h).
[T 5] In 2018, following our decision in In re RB, 2013 WY 15, 294 P.3d 24 (Wyo.2013), described below, Mr. Skoric reconsidered the extent of his office's participation in civil commitment proceedings. He determined that it lacked statutory authority to participate in emergency detention hearings under § 109, and that appearing in the public's interest at an involuntary hospitalization hearing under § 110 did not require him to present the case in chief, He concluded instead that a county attorney was only required to observe commitment proceedings and ensure that the statutes are followed at a § 110 hearing, presumably meaning that he or his deputies could sit in the back of the courtroom and speak up if something untoward took place. He feared that if his office handled cases as it had in the past, he and his deputies would not be entitled to prosecu-torial immunity from civil claims, and that they could be subject to criminal lability under Wyo. Stat. Ann. § 25-10-126.2
[16] The effect of the Park County Attorney's decision was to place the burden of going forward with emergency detention and involuntary hospitalization hearings on employees of or attorneys paid by Appellants. This led Appellants to file a Verified Petition for Writ of Mandamus pursuant to Wyo. Stat. Ann. & 1-30-101 et seq., asking the district court to compel the Park County Attorney to proceed in the same way he had for many years. They conceded, as they do in this appeal, that the county attorney has discretion to decline to pursue emergency detention or involuntary commitment in a particular case in which he believes either to be inappropriate, but claim that he could not simply refuse to appear in all such proceedings or decline to present any case for involuntary commitment while just watching the proceedings from the sideline.
[17] Mr. Skorie moved to dismiss the petition for a writ of mandamus, arguing that the writ could not be granted because the law did not impose a duty upon him or his office to participate in emergency detention hearings or to present a case for involuntary commitment. After holding a hearing and considering the arguments presented by the parties, the district court denied Appellants' application for the writ. Adhering to the strict standards for ordering such extraordinary relief, it concluded:
The issue in In the Interest of RB was the authority of the county attorney to object to the proposed release of an involuntarily hospitalized person. - However, Justice Davis, writing for a unanimous court set forth in detail the rules of statutory construction and an analysis of the role of the county attorney in Title 25 proceedings that this Court considers dis-positive, particularly in view of the standards for the issuance of a writ of mandamus as outline above.
W.S. § 25-10-109 provides that emer-geney detention may be initiated by a law enforcement officer or an examiner and in subsection (h), that the Court will conduct a hearing within 72 hours to determine whether continued detention is appropriate pending the initiation of involuntary hospi*338talization proceedings. Significantly, W.S. § 25-10-109 does not require the participation of the county attorney in order to detain a person or to determine whether continued detention is appropriate pending an application for involuntary hospitalization. Reading W.S. § 25-10-109 in the light of the Court's discussion of involuntary hospitalization procedure and examinations, this Court cannot identify a primary role for the county attorney much less a clear unambiguous duty to act. It is not until involuntary hospitalization proceedings are commenced that the legislature by enacting W.S. § 25-10-110 requires the county attorney to appear in the public interest. The Supreme Court in In the Interest of RB discusses the legitimate interest of the public at that stage of the proceedings. - However, W.S. § 25-10-110 can be fairly read to allow any interested person to commence proceedings for involuntary commitment by filing a written application with the appropriate court. The obligation of the county attorney is to "appear" in the public interest.
There are many reasons why it might be preferable to have the county attorney involved in the emergency detention proceedings provided for in W.S. § 25-10-109. Such proceedings involve public safety, public funds, and most importantly and most assuredly, the safety, the wellbeing and the liberty of proposed patients. However, the Legislature, despite several revisions through the years has not seen fit to define a role for the county attorney in the emergency detention process and arguably a non-exclusive role in the involuntary hospitalization process.
Appellants timely filed a notice of appeal from this order.
[18] Appellants also filed a motion to alter or amend the order under W.R.C.P. 59(e), essentially requesting the district court to determine what the legislature intended to require of the county attorney when he appeared "in the public interest" under § 110(c). The court denied the Rule 59(c) motion, finding that the language in § 110 does not "define a definitive role" for the county attorney in the involuntary hospitalization process. Appellants timely filed a second notice of appeal from the denial of that motion. The appeals were consolidated.
STANDARD OF REVIEW
[19] Whether there is a statutory duty which might permit issuance of a writ of mandamus is a question of law which we review de novo, adhering to our general rules of statutory construction. State ex rel. Arnold v. Ommen, 2009 WY 24, ¶ 14, 201 P.3d 1127, 1132 (Wyo.2009). Whether a writ of mandamus will be issued in a particular case is a decision entrusted to the sound discretion of the district court, and we will reverse only if the district court could not reasonably conclude as it did. Id.
DISCUSSION
Duties of a County Attorney in Involuntary Hospitalization Proceedings
[110] We must first determine whether a county attorney has the duty to participate in emergency detention hearings and to present the case for involuntary commitment. We therefore examine the applicable statutes. In interpreting statutes, our objective is to determine the legislature's intent. In re RB, ¶ 16, 294 P.3d at 29. Legislative intent must be ascertained initially and principally from the words used in the statute; for when the words are clear and unambiguous, there is a peril that a court may impermissibly substitute its own views if any attempt is made to interpret or construe statutes on any basis other than the language invoked by the legislature. Int'l Ass'n of Firefighters Local Union No. 279 v. City of Cheyenne, 2013 WY 157, ¶ 9, 316 P.3d 1162, 1166 (Wyo.2013).
[111] We look first to the plain and ordinary meaning of the words used in a statute to determine if it is ambiguous. In re RB, ¶ 16, 294 P.3d at 29. "A statute is clear and unambiguous if its wording is such that reasonable persons are able to agree on its meaning with consistency and predictability." Int'l Ass'n of Firefighters Local Union No. 279, ¶ 9, 316 P.3d at 1166. "Conversely, a statute is ambiguous if it is found to be vague or uncertain and subject to varying interpre*339tations." Id. Divergent opinions among parties as to the meaning of a statute may be evidence of ambiguity; however, the fact that there are differing opinions as to its meaning is not conclusive of ambiguity. See Romsa v. State ex rel. Wyoming Dep't of Transp., 2012 WY 146, ¶ 22, 288 P.3d 695, 702 (Wyo.2012). Whether a statute is ambiguous is a matter of law that is determined by this Court. In re RB, ¶ 16, 294 P.3d at 29.
[112] Title 25, Chapter 10 of the Wyoming statutes provides a procedure for the detention and hospitalization of a mentally ill individual, establishing a two-step hearing process in which a district court may first detain a proposed mentally il individual if a preponderance of the evidence at an informal hearing shows that the person is mentally ill as that term is defined by the statute. §§ 25-10-109, 101(a)ix). The statutes then provide for a more formal hearing on whether the patient should be involuntarily hospitalized. At that hearing, a patient has the right to have the court (or a jury if one is timely requested) determine whether he suffers from mental illness to the extent that he is a danger to himself or others. § 25-10-110(b), (J). The pertinent portions of the statutes in question are as follows:
(a) Proceedings for the involuntary hospitalization of a person may be commenced by the filing of a written application with the court in the county in which the person is initially detained. Proceedings may also be initiated in the county in which there is a designated hospital if there is a written agreement executed by the county in which the person resides and the designated hospital stating that the county in which the person resides will be responsible for costs of treatment under W.S. 25-10-112(e) that are not covered by the state....
[[Image here]]
(c) Proceedings under this section shall be entitled "In the Interest of....". The county attorney of the county where the application is filed shall appear in the public interest. The court shall expedite the proceedings.
[[Image here]]
(b) The proposed patient, the applicant, and all others to whom notice is required may appear at the hearing to testify and may present witnesses. The court may receive the testimony of other persons. The proposed patient shall be present at the hearing unless he waives his right to appear. All persons not necessary to protect the rights of the parties shall be excluded from the hearing. The hearing shall be conducted in as informal a manner as is consistent with orderly procedure and in a physical setting which will not have a harmful effect on the mental health of the proposed patient. Any hearing conducted under this subsection shall be recorded by the court reporter or by electronic, mechanical or other appropriate means.
§ 25-10-110(a), (c), (h). The applicable statute provides for a prompt detention hearing preceding a formal involuntary commitment hearing:
(h) When a person is detained in emergency detention and an application for involuntary hospitalization is filed, the court shall appoint an attorney to represent the detained person unless he has his own attorney, and the court shall conduct a hearing within seventy-two (72) hours, excluding Saturdays, Sundays and legal holidays, of the initial detention to determine whether continued detention is required pending involuntary hospitalization proceedings.
§ 25-10-109(h).
[113] Appellants assert that §§ 25-10-109 and 110 clearly and unambiguously prescribe county attorneys' duties. We disagree and find the statute to be ambiguous as to the specific duties of a county attorney in emergency detention and involuntary hospitalization proceedings. The statutes do not explicitly define the county attorney's role in detention hearings, and they likewise do not expressly state what a county attorney appearing in the public interest must do. Appellants concede that the phrase "appear in the public interest" is ambiguous.
[114] Onee we have determined that a statute is ambiguous, we must apply general principles of statutory construction in an effort to determine the legislature's intent. Petroleum Inc. v. State ex rel. State *340Bd. of Equalization, 983 P.2d 1237, 1240 (Wyo.1999). "In ascertaining the legislative intent in enacting a statute the court must look to the mischief the act was intended to cure, the historical setting surrounding its enactment, the public policy of the state, the conditions of the law and all other prior and contemporaneous facts and circumstances that would enable the court intelligently to determine the intention of the lawmaking body." Id. (citations and ellipses omitted). This Court's responsibility in interpreting § 109 and § 110 is to follow the rule that provisions in pari materia are to be compared and harmonized, if possible, and, "if not susceptible of a construction which will make all of their provisions harmonize, they are made to operate together so far as possible consistently with the evident intent of the latest enactment." Huber v. Thomas, 45 Wyo. 440, 450, 19 P.2d 1042, 1044 (1933).
[115] Reading the provisions of Wyoming's statute governing the involuntary hospitalization of mentally ill persons in light of the rules for interpreting ambiguous statutes, we conclude that a county attorney has the duty to commence involuntary hospitalization proceedings by filing the written application, and that he must appear and present the case in support of the application on behalf of the State under Wyo. Stat. Aun. §§ 25-10-109 and 110.3 This conclusion assumes that the county attorney has determined that the application has merit and that the patient is in need of involuntary hospitalization, which is not a ministerial task. In other words, a county attorney retains discretion to determine in a particular case that the need for detention or involuntary hospitalization can or cannot be proven, but he or she cannot simply refuse to participate or limit participation after deciding to file the requisite application. There are a number of reasons to support our conclusion, including the following:
'The arrangement and connection of the words in §§ 109 and 110 lead to the logical conclusion that emergency detention and involuntary hospitalization hearings are parts of one proceeding. As set forth in § 110(a) and (c), the involuntary hospitalization of an individual is commenced by filing the requisite application which shall be entitled "In the Interest of ..." and the county attorney shall appear in the public interest. - Interrelated, in § 25-10-109(bh), when an examiner finds that the individual is mentally ill and an application for involuntary hospitalization is filed, the district court must hold the initial hearing within 72 hours, pending the subsequent hearing under § 110.
The term "appear," a verb, is synonymous with making an "appearance," a noun, which is defined as "[a] coming into court as a party or interested person, or as a lawyer on behalf of a party or interested person." - Black's Law Dictionary 118 (9th ed.2009); see Multiple Resort Ownership Plan, Inc., v. Design-Build-Manage, Inc., 2002 WY 67, ¶ 17, 45 P.3d 647, 653 (Wyo.2002). "Public interest" is defined as an interest in "[the general welfare of the public that warrants recognition and protection." Black's Law Dictionary, supra, at 1350. The interested party that a county attorney appears on behalf of then, is the State, which "exercises its parens patraie powers under Title 25 to care for those who cannot care for themselves." In re RB, ¶ 19, 294 P.3d at 30-31. Thus, the language of the statute means that a county attorney, in his capacity as the representative of the State *341at that stage of the proceedings, has a specific duty after filing the application to appear and go forward with presentation of the evidence justifying detention and commitment.
Looking at the mischief that the statute was intended to cure; that is, the object and purpose that the legislature intended to accomplish when it enacted the statute, further supports our conclusion. "The general purpose of civil commitment is to treat the individual's mental illness and protect him and society from his potential dangerousness." In re RB, ¶ 21, 294 P.3d at 30 (internal quotation marks omitted). A county attorney appearing on behalf of the State best serves the statute's purpose by commencing and presenting the case for detention or commitment, because these proceedings involve public safety, public funds, and most importantly the safety, wellbeing and liberty of proposed patients.
[T 16] Our conclusion is further supported by the fact that absurd results would follow if it were not the county attorney's duty to file the application and present the case during such proceedings. See In re RB, ¶ 17, 294 P.3d at 29 ("We do not construe statutes 'in a manner producing absurd results'"); see also McTiernan v. Jellis, 2013 WY 151, ¶ 20, 316 P.3d 1153, 1160 (Wyo.2013) (interpretation should not produce an absurd result). If county attorneys were not responsible for commencing and presenting the case during these proceedings, Appellants would have to execute their duties as "examiners" under § 25-10-101(a)iv) and § 25-10-109(a) and (b) and also then be forced to initiate and prosecute the court proceedings under §§ 109(h) and 110(a), which would probably require them to retain an attorney. That was obviously not the result the legislature intended when it enacted the provisions for involuntary hospitalization of mentally ill individuals.
[117] Appellants are not charged with appearing in the public interest or acting for the State at either the § 25-10-109(h) or § 25-10-110(a) hearings. There is no law which grants them the right to speak for the State and to execute its parens patraie powers under Title 25. The exercise of the State's police power must stem from a grant contained in the Wyoming Constitution or be delegated by the legislature. See K N Energy, Inc. v. City of Casper, 755 P.2d 207, 212 (Wyo.1988). There is no such delegation to Appellants in Title 25. Simply put, Appellants and their employees may have obligations as "examiners," but nothing in the statutes suggests that they have been empowered by the legislature to act in the "public interest" by presenting the case for commitment to the court; rather, a county attorney, a publically elected official, is delegated this heavy responsibility.
[118] The evolution of Wyoming's involuntary hospitalization statutes also supports the conclusion that a county attorney's duty is, and has been, to file the requisite application as well as appear on behalf of the State and present its case in support of the involuntary hospitalization of an individual at hearings under §§ 25-10-109 and 110. In 1929, the original act provided that a "lunacy commission" examined a proposed mentally ill person who had become the subject of a petition for commitment. See Wyo. Stat. § 51-207 (1945). Following the petition and examination, the statutes required a court hearing at which the county and prosecuting attorney was required to "appear and prosecute such petition for the state." Id. at § 51-208 (1945).
[119] Roughly thirty years later in 1963, the legislature amended the statute to require a form of emergency detention hearing followed by an involuntary hospitalization hearing, a procedure similar to the two-step process utilized today. See Wyo. Stat. §§ 25-59 & 60 (1957). The statute adopted back then required the county attorney to "cause all proceedings under this section to be expeditiously accomplished and [to] appear in the public interest and conduct the examination in chief of the witnesses." Wyo. Stat. § 25-60(c).
[120] In 1982, the legislature once again amended the statute to contain the current language: "The county and prosecuting attorney of the county where the application is filed shall appear in the public interest." *342§ 25-10-110(c)4 We are convinced the evolving language regarding civil commitment proceedings are mere stylistic changes which were not intended to scale back a county attorney's duties from what we have described above. See In re RB, ¶¶ 19-22, 294 P.3d at 29-30.
[121] Lastly, we address Mr. Skorie's assertion that our recent opinion in In re RB calls for a different result than the one we reach in this decision. In Im re RB, we decided that the plain language of Wyo. Stat. Ann. § 25-10-116(b) does not grant Wyoming county attorneys the authority to object to a patient's discharge from involuntary civil commitment or to obtain review of the State Hospital's decision to release a patient from involuntary hospitalization. See In re RB, ¶¶ 1, 45, 294 P.3d at 27, 35. In so holding, we explained that "the involuntary hospitalization statutes require the county attorney to participate in civil commitment proceedings, at least to the point at which the patient is actually hospitalized." Id. at ¶ 25, 294 P.3d at 31. Nothing in In re RB contradicts our conclusion in this case.
Writ of Mandamus
[122] Having found that a county attorney is responsible for commene-ing involuntary hospitalization proceedings by filing the requisite written application and must appear on behalf of the State and present its case in support of the detention and involuntary hospitalization of an individual at hearings under Wyo. Stat. Ann. § 25-10-109 and 110,5 we turn to whether the district court erred in denying Appellants' petition for writ of mandamus.
"Mandamus is a writ issued in the name of the state to an inferior tribunal, a corporation, board or person commanding the performance of an act which the law specially enjoins as a duty resulting from an office, trust or station." Wyo. Stat. Ann. § 1-30-101. ... The function of mandamus is to command performance of a ministerial duty which is plainly defined and required by law. Mandamus will not lie unless the duty is absolute, clear, and indisputable. The law must not only authorize the demanded action but require it. If the lower tribunal has the right to exercise discretion regarding an issue, mandamus is not an appropriate remedy.
Arnold, ¶ 16, 201 P.3d at 1133 (citations omitted). Suceinetly put, "[mJandamus will only issue if the respondent, at the time of the application for mandamus, owes a clear duty to perform to the plaintiff." 52 Am.Jur.2d Mandamus § 45 (2011); see also State ex rel. Epp v. Mayor, 894 P.2d 590, 595 (Wyo.1995) ("Mandamus will not lie unless the duty itself is absolute and incontrovertible, or clear, certain, and indisputable.").
[123] The provisions in dispute are not clear and certain on their face. We have had to employ rules of statutory construction to determine the duties of a county attorney. Mandamus was therefore not warranted when Appellants applied for this extraordinary relief,. See Arnold, 122, 201 P.3d at 1134; see also 55 C.J.S. Mandamus § 7 (2009) (Nature of Remedy-Extraordinary Nature of Relief). Accordingly, the district court did not abuse its discretion in denying Appellants' petition for writ of mandamus at that time. Now that we have construed the statute to impose a duty that Mr. Skorie did not previously believe to exist, we have no trepidation that the Park County Attorney's office will not faithfully perform that duty.
CONCLUSION
[124] A county attorney is responsible for commencing involuntary hospitalization proceedings by filing the requisite written application and must appear and present the *343State's case in support for involuntary hospitalization under Wyo. Stat. Ann. §§ 25-10-109 and 110. We recognize that a county attorney's duties are not plainly defined on the face of the statute, requiring us to interpret its ambiguous language according to applicable rules of statutory construction. Because mandamus may only issue if the respondent owes a clear, certain and indisputable duty to perform at the time of the application for mandamus, such extraordinary relief was not warranted when Appellants filed their petition.
. [125] Affirmed.
. A law enforcement officer or examiner (generally a mental health professional) who believes that a patient is mentally ill-meaning that he is a danger to himself or others and needs treatment-may initiate emergency detention in a local hospital or other suitable facility. See Wyo. Stat. Ann. §§ 25-10-109(a); 25-10-101(a)iv), (ix) (LexisNexis 2013).
. - That statute provides as follow:
(a) A person who willfully causes the unwarranted hospitalization of any individual under this act [§§ 25-10-101 through 25-10-305] is guilty of a felony punishable by a fine not exceeding five thousand dollars ($5,000.00) or imprisonment not exceeding five (5) years, or both.
(b) A person who willfully denies any individual any of the rights accorded to him under this act is guilty of a misdemeanor punishable by a fine not exceeding seven hundred fifty dollars ($750.00) or imprisonment not exceeding six (6) months, or both.
Wyo. Stat. Ann. § 25-10-126 (LexisNexis 2013).
. We note that the legislature recently enacted SEA 0019 (2014), which clarifies a county attorney's role in emergency detention hearings. Our conclusions in this opinion are entirely consistent with the clarifications that the legislature deemed fit to make to ensure county attorneys perform their duties accordingly. SEA 0019 becomes effective July 1, 2014 and states in pertinent part (emphasis in original):
25-10-109. - Emergency detention.
(h) When a person is detained in emergency detention and an application for involuntary hospitalization is filed by the county attorney, the court shall appoint an attorney to represent the detained person unless he has his own attorney, and the court shall conduct a hearing within seventy-two (72) hours, excluding Saturdays, Sundays and legal holidays, of the initial detention to determine whether continued detention is required pending involuntary hospitalization proceedings. The county attorney of the county where the application is filed shall appear on behalf of the state at the hearing. ....
. The 1982 revisions were in response to United States Supreme Court precedent concerning the rights of those who were considered mentally ill. See Robert B. Keiter, A Preliminary Review of Wyoming's Revised Civil Commitment Procedures, 17 Land & Water L.Rev. 531, 531-32 (1982).
. This statement assumes that the county attorney or deputy assigned to the case has determined that the evidence available supports detention or involuntary commitment. Nothing in this opinion is intended to suggest that county attorneys should not exercise their professional judgment on a case-by-case basis, or that they cannot or should not refuse to pursue detention or commitment in cases in which they do not believe the evidence supports it.