Cantor Function problem

• To: mathgroup at smc.vnet.net
• Subject: [mg74596] Cantor Function problem
• From: "Neelaka Seneviratne" <neelaka at gmail.com>
• Date: Tue, 27 Mar 2007 04:07:54 -0500 (EST)

```hi,

i am not a member of this group. but i have a difficulty in Mathematica that
you may be able to help with.
resolve it.
this is for a friend of mine who wants to generate the cantor function for
his BSc final year project.

thank you very much
neelaka seneviratne

spawn[{a_Rational, b_rational}] :=
Block [{w=(b-a)/3}, {{a-2w, a-w}, {b+w, b+2w}}]
spawn [intervals_list] := Flatten[Map[spawn, intervals], 1 /;
Length[intervals[]] >1

removedintervals[n_]:=
Flatten[NestList[spawn, {{1/3, 2/3}}, n-1], 1]

f = 1;
f[x_] := f[3x]/2   /; x<=1/3;
f[x_] := 1-f[1-x] /; 2/3<=x;

connect [{a_, b_}] := Block [{y=f[a]}, Line[{{a,y}, {b,y}}]]

CantorFunction[levels_] := show[Graphics[{Thickness[.001],
Map[connect, removedintervals[levels]]}],
Axes-> {0,0}, Ticks->{N[Range[0., 1, 1/9], 3], Automatic}]

```

• Prev by Date: Thread function now working as expected
• Next by Date: Sequence as a universal UpValue
{"ft_lang_label":"__label__en","ft_lang_prob":0.7850989,"math_prob":0.94693214,"size":1069,"snap":"2021-31-2021-39","text_gpt3_token_len":380,"char_repetition_ratio":0.092018776,"word_repetition_ratio":0.0,"special_character_ratio":0.3816651,"punctuation_ratio":0.22672065,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97716784,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-27T05:11:03Z\",\"WARC-Record-ID\":\"<urn:uuid:a38f72f4-29ff-4c32-bb3d-278f5963effe>\",\"Content-Length\":\"44718\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:56e2bbc4-a8cb-48ce-9b4e-0030f6bc1ed5>\",\"WARC-Concurrent-To\":\"<urn:uuid:80ba938b-e8c6-4b95-8d0f-fa9b19c11b3a>\",\"WARC-IP-Address\":\"140.177.205.73\",\"WARC-Target-URI\":\"https://forums.wolfram.com/mathgroup/archive/2007/Mar/msg00820.html\",\"WARC-Payload-Digest\":\"sha1:PM6JWAYRC5SKYQHH2IHV76ZWTJWE5O7F\",\"WARC-Block-Digest\":\"sha1:KAD25ROXQ4LTBTW4Q4JPPCIDLEHCZO2Z\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780058263.20_warc_CC-MAIN-20210927030035-20210927060035-00186.warc.gz\"}"}