<div dir="ltr">Thank you, this is amazing! I am a Racketeer for life.<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 26, 2013 at 10:02 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>Just add fuzzy-set? to the provide specification of fuzzy-set-library. Also add other functions as needed and provide them. </div>
<div><div><div><br></div><div><br></div><br><div><div>On Aug 26, 2013, at 9:09 PM, Rian Shams wrote:</div><br><blockquote type="cite"><div dir="ltr"><div dir="auto"><div><span></span></div><div><div>Thank you, a fuzzy-set-library is exactly what I am looking for. Initially I tried to create this library using the methodology you describe from the chapter on sets in "The Little Schemer," but after discovering structs in Racket I switched over. More recently I have been trying to emulate the set.rkt file that is provided in collect, but am finding this overwhelming (at least for the time being).</div>
<div><br></div><div>In order to define the fuzzy set operators I believe I would need fuzzy-set? and then selectors that correspond to each field. I am unclear as to why fuzzy-set? doesn't seem to exist and am not sure how to create fuzzy-set-first and fuzzy-set-rest (along with all of the other operators such as fuzzy-union, fuzzy-intersect , etc...) without having a fuzzy-set? made available.</div>
<div><br></div><div>My question is given:</div><div> </div><div><div>(fuzzy-set </div><div> (fuzzy-element 'a 1)</div><div> (fuzzy-element 'b .2)</div><div> (fuzzy-element 'c .2)</div><div>
(fuzzy-element 'd .3)))</div><div><br></div><div>in the way you defined fuzzy-set above, how do you create the function fuzzy-set? and how do you create fuzzy-first and fuzzy-rest ?</div><div><br></div>
<div>Thanks,</div><div>Rian</div></div><div><br></div><div>On Aug 23, 2013, at 8:02 PM, Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>> wrote:<br>
<br></div><blockquote type="cite"><div><div><br></div><div>Here is one more alternative: </div><div><br></div><div><div><div>#lang racket</div><div><br></div><div>;; you can move the body of this module into a '#lang racket' file called fuzzy-set-library.rkt </div>
<div>(module fuzzy-set-library racket </div><div> ;; rename-out is an elegant version of the let()/define-values trick in Realm of Racket </div><div> (provide (rename-out (fuzzy-set0 fuzzy-set)) (struct-out fuzzy-element))</div>
<div> </div><div> (struct fuzzy-element (val degree) #:transparent)</div><div> ;; FE = (fuzzy-element Any [0,1))</div><div> </div><div> (struct fuzzy-set (vals) </div><div> #:transparent </div><div> #:guard </div>
<div> ;; [List-of FE] -> Fuzzy-set</div><div> (lambda (le type-name)</div><div> (define-values (members _)</div><div> (for/fold ((s '()) (keys '())) ((x le))</div><div> (unless (fuzzy-element? x) </div>
<div> (error type-name "fuzzy-element expected, given: ~e" x))</div><div> (define k (fuzzy-element-val x))</div><div> (if (member k keys)</div><div> (values s keys)</div>
<div> (values (cons x s) (cons k keys)))))</div><div> (apply set members)))</div><div> ;; FuzzySet = (fuzzy-set [Set-of FE])</div><div> </div><div> (define (fuzzy-set0 . x) ;; <--- this means take as many arguments as there are, as a list </div>
<div> (fuzzy-set x))</div><div> </div><div> ;; add</div><div> ;; -- fuzzy-add-element </div><div> ;; -- fuzzy-union </div><div> ;; etc.</div><div> )</div><div><br></div><div>;; this could be a '#lang racket' file too</div>
<div>(module fuzzy-set-client racket </div><div> ;; then you replace this with the usual require </div><div> (require (submod ".." fuzzy-set-library))</div><div><br></div><div> (fuzzy-set</div><div> (fuzzy-element 'a .1)</div>
<div> (fuzzy-element 'b .2)</div><div> (fuzzy-element 'c .3)</div><div> (fuzzy-element 'a .3)))</div><div><br></div><div>;; drop this, it exists to test </div><div>(require 'fuzzy-set-client)</div></div>
</div><div><br></div><div><br></div><br><div><div>On Aug 23, 2013, at 3:49 PM, Rian Shams wrote:</div><br><blockquote type="cite"><div dir="ltr"><div>Hello All,<br></div><div><br></div><div>My name is Rian and I am a new Racket user and a novice programmer (Racket is my first language). First let me say that I am very grateful for the resources available online and the books, HTDP and Realm of Racket. I find your teaching methods very clear and as a result I am picking up Racket faster than I originally thought.</div>
<div><br></div><div>I am a System Science graduate student whose primary research focus is on Fuzzy Set Theory. A fuzzy set is a collection of distinct elements where each element has a degree of membership associated with it. </div>
<div><br></div><div>The representation I am currently using for a fuzzy set is the following:</div><div>First I create a struct called fuzzy-element which consists of 2 fields; the first is the name of the element and the second is the elements degree of membership to the set which ranges from 0 to 1.</div>
<div><br></div><div>;; Data Definition</div><div><br></div><div>#lang racket</div><div><br></div><div>(struct fuzzy-element (member degree-of-membership) </div><div> #:transparent</div><div> #:guard (lambda (member degree-of-membership type-name)</div>
<div> (cond</div><div> [(not (and (number? degree-of-membership)</div><div> (<= 0 degree-of-membership 1) degree-of-membership))</div><div> (error type-name</div>
<div> "~e is not a number between 0 and 1"</div><div> degree-of-membership)]</div><div> [else (values member degree-of-membership)])))</div><div>
<br></div><div>;; fuzzy-element is (fuzzy-element Symbol Number[0, 1])</div><div>;; interp. a fuzzy-element as a struct in which:</div><div>;; -the first field is the member's name</div>
<div>;; -the second field is the respective members degree of membership</div><div><br></div><div>Then I combine them with a list so what I have now is a list of fuzzy elements.</div><div><br></div><div><div>
;; ListOfFuzzyElement is one of:</div><div>;; - empty</div><div>;; - (cons fuzzy-element ListOfFuzzyElement)</div></div><div><br></div><div>The problem with this data definition is that it allows for duplicate structs with the same field-1 elements.</div>
<div><br></div><div>What I am looking to create is</div><div><br></div><div>;; A Fuzzy-Set is one of:</div><div>;; - empty list</div><div>;; - (cons <b>distinct</b> fuzzy-element ListOfFuzzyElement)</div><div>
<br></div><div><br></div><div><div><br></div><div><div>Ideally the type of representation I would like to use should look like: </div><div><br></div><div><div>(fuzzy-set (fuzzy-element 'a .1)</div><div> (fuzzy-element 'b .2)</div>
<div> (fuzzy-element 'c .3)</div><div> (fuzzy-element 'a .3))</div><div><br></div><div>-> (fuzzy-set (fuzzy-element 'a .1)</div><div> (fuzzy-element 'b .2)</div>
<div> (fuzzy-element 'c .3))</div></div><div><br></div><div>Upon evaluation, the last element, (fuzzy-element 'a .3) is deleted because there already exists a member named 'a (fuzzy-element 'a .1). It should work exactly like the built in "set" data type, except in this case it is a set of structures that checks the first fields of all structures and eliminates latter duplicates. </div>
</div><div><br></div><div>Any guidance on how to create fuzzy-set representation this way or if you can suggest more concise and elegant methods I would be greatly appreciative. </div><div><br></div><div>Thanks,</div>
-- <br>Rian Shams
</div></div>
____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br></blockquote></div><br></div></blockquote></div></div></div>
</blockquote></div><br></div></div></div></blockquote></div><br></div></div>