I have now this : 

(ns fourclojure.core
  (:gen-class))


(defn checker [x]
  ( = x (if (string? x)
    (clojure.string/reverse x)
    (into (empty x) (reverse x)))))


(checker '(1 2 3 4 5))     true


( = '( 1 2 3 4 5) '( 5 4 3 2 1) ) false

So something is wrong about my code 

it works fine with string but not with a set 

Roelof





Op woensdag 7 oktober 2015 23:40:11 UTC+2 schreef Erik Assum:

> I do believe that a palindrome could be defined as 
>
> user> (defn palindrome [s] (= s (clojure.string/reverse s))) 
> ;; => #'user/palindrome 
> user> (palindrome "agnesisenga") 
> ;; => true 
> user> 
>
> No need to split in half. 
>
>
> > On 7. okt. 2015, at 20.24, Tristan Strange <tristan...@gmail.com 
> <javascript:>> wrote: 
> > 
> > Hey Roelof, 
> > 
> > Moe's answered your question perfectly. 
> > 
> > Unfortunately I'm not sure it'll help you. All that's been written up 
> > there is a reverse function that works on both a string and a 
> > sequence. 
> > 
> > Firstly I think you might need to check up on what a palindrome is: 
> > https://en.wikipedia.org/wiki/Palindrome 
> > 
> > You need to: 
> > - take the first half of the sequence 
> > - take second half 
> > - compare them 
> > 
> > and work around the fact that sometimes sequences have an odd number 
> > of elements. 
> > 
> > Have you seen the take and drop functions yet? They'd really help. As 
> > would Math/floor and Math/ceil. Those, a reverse and an = will make 
> > bob your uncle. 
> > 
> > If you haven't seen them writing a recursive function would be a 
> solution too. 
> > 
> > I'm not sure what the "hint" is about. It seems very misleading to me. 
> > 
> > Good luck! 
> > 
> > Cheers, 
> > Tristan 
> > 
> > 
> > On 7 October 2015 at 19:06, Moe Aboulkheir <m...@nervous.io 
> <javascript:>> wrote: 
> >> Roelof, 
> >> 
> >> Something like this: 
> >> 
> >> (defn palindrome [x] 
> >>  (if (string? x) 
> >>    (clojure.string/reverse x) 
> >>    (into (empty x) (reverse x)))) 
> >> 
> >> Alternatively, you may want to consider explicitly using seq on your 
> inputs 
> >> when you get them, and using that of the basis of comparison & input to 
> >> reverse.  If you don't actually care about the concrete sequence type 
> (i.e. 
> >> you only want sensible equality semantics after reversing something), 
> >> dropping it as soon as possible may be a better strategy. 
> >> 
> >> Take care, 
> >> Moe 
> >> 
> >> On Wed, Oct 7, 2015 at 6:51 PM, Roelof Wobben <wobben...@gmail.com 
> <javascript:>> 
> >> wrote: 
> >>> 
> >>> Hello, 
> >>> 
> >>> I try to solve a problem for 4clojure where I have to make a 
> palingdrome 
> >>> detector. 
> >>> 
> >>> So for trying I did this : 
> >>> 
> >>> (ns fourclojure.core 
> >>>  (:gen-class)) 
> >>> 
> >>> 
> >>> (defn palingdrome [string] 
> >>>  ( reverse string)) 
> >>> 
> >>> (apply str (palingdrome '( 1 2 3) ))  '321' 
> >>> (apply str (palingdrome "Roelof" )) "foleoR" 
> >>> 
> >>> (defn palingdrome2 [string] 
> >>>  ( reverse string)) 
> >>> 
> >>> (palingdrome2 '( 1 2 3) )  ( 3 2 1 ) 
> >>> (palingdrome2  "Roelof" )  (\f \o \l \e \o \R) 
> >>> 
> >>> So it works for a map or for a string. 
> >>> 
> >>> Is there a way I can make it work for both ? 
> >>> 
> >>> Roelof 
> >>> 
> >>> 
> >>> 
> >>> -- 
> >>> You received this message because you are subscribed to the Google 
> >>> Groups "Clojure" group. 
> >>> To post to this group, send email to clo...@googlegroups.com 
> <javascript:> 
> >>> Note that posts from new members are moderated - please be patient 
> with 
> >>> your first post. 
> >>> To unsubscribe from this group, send email to 
> >>> clojure+u...@googlegroups.com <javascript:> 
> >>> For more options, visit this group at 
> >>> http://groups.google.com/group/clojure?hl=en 
> >>> --- 
> >>> You received this message because you are subscribed to the Google 
> Groups 
> >>> "Clojure" group. 
> >>> To unsubscribe from this group and stop receiving emails from it, send 
> an 
> >>> email to clojure+u...@googlegroups.com <javascript:>. 
> >>> For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> 
> >> -- 
> >> You received this message because you are subscribed to the Google 
> >> Groups "Clojure" group. 
> >> To post to this group, send email to clo...@googlegroups.com 
> <javascript:> 
> >> Note that posts from new members are moderated - please be patient with 
> your 
> >> first post. 
> >> To unsubscribe from this group, send email to 
> >> clojure+u...@googlegroups.com <javascript:> 
> >> For more options, visit this group at 
> >> http://groups.google.com/group/clojure?hl=en 
> >> --- 
> >> You received this message because you are subscribed to the Google 
> Groups 
> >> "Clojure" group. 
> >> To unsubscribe from this group and stop receiving emails from it, send 
> an 
> >> email to clojure+u...@googlegroups.com <javascript:>. 
> >> For more options, visit https://groups.google.com/d/optout. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com 
> <javascript:> 
> > Note that posts from new members are moderated - please be patient with 
> your first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@googlegroups.com <javascript:> 
> > For more options, visit this group at 
> > http://groups.google.com/group/clojure?hl=en 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups "Clojure" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to clojure+u...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to